Skip to content

enh: make SOCIAL_AUTH_USERNAME_IS_FULL_EMAIL configurable#409

Merged
stefanv merged 7 commits intocesium-ml:mainfrom
camilledzt:enh_enable_username_is_full_email_config
Apr 1, 2026
Merged

enh: make SOCIAL_AUTH_USERNAME_IS_FULL_EMAIL configurable#409
stefanv merged 7 commits intocesium-ml:mainfrom
camilledzt:enh_enable_username_is_full_email_config

Conversation

@camilledzt
Copy link
Copy Markdown
Contributor

@camilledzt camilledzt commented Jan 21, 2026

The goal of this PR is to make SOCIAL_AUTH_USERNAME_IS_FULL_EMAIL configurable via server.auth.username_is_email config option instead of being hardcoded. Default value is set to True

@stefanv
Copy link
Copy Markdown
Contributor

stefanv commented Mar 5, 2026

Hi Camille, thanks for this. I think it's fine to expose this change. Python Social Auth chose a confusing name for it, though, and maybe we can do better. What is the intent of the variable? What do we use as username if this is not set—whatever the OAuth provider returns? Also, it would be good to document all added options.

@camilledzt
Copy link
Copy Markdown
Contributor Author

Hello,
On skyportal, the username generation priority would be:

  • USERNAME_IS_FULL_EMAIL=True: Use email as username
  • USERNAME_IS_FULL_EMAIL=False (default): Use first initial + lastname, with auto-incrementing number if already exists
  • Fallback: Use details["username"] if first_name or last_name is unavailable

I can add documentation on Skyportal side.

The only goal to this PR is to expose SOCIAL_AUTH_USERNAME_IS_FULL_EMAIL variable and make it configurable.

@Theodlz
Copy link
Copy Markdown
Collaborator

Theodlz commented Mar 16, 2026

@camilledzt as we discussed on Thursday, please add a little of docs about these changes at the baselayer level. Please ping me once that's done and I'll review this and the SkyPortal PR!

@camilledzt
Copy link
Copy Markdown
Contributor Author

Hi @Theodlz, I added some docs about the configuration related to the username generation. Does it seem fine for you ?

Copy link
Copy Markdown
Contributor

@stefanv stefanv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me; I suggest we rename to username_is_email to make it more obvious what it does; "full" is confusing in the context of email addresses (what is a not-full email address!).

Ping me when you're ready to merge.

doc/setup.md Outdated

When `server.auth.username_is_full_email` is set to `True` (the default), the user's full email address is used as their username.

When set to `False`, the username is derived from the `username` field provided by the OAuth provider. For Google OAuth2, this is typically the local part of the email address (everything before `@`, e.g., `john.doe` from `john.doe@example.com`).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a sense of how it handles username conflicts?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that username is already taken, a random suffix is appended until a unique username is found. This logic is handled by the social_core library.

@Theodlz
Copy link
Copy Markdown
Collaborator

Theodlz commented Apr 1, 2026

@camilledzt is this ready for another round of review?

@camilledzt
Copy link
Copy Markdown
Contributor Author

Yes it's ready @Theodlz

@camilledzt
Copy link
Copy Markdown
Contributor Author

I will check the lint failing job

@camilledzt
Copy link
Copy Markdown
Contributor Author

Done. @Theodlz , can you approve this workflow ?

@Theodlz Theodlz requested a review from stefanv April 1, 2026 13:26
@stefanv stefanv merged commit f49da75 into cesium-ml:main Apr 1, 2026
3 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.

3 participants