Closed vsoch closed 6 years ago
second bug is fixed, I forgot to add the saml to the settings.py! The first is still an issue (with the capital letter) I think.
@vsoch I've got the same issue
social_core.exceptions.MissingBackend: Missing backend "saml" entry
Have you fixed the issue? If yes, would you like to let me know?
oh hmm, I think it came down to a mismatched version for Python social auth, but I can't remember to be honest. It looks like the version I was using is python-social-auth==0.3.5
(and maybe that resulted in the bug?) but then later I install social-auth-app-django
. Here is the applications I was working on, if it helps:
Could it be that your saml metadata isn't being found? Try accessing the URL and see if everything shows up as it should. This looks like a good thread / contender too --> https://github.com/ansible/awx/issues/715#issuecomment-351968394
And make sure you are using https://github.com/python-social-auth/social-core, I think this was the original version that was replaced by that?
Thanks for your help. I've installed the social-auth-core package
social-auth-core==1.7.0
I am working on local - localhost, which can be the reason? For your information, I am following instructions given by here. https://python-social-auth.readthedocs.io/en/latest/backends/saml.html#basic-usage
Did you install python3-saml
?
Yes. I did.
python3-saml==1.4.1
Have you gone to the saml.xml url and confirmed that it's there? Can you post here the fields that you are sending?
I didn't create any app to manage saml so just tried to use another app to add the view to download xml. Here it is.
def saml_metadata_view(request, *args, **kwargs):
complete_url = reverse('books:book_list', args=())
saml_backend = load_backend(
load_strategy(request),
"saml",
redirect_uri=complete_url,
)
metadata, errors = saml_backend.generate_metadata_xml()
if not errors:
return HttpResponse(content=metadata, content_type='text/xml')
I guess that the url might be the issue so I am creating a temp app to manage the saml
yes that is logical, the entire saml metadata object needs to be generated from your server via a URL, and you need an app to generate the URL from.
@vsoch Unfortunately I couldn't get it working. I hope you would like to give me a few hints. Here are my console logs.
Internal Server Error: /sso/
Traceback (most recent call last):
File "/home/alexis/Environments/bwb/lib/python3.6/site-packages/social_core/backends/utils.py", line 50, in get_backend
return BACKENDSCACHE[name]
KeyError: 'saml'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/alexis/Environments/bwb/lib/python3.6/site-packages/social_core/backends/utils.py", line 55, in get_backend
return BACKENDSCACHE[name]
KeyError: 'saml'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/alexis/Environments/bwb/lib/python3.6/site-packages/django/core/handlers/exception.py", line 35, in inner
response = get_response(request)
File "/home/alexis/Environments/bwb/lib/python3.6/site-packages/django/core/handlers/base.py", line 128, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/home/alexis/Environments/bwb/lib/python3.6/site-packages/django/core/handlers/base.py", line 126, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/alexis/workspace/ksw/BWB-Django-Platform/saml/views.py", line 14, in saml_metadata_view
redirect_uri=complete_url,
File "/home/alexis/Environments/bwb/lib/python3.6/site-packages/social_django/utils.py", line 27, in load_backend
Backend = get_backend(BACKENDS, name)
File "/home/alexis/Environments/bwb/lib/python3.6/site-packages/social_core/backends/utils.py", line 57, in get_backend
raise MissingBackend(name)
social_core.exceptions.MissingBackend: Missing backend "saml" entry
[06/Sep/2018 17:08:44] "GET /sso/ HTTP/1.1" 500 96921
/complete/saml/
Internal Server Error: /sso/
Traceback (most recent call last):
File "/home/alexis/Environments/bwb/lib/python3.6/site-packages/social_core/backends/utils.py", line 50, in get_backend
return BACKENDSCACHE[name]
KeyError: 'saml'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/alexis/Environments/bwb/lib/python3.6/site-packages/social_core/backends/utils.py", line 55, in get_backend
return BACKENDSCACHE[name]
KeyError: 'saml'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/alexis/Environments/bwb/lib/python3.6/site-packages/django/core/handlers/exception.py", line 35, in inner
response = get_response(request)
File "/home/alexis/Environments/bwb/lib/python3.6/site-packages/django/core/handlers/base.py", line 128, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/home/alexis/Environments/bwb/lib/python3.6/site-packages/django/core/handlers/base.py", line 126, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/alexis/workspace/ksw/BWB-Django-Platform/saml/views.py", line 14, in saml_metadata_view
redirect_uri=complete_url,
File "/home/alexis/Environments/bwb/lib/python3.6/site-packages/social_django/utils.py", line 27, in load_backend
Backend = get_backend(BACKENDS, name)
File "/home/alexis/Environments/bwb/lib/python3.6/site-packages/social_core/backends/utils.py", line 57, in get_backend
raise MissingBackend(name)
social_core.exceptions.MissingBackend: Missing backend "saml" entry
[06/Sep/2018 17:09:04] "GET /sso/ HTTP/1.1" 500 96921
Did you register the backend in your settings?
Yes, I think so. Here are the configuration.
UTHENTICATION_BACKENDS = (
# 'social_core.backends.open_id.OpenIdAuth',
# 'social_core.backends.google.GoogleOpenId',
# 'social_core.backends.google.GoogleOAuth2',
# 'social_core.backends.google.GoogleOAuth',
# 'social_core.backends.twitter.TwitterOAuth',
# 'social_core.backends.yahoo.YahooOpenId',
'django.contrib.auth.backends.ModelBackend',
)
I don't think it's there :)
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'social_core.backends.saml.SAMLAuth' # <----
)
Thank you so much, @vsoch
No one mentioned the configuration - social_core.backends.saml.SAMLAuth
.
XML download link works now. Thanks again.
I'm going to close this, since both our issues are resolved. Glad to help!
I'm trying to set up SAML following the instructions here:
http://python-social-auth.readthedocs.io/en/latest/installing.html
I'm not having trouble with the SAML part, but just getting the import of load_strategy and load_backend to work. it comes down to this one line, the bug is an ImportError that it cannot find
strategy
and this makes sense, because strategy is in uppercase:https://github.com/omab/python-social-auth/blob/master/social/apps/django_app/utils.py#L1
I changed that lowercase s to uppercase, and the site is working again. Now I'm getting this error:
I'm wondering why following the instructions for the new repo are leading to the installation of this old version? I'm following the installation instructions (is it a mistake to use pip?) and it always winds up that I have this particular file. I would really appreciate help, and maybe a working set of instructions for getting this working? Thank you!