Skip to content

[BUG] SSO module looking for non-existent ID claim #8269

@steveiliop56

Description

@steveiliop56

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Using an OIDC server like Tinyauth (which does not include the user-info claims in the ID token), set-up a demo application with SSO and try to login. You will be greeted with the error=invalid_provider&error_description=missing_user_info error.

Current vs. Expected behavior

Looking through the code, specifically here:

if (!userInfo.email || !userInfo.id) {
throw ctx.redirect(
`${
errorURL || callbackURL
}?error=invalid_provider&error_description=missing_user_info`,
);
}

Seems like better-auth is trying to extract some id claim from the user-info endpoint. However, according to Section 5.1 of the OIDC specification, the OIDC server is not obligated to return such claim. Normally, better-auth should be looking for the sub claim (containing the ID of the user that remains static despite of profile changes) instead of an id one.

I am guessing that since most OIDC providers include the claims in the ID token (which is not required according to Section 2), the user-info extraction logic from the ID token happens first and thus there is no need to check the user-info endpoint which would most likely fail.

What version of Better Auth are you using?

1.5.0

System info

Not relevant to the issue.

Which area(s) are affected? (Select all that apply)

Client

Auth config (if applicable)

Not applicable.

Additional context

No response

Metadata

Metadata

Labels

bugSomething isn't workinglockedLocked conversations after being closed for 7 days

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions