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

Support for OAuth2 Strava #37850

Merged
merged 1 commit into from
Jan 4, 2024
Merged

Conversation

sberyozkin
Copy link
Member

@sberyozkin sberyozkin commented Dec 19, 2023

Fixes #37839.

CC @gastaldi

It requires adding integration test for the new option, will look a bit later

Copy link
Contributor

@gastaldi gastaldi left a comment

Choose a reason for hiding this comment

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

LGTM, added a minor observation but I think it can be ignored

Copy link

github-actions bot commented Dec 19, 2023

🙈 The PR is closed and the preview is expired.

@sberyozkin
Copy link
Member Author

Thanks George @gastaldi, sure, I'll simplify as you suggested.
I’ve just been thinking that this PR will need a bit more hardening work. The problem is, Strava does not force a specific redirect url, only a domain, and even though, if combined with other security mechanisms it can be safe, it is strongly recommended to enforce a unique redirect uri.

So, since Strava itself doesn't do it, Quarkus can do it itself. It has quarku.oidc.authentication.redirect-path, which we also register in Google, etc and all the providers enforce it. But in this case Quarkus should do an extra check itself if that property is set and then it will be tested.

Once this check is in, it will be safer to offer this integration. Not sure though when I'll complete it, 🙂, but happy enough it works in principle, will also check with Pedro.

Cheers

@sberyozkin sberyozkin force-pushed the oidc_strava branch 2 times, most recently from dc520ca to 62314a7 Compare December 22, 2023 18:07
@sberyozkin sberyozkin marked this pull request as ready for review December 22, 2023 18:08
@sberyozkin
Copy link
Member Author

Hi @gastaldi

Today I have added an integration test checking the client query authentication mode which is required by Strava, I had to fix a minor but not related to this enhancement (OidcProvider.SymmetricKeyResolver) - this is a test issue only - this key resolver is used to support all the well-known OAuth2 providers we already support - but none of the them require client id and secret POSTed to them as body form parameters, instead they are encoded in the Basic authentication, and once I updated the test to try POSTing them as body form parameters, the fact that OidcProvider.SymmetricKeyResolver does not check all the configuration properties where the client secret can be configured showed itself, so I fixed it.

Also, as promised earlier, I have added a hardening fix to enforce a precise redirect URI match when, after authenticating to Strava, the user is redirected back to Quarkus. I've updated the docs clarifying why it has to be done, linking to the OAuth2 best security practices draft spec. By the way - this is a typical issue when Google, and other providers will fail in case of the redirect_uri mismatch, see for example, https://developers.google.com/identity/protocols/oauth2/web-server#creatingclient, so with this hardening fix, the authentication will fail earlier in Quarkus, avoiding a remote call to Google/etc.

Now, I'm happy enough with this PR to go in, but I'll also keep it till early January in case yourself and Pedro would like to comment more.

Confirmed the latest code is working with Strava.

String redirectPath = getRedirectPath(configContext.oidcConfig, context);
if (configContext.oidcConfig.authentication.redirectPath.isPresent()
Copy link
Member Author

@sberyozkin sberyozkin Dec 22, 2023

Choose a reason for hiding this comment

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

@gastaldi @pedroigor This is the only hardening code that I've added to enforce a precise path match at the Quarkus level. For example, if the configured redirect path is /a/b/c but the current request attempting to complete the code flow is /a then it means, assuming the best and wide-spread practice that a registered application in my-provider has configured www.my-provider-app/a/b/c then this redirect may not be coming from that provider . We haven't had to deal it with it before because the providers will enforce such checks. For example, I linked to Google docs and it can easily be confirmed with all providers here except Strava that a mismatch will cause an eventual failure, but, it costs a remote call, and we rely on providers to do the right thing, so this simple check will make the initial check done early at the Quarkus level which is important for the Strava case.
This is also why I'm not considering this check changing the OIDC logic as such, it is only a hardening check

Copy link
Member Author

Choose a reason for hiding this comment

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

I've found it difficult to test this specific check though as it is difficult to verify the test failed exactly because of this check, I've spent quite some time today on it

Copy link
Member Author

@sberyozkin sberyozkin Jan 4, 2024

Choose a reason for hiding this comment

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

@gastaldi Hi George, I've now added a test for this condition by modifying one of the existing CodeFlowTest integration tests, not perfect but is probably closest to what can be done without having to create a dedicated integration module and check logs. So I'm happy enough now.

This comment has been minimized.

@quarkus-bot quarkus-bot bot added the area/docstyle issues related for manual docstyle review label Jan 2, 2024
@sberyozkin
Copy link
Member Author

@gastaldi @pedroigor I've only updated the docs a bit, specifically, I've added a small section to the providers doc explaining how to deal with the configured redirect url now that Strava enforces it.

I'll hold on though with merging for another day or so and send a short update to the forum

This comment has been minimized.

This comment has been minimized.

@sberyozkin
Copy link
Member Author

@gastaldi Tweaked the docs a bit more, resolved the conflict, will hold on with the merge for another day, thanks

This comment has been minimized.

Copy link

quarkus-bot bot commented Jan 4, 2024

✔️ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

@sberyozkin
Copy link
Member Author

OK, let me merge now

@sberyozkin sberyozkin merged commit ba118bc into quarkusio:main Jan 4, 2024
25 checks passed
@quarkus-bot quarkus-bot bot added the kind/enhancement New feature or request label Jan 4, 2024
@sberyozkin sberyozkin deleted the oidc_strava branch January 4, 2024 16:16
@quarkus-bot quarkus-bot bot added this to the 3.7 - main milestone Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/docstyle issues related for manual docstyle review area/documentation area/oidc kind/enhancement New feature or request
Projects
Development

Successfully merging this pull request may close these issues.

Support Strava OAuth2 provider
2 participants