+
Skip to content

Verification of external facebook token via "debug token" endpoint #40720

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

Merged
merged 1 commit into from
Jun 26, 2025

Conversation

graziang
Copy link
Contributor

Closes #40163

Added a check to ensure that the client_id matches the app_id contained in the response from the custom Facebook /debug_token endpoint. To invoke the debug endpoint, an "app access token" is required, which can either be in the form client_id|client_secret or obtained via the client credentials grant. However, I noticed that with the default settings, the "app access token" is returned from client credential grant as client_id|client_secret in plain so I skipped this additional step. Since we don't have automated tests, I also added the option to disable this verification (enabled by default).

@graziang graziang requested a review from a team as a code owner June 25, 2025 15:20
@mposolda mposolda self-assigned this Jun 26, 2025
@mposolda
Copy link
Contributor

@graziang Did you manage to have successfully working external-to-internal token exchange with Facebook token and with ExternalToInternalTokenExchangeProvider ? I have some doubts it would work with your PR as the FacebookIdentityProvider does not implement exchangeExternalTokenV2Impl method in your PR. I see the change in doGetFederatedIdentity(), which is the method triggered during classic "Login with Facebook", but not during token exchange AFAIK. It may seem to me that this method does not need to be changed anyhow?

I think that right now, the steps for testing this might be like:

  • Start KC server with ./kc.sh start-dev --features=admin-fine-grained-authz:v1,token-exchange-external-internal:v2
  • Setup Facebook IDP in some realm and issue Facebook token somehow (Might be probably through Keycloak login and user clicking to "Login to Facebook")
  • Setup some client and FGAP:v1 for external-to-internal as mentioned in the external-to-internal docs (I think we will need to get rid of FGAP being required like we have for standard token exchange, but right now, it is still required in ExternalToInternalTokenExchangeProvider ).
  • Exchange external to internal as described in the docs for external-internal and make sure that ExternalToInternalTokenExchangeProvider was triggered and Keycloak token was issued successfully based on Facebook token and verification took place.

Closes keycloak#40163

Signed-off-by: Giuseppe Graziano <g.graziano94@gmail.com>
@graziang
Copy link
Contributor Author

@mposolda Thanks for the review, I messed up the requirements. I've updated the PR and successfully tested everything manually.

Copy link
Contributor

@mposolda mposolda left a comment

Choose a reason for hiding this comment

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

@graziang Thanks! I hope to merge once tests are OK.

Good catch with parameter access_token in the format of clientId|clientSecret :-)

@mposolda mposolda added the status/ready Ready to be merged label Jun 26, 2025
@mposolda mposolda merged commit 150ac63 into keycloak:main Jun 26, 2025
84 of 86 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/ready Ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Verification of external facebook token by facebook "debug token" endpoint
2 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载