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

Populate username from sociallogin #577

Conversation

smcgu
Copy link
Contributor

@smcgu smcgu commented Jan 29, 2025

This should resolve #576.

It prioritizes the username from data and uses sociallogin as the fallback.

Copy link

codecov bot commented Jan 29, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.97%. Comparing base (f727e27) to head (0449122).
Report is 5 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #577   +/-   ##
=======================================
  Coverage   91.97%   91.97%           
=======================================
  Files         323      323           
  Lines       18690    18690           
=======================================
  Hits        17190    17190           
  Misses       1500     1500           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@chrismaddalena
Copy link
Collaborator

As discussed in Slack, the changes look OK but will need some testing. I tried the change with Google auth, which caused the account name and username to be set to Google User and googleuser, respectively. There's probably an easy change to fix your issue with Open ID and Jump Cloud while keeping the same desirable functionality with Microsoft, Google, and others. I will look into it more this week.

@smcgu
Copy link
Contributor Author

smcgu commented Jan 30, 2025

This change should only affect the username, so I think this indicates there may be a bug with the subsequent code under populate_user. Can you share an example of what data contains for one of these other providers?

Nothing jumps out to me on where username would be used for the user name.

I'll see if I can test one of these other providers locally, too.

@smcgu
Copy link
Contributor Author

smcgu commented Jan 30, 2025

Tested Ok with GitHub OAuth.

data: {'email': None, 'username': 'smcgu', 'name': 'Sean'}

@smcgu
Copy link
Contributor Author

smcgu commented Jan 30, 2025

How is your Google OAuth app set up? I just tested on my end and the name turned out okay. The username ended up being the Google account's first/given name. So, I'll update this PR in a few with a fallback to use to the first part of the email address.

data: {'email': '[email protected]', 'last_name': 'Doe', 'first_name': 'John'}
extra_data: {'iss': 'https://accounts.google.com', 'azp': '...', 'a
ud': '...', 'sub': '...', 'email': '[email protected]', 'email_verified': True, 'at_hash': '...', 'name': 'John Doe', 'picture': '...', 'given_name': 'John', 'family_name': 'Doe'
, 'iat': ..., 'exp': ...}

In this case, the Ghostwriter user was created with the following:

@smcgu
Copy link
Contributor Author

smcgu commented Jan 30, 2025

How is your Google OAuth app set up? I just tested on my end and the name turned out okay. The username ended up being the Google account's first/given name. So, I'll update this PR in a few with a fallback to use to the first part of the email address.

data: {'email': '[email protected]', 'last_name': 'Doe', 'first_name': 'John'}
extra_data: {'iss': 'https://accounts.google.com', 'azp': '...', 'a
ud': '...', 'sub': '...', 'email': '[email protected]', 'email_verified': True, 'at_hash': '...', 'name': 'John Doe', 'picture': '...', 'given_name': 'John', 'family_name': 'Doe'
, 'iat': ..., 'exp': ...}

In this case, the Ghostwriter user was created with the following:

* Full Name: John Doe
* Username: john
* Email: [[email protected]](mailto:[email protected])

The updated commit results now in the Ghostwriter user being:

@chrismaddalena
Copy link
Collaborator

Thanks for taking a crack at that. As mentioned in Slack, it was a temporary issue on Google's end. With no change, I stopped receiving "Google User" as an account name when I started testing this morning, so I have to imagine it was on Google's side. I have tested your latest changes and everything looks good. I'll merge it for the next release.

@chrismaddalena chrismaddalena merged commit 5140ad4 into GhostManager:master Feb 3, 2025
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Username not populated from sociallogin
2 participants