Lock username to GitHub username when authenticating using GitHub

User story: As a new user, when I authenticate with GitHub, my username is automatically set to whatever my GitHub username is, and I cannot change it unless I change my username on GitHub.

The reason this would be helpful is that our open source community, Free Code Camp, uses GitHub authentication for our website, Gitter chat, and our Discourse. We want to maintain a consistent identity across all three of these services (plus GitHub itself) for convenience and consistency.

This could be rolled into the same package as Import GitHub image as profile image when authenticating with GitHub

CC @michaelhenderson

2 Likes

We have a similar option with SSO, but I am not 100% sure this belongs in core, maybe as a site setting default off.

@sam yes - are you talking about this?

Even though this has been set to “0” I am still able to change my username.

Also, the SSO override option doesn’t seem to work as I understand it. I changed my username, signed out, then signed back in with GitHub and it did not revert my local username to my SSO username.

I’m not sure whether these are known issues or I’m just doing it wrong :slight_smile:

If you were still logged in as an Admin, that could be why. Admins are excluded by most settings that disable things. You might want to try that setting and login as a normal user.

6 Likes

@cpradio I just confirmed that non-admin users can also change their usernames. This user (who is a mod and not currently an admin) was able to change his username last night even though the “username change period” was set to 0. So this functionality does not seem to be working currently.

2 Likes

That also isn’t a good test. Staff seem to be immune, here is the logic:
https://github.com/discourse/discourse/blob/1e57bbf5c8f28e4439bd09a09e8ad368c56afd04/lib/guardian/user_guardian.rb#L8-L13

So you need a regular member.

4 Likes