Skip to content

Conversation

cemalkilic
Copy link
Contributor

@cemalkilic cemalkilic commented Jun 6, 2025

What kind of change does this PR introduce?

This PR adds support for Facebook Limited Login JWT (iOS only) to the /token?grant_type=id_token endpoint. This enables iOS apps using Facebook's Limited Login feature to authenticate with Supabase without requiring web browser redirects.

What is the current behavior?

Currently, the /token?grant_type=id_token endpoint does not support Facebook as a provider. When iOS apps using Facebook Limited Login try to authenticate with their JWT, they receive a Bad ID token error because Facebook's JWT structure is not recognized by the generic OIDC parser. This is already raised by users in #1522 as well.

What is the new behavior?

  • iOS apps can now authenticate using Facebook Limited Login JWT via signInWithIdToken() function on the client side
  • Facebook JWT are properly parsed and validated
  • End users can authenticate on iOS even if they dont allow tracking (ATT)

Additional context

Important: Android Platform Limitations

This implementation only supports iOS Facebook Limited Login. Android developers must continue using the standard OAuth flow (signInWithOAuth()) with web browser redirects.

Why Android is not supported in this PR:

  1. Fundamental Token Differences:
  • iOS: Facebook Limited Login provides self-contained JWT ID tokens that follow OIDC standards
  • Android: Facebook SDK only provides opaque access tokens (random strings, not JWTs)
  1. Validation Requirements:
  • iOS JW: Can be validated using standard OIDC/JWKS (already handled by our infrastructure)
  • Android access tokens: Require calling Facebook Graph API for validation
  1. Architectural Considerations:
  • The /token?grant_type=id_token endpoint is designed specifically for OIDC-compliant JWT
  • Adding Graph API validation for Android access tokens would be out of scope and violate the endpoint's single responsibility
  • It would essentially make this an "id_token OR access_token" endpoint, which breaks the grant type semantics

@cemalkilic cemalkilic requested a review from a team as a code owner June 6, 2025 13:43
@coveralls
Copy link

coveralls commented Jun 6, 2025

Pull Request Test Coverage Report for Build 15682490243

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 2 of 28 (7.14%) changed or added relevant lines in 1 file are covered.
  • 119 unchanged lines in 4 files lost coverage.
  • Overall coverage decreased (-0.3%) to 69.993%

Changes Missing Coverage Covered Lines Changed/Added Lines %
internal/api/provider/oidc.go 2 28 7.14%
Files with Coverage Reduction New Missed Lines %
internal/api/provider/oidc.go 4 45.95%
internal/api/invite.go 12 69.01%
internal/api/provider/apple.go 44 27.18%
internal/api/token_oidc.go 59 15.12%
Totals Coverage Status
Change from base Build 15475144987: -0.3%
Covered Lines: 11350
Relevant Lines: 16216

💛 - Coveralls

Copy link
Contributor

@hf hf left a comment

Choose a reason for hiding this comment

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

Looks good, just make sure you complete writing the test before merging!

Copy link
Contributor

@cstockton cstockton left a comment

Choose a reason for hiding this comment

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

test won’t be implemented as it might make harder future maintenance e.g if the signing key is rotated by facebook
@cemalkilic cemalkilic merged commit 4de7bd6 into master Jun 16, 2025
7 checks passed
@cemalkilic cemalkilic deleted the cemal/facebook-limited-login-support branch June 16, 2025 14:05
@Soilverts
Copy link

how to skip nonce check? its now not bad ID token but keep happening nonce mismatch.

cemalkilic added a commit that referenced this pull request Jul 17, 2025
## What kind of change does this PR introduce?

nonce matching isn't supported for facebook limited login, skipping it
during OIDC login. finalizes #2046
cemalkilic added a commit that referenced this pull request Aug 7, 2025
## What kind of change does this PR introduce?

This PR adds support for [Facebook Limited
Login](https://developers.facebook.com/docs/facebook-login/limited-login/)
JWT (iOS only) to the `/token?grant_type=id_token` endpoint. This
enables iOS apps using Facebook's Limited Login feature to authenticate
with Supabase without requiring web browser redirects.

## What is the current behavior?

Currently, the `/token?grant_type=id_token` endpoint does not support
Facebook as a provider. When iOS apps using Facebook Limited Login try
to authenticate with their JWT, they receive a `Bad ID token` error
because Facebook's JWT structure is not recognized by the generic OIDC
parser. This is already raised by users in
#1522 as well.

## What is the new behavior?

- iOS apps can now authenticate using Facebook Limited Login JWT via
`signInWithIdToken()` function on the client side
  - Facebook JWT are properly parsed and validated
- End users can authenticate on iOS even if they dont allow tracking
([ATT](https://developer.apple.com/documentation/apptrackingtransparency))

## Additional context

Important: Android Platform Limitations

This implementation only supports iOS Facebook Limited Login. Android
developers must continue using the standard OAuth flow
(`signInWithOAuth()`) with web browser redirects.

Why Android is not supported in this PR:

1. Fundamental Token Differences:
- iOS: Facebook Limited Login provides self-contained JWT ID tokens that
follow OIDC standards
- Android: Facebook SDK only provides opaque access tokens (random
strings, not JWTs)
2. Validation Requirements:
- iOS JW: Can be validated using standard OIDC/JWKS (already handled by
our infrastructure)
- Android access tokens: Require calling Facebook Graph API for
validation
3. Architectural Considerations:
- The /token?grant_type=id_token endpoint is designed specifically for
OIDC-compliant JWT
- Adding Graph API validation for Android access tokens would be out of
scope and violate the endpoint's single responsibility
- It would essentially make this an "id_token OR access_token" endpoint,
which breaks the grant type semantics

WIP: Tests in `oidc_test.go` will be added.
cemalkilic added a commit that referenced this pull request Aug 7, 2025
## What kind of change does this PR introduce?

nonce matching isn't supported for facebook limited login, skipping it
during OIDC login. finalizes #2046
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.

5 participants