Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Link OIDC accounts by unique identifier #3322

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

Closed
kylecarbs opened this issue Jul 31, 2022 · 1 comment · Fixed by #3441
Closed

Link OIDC accounts by unique identifier #3322

kylecarbs opened this issue Jul 31, 2022 · 1 comment · Fixed by #3441
Assignees
Labels
api Area: HTTP API

Comments

@kylecarbs
Copy link
Member

kylecarbs commented Jul 31, 2022

Introduced by #3314. OIDC accounts are currently linked by a verified email address from the provider. If a user's upstream email address changes, this would cause a new user to be created in Coder instead of associating it.

The sub (subject) and iss (issuer) Claims, used together, are the only Claims that an RP can rely upon as a stable identifier for the End-User, since the sub Claim MUST be locally unique and never reassigned within the Issuer for a particular End-User, as described in Section 2. Therefore, the only guaranteed unique identifier for a given End-User is the combination of the iss Claim and the sub Claim.

See: https://openid.net/specs/openid-connect-core-1_0.html#ClaimStability

Accounts should be linked by a unique identifier to the OIDC provider, not the email address. This can also take effect for OAuth2 authentication since each method (currently just GitHub) queries the upstream service API to get information (which would include a unique user ID).

The simplest solution seems to be a table of account links with a unique index of:

CREATE TABLE user_auth (
  user_id UUID NOT NULL REFERENCES users (id),
  login_type login_type NOT NULL,
  linked_id text NOT NULL,
  UNIQUE(user_id, login_type)
);

I don't see a reason to remove a link right now, but the implementor may discover one.

@sreya
Copy link
Collaborator

sreya commented Aug 2, 2022

@kylecarbs do we want to allow multiple forms of authentication for a user? It doesn't seem like other services allow that. For example with Gitlab I registered an account with an email and then tried to sign in with Google OAuth and it threw an error. Thinking we should probably do the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Area: HTTP API
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants