Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidate the id stored against the Saml2 user to avoid duplicates #102

Open
wants to merge 1 commit into
base: link-master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions ckanext/saml2/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def identify(self):
try:
# Update the user account from the authentication response
# every time
c.userobj = self._create_or_update_user(c.user, saml_info)
c.userobj = self._create_or_update_user(c.user, saml_info, name_id)
c.user = c.userobj.name
except Exception as e:
log.error(
Expand Down Expand Up @@ -389,7 +389,7 @@ def identify(self):
redirect_after_login = config.get('saml2.redirect_after_login', '/dashboard')
h.redirect_to(redirect_after_login)

def _create_or_update_user(self, user_name, saml_info):
def _create_or_update_user(self, user_name, saml_info, name_id):
"""Create or update the subject's user account and return the user
object"""
data_dict = {}
Expand Down Expand Up @@ -426,7 +426,6 @@ def _create_or_update_user(self, user_name, saml_info):
if is_new_user:
email = _take_from_saml_or_user('email', saml_info, data_dict)
new_user_username = _get_random_username_from_email(email)
name_id = _take_from_saml_or_user('id', saml_info, data_dict)
data_dict['name'] = new_user_username
data_dict['id'] = unicode(uuid.uuid4())
log.debug("Creating user: %s", data_dict)
Expand Down