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

feat: complete OIDC support for Apple and Google providers #1108

Merged
merged 5 commits into from
Jun 7, 2023

Conversation

hf
Copy link
Contributor

@hf hf commented May 17, 2023

Previously OIDC sign in (i.e. sign-in using an ID token) for Apple, Google and a few other providers was not properly supported. There was no account linking available, and there were a few security issues found with the implementation.

This PR attempts to resolve all of the issues, specifically targeting Apple and Google providers, which enables native Sign in with Apple and Google with mobile or desktop apps. Furthermore, this PR paves the way towards SSO with OIDC support.

Basically, the whole POST /token?grant_type=id_token endpoint is refactored to use the central createAccountFromExternalIdentity method which supports both regular and SSO accounts with automatic account linking.

For both Apple and Google flows, the important thing to realize is that their OAuth2 flows are in-fact OIDC authentication flows. The Apple OAuth2 flow already used the Apple OIDC ID token to extract user information. The Google OAuth2 flow is refactored to use the OIDC ID token when available (appears to be always) or fall back to the previous implementation.

Since it does not matter whether the flow is OAuth2 or OIDC, automatic account linking can take place.

The remaining OIDC supported providers -- Azure, Facebook, Keycloak -- remain supported though with upgraded account linking support; however their implementations are best-effort at this point. Furthermore, the Keycloak implementation should be deprecated as it's actually solving a SSO-with-OIDC problem.

@hf hf requested a review from a team as a code owner May 17, 2023 11:08
internal/api/provider/google.go Outdated Show resolved Hide resolved
internal/api/token_oidc.go Outdated Show resolved Hide resolved
@hf hf force-pushed the hf/native-oidc-sign-in branch 2 times, most recently from 53261ec to 5770b66 Compare May 23, 2023 12:55
internal/api/provider/oidc.go Show resolved Hide resolved
@hf hf force-pushed the hf/native-oidc-sign-in branch 2 times, most recently from 503608a to 9ec4370 Compare May 26, 2023 17:18
@hf hf force-pushed the hf/native-oidc-sign-in branch from 9ec4370 to 38482db Compare May 26, 2023 18:04
@kangmingtay
Copy link
Member

would prefer if we had split the support for multiple client IDs in a separate PR - feels like there's already alot going on here

@hf hf merged commit aab7c34 into master Jun 7, 2023
@hf hf deleted the hf/native-oidc-sign-in branch June 7, 2023 11:30
@github-actions
Copy link
Contributor

github-actions bot commented Jun 7, 2023

🎉 This PR is included in version 2.70.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

hf added a commit to supabase/auth-js that referenced this pull request Jun 29, 2023
Updates the `signInWithIdToken` API:

- No longer experimental.
- Adds optional `access_token` parameter.
- Updates the types on `provider`.
- More docs.

To be merged after release of:
supabase/auth#1108
uxodb pushed a commit to uxodb/auth that referenced this pull request Nov 13, 2024
uxodb pushed a commit to uxodb/auth that referenced this pull request Nov 13, 2024
…1108)

Previously OIDC sign in (i.e. sign-in using an ID token) for Apple,
Google and a few other providers was not properly supported. There was
no account linking available, and there were a few security issues found
with the implementation.

This PR attempts to resolve all of the issues, specifically targeting
Apple and Google providers, which enables native Sign in with Apple and
Google with mobile or desktop apps. Furthermore, this PR paves the way
towards SSO with OIDC support.

Basically, the whole `POST /token?grant_type=id_token` endpoint is
refactored to use the central `createAccountFromExternalIdentity` method
which supports both regular and SSO accounts with automatic account
linking.

For both Apple and Google flows, the important thing to realize is that
their OAuth2 flows are in-fact OIDC authentication flows. The Apple
OAuth2 flow already used the Apple OIDC ID token to extract user
information. The Google OAuth2 flow is refactored to use the OIDC ID
token when available (appears to be always) or fall back to the previous
implementation.

Since it does not matter whether the flow is OAuth2 or OIDC, automatic
account linking can take place.

The remaining OIDC supported providers -- Azure, Facebook, Keycloak --
remain supported though with upgraded account linking support; however
their implementations are best-effort at this point. Furthermore, the
Keycloak implementation should be deprecated as it's actually solving a
SSO-with-OIDC problem.
LashaJini pushed a commit to LashaJini/auth that referenced this pull request Nov 13, 2024
LashaJini pushed a commit to LashaJini/auth that referenced this pull request Nov 13, 2024
…1108)

Previously OIDC sign in (i.e. sign-in using an ID token) for Apple,
Google and a few other providers was not properly supported. There was
no account linking available, and there were a few security issues found
with the implementation.

This PR attempts to resolve all of the issues, specifically targeting
Apple and Google providers, which enables native Sign in with Apple and
Google with mobile or desktop apps. Furthermore, this PR paves the way
towards SSO with OIDC support.

Basically, the whole `POST /token?grant_type=id_token` endpoint is
refactored to use the central `createAccountFromExternalIdentity` method
which supports both regular and SSO accounts with automatic account
linking.

For both Apple and Google flows, the important thing to realize is that
their OAuth2 flows are in-fact OIDC authentication flows. The Apple
OAuth2 flow already used the Apple OIDC ID token to extract user
information. The Google OAuth2 flow is refactored to use the OIDC ID
token when available (appears to be always) or fall back to the previous
implementation.

Since it does not matter whether the flow is OAuth2 or OIDC, automatic
account linking can take place.

The remaining OIDC supported providers -- Azure, Facebook, Keycloak --
remain supported though with upgraded account linking support; however
their implementations are best-effort at this point. Furthermore, the
Keycloak implementation should be deprecated as it's actually solving a
SSO-with-OIDC problem.
LashaJini pushed a commit to LashaJini/auth that referenced this pull request Nov 15, 2024
LashaJini pushed a commit to LashaJini/auth that referenced this pull request Nov 15, 2024
…1108)

Previously OIDC sign in (i.e. sign-in using an ID token) for Apple,
Google and a few other providers was not properly supported. There was
no account linking available, and there were a few security issues found
with the implementation.

This PR attempts to resolve all of the issues, specifically targeting
Apple and Google providers, which enables native Sign in with Apple and
Google with mobile or desktop apps. Furthermore, this PR paves the way
towards SSO with OIDC support.

Basically, the whole `POST /token?grant_type=id_token` endpoint is
refactored to use the central `createAccountFromExternalIdentity` method
which supports both regular and SSO accounts with automatic account
linking.

For both Apple and Google flows, the important thing to realize is that
their OAuth2 flows are in-fact OIDC authentication flows. The Apple
OAuth2 flow already used the Apple OIDC ID token to extract user
information. The Google OAuth2 flow is refactored to use the OIDC ID
token when available (appears to be always) or fall back to the previous
implementation.

Since it does not matter whether the flow is OAuth2 or OIDC, automatic
account linking can take place.

The remaining OIDC supported providers -- Azure, Facebook, Keycloak --
remain supported though with upgraded account linking support; however
their implementations are best-effort at this point. Furthermore, the
Keycloak implementation should be deprecated as it's actually solving a
SSO-with-OIDC problem.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants