-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Make OAuth2AuthorizationConsent customizable #436
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
Comments
Thanks for the report @fwollsch. I understand that you're looking to customize the |
Hello @jgrandja , yes, exactly. In my case it's the It doesn't have to be the I attached a video of how my consent page looks like: This may help to understand what I'm referring to. |
This makes sense @fwollsch. I was expecting to introduce a I will get to this shortly and propose a design that you can review and validate. |
@fwollsch, that's awesome!
GW2 FTW! I don't play much any more but I love that game! I used to play all the time. I'd love to hear more about your use case for the authorization server! (@sjohnr on twitter) So here's what I'm thinking. We can add a Map<Object, Object> context = new HashMap<>();
context.put(OAuth2AuthorizationConsent.Builder.class, authorizationConsentBuilder);
context.put(OAuth2Authorization.class, authorization);
context.put(OAuth2AuthorizationRequest.class, authorizationRequest);
OAuth2AuthenticationContext authenticationContext = new OAuth2AuthenticationContext(
authorizationCodeRequestAuthentication, context);
this.authorizationConsentCustomizer.customize(authenticationContext); We could possibly put other things into the context if needed. We could also look at creating a new strongly-typed context just for Either way, this should allow you access to all additional parameters and ability to customize the consent prior to saving.
Note: I'm not currently sure about handling multi-valued parameters. That would probably need to be a separate issue that we can evaluate the need to solve for, since additional parameters don't currently accomodate multiple values. Does this sound like a suitable solution? Any thoughts or concerns? |
Perfect! This sounds exactly how I imagined it. |
@sjohnr I couldn't reach you on Twitter, but maybe I just didnt find the DM button. My use case for Gw2 is to provide a unified and easier to use way to authorize applications to use your API-Tokens. The Gw2-API is extremely powerful (only read access, but still very powerful). Sadly, you can only create API-Tokens without a TTL or similar using the official website. So people end up (including me) having one API-Token with all permissions created on the official website and using that for every gw2 website/tool out there. Luckily, the Gw2-API provides one endpoint to create so-called "subtokens". Given another API-Token, you can request a subtoken with reduced permissions and an expiration time. The authorization server I'm building uses this Endpoint to provide authorized clients with subtokens for the gw2-accounts a user consented. You can check out the sourcecode if you like: https://github.com/gw2auth/oauth2-server |
Hi, I've just absorbed this change whilst testing 0.2.1 for another issue. I'm not using this customisation but my deny consent flow now breaks. This is due to the change in OAuth2AuthorizationCodeRequestAuthenticationProvider that now requires no additional parameters to be sent in order to return access denied. In my case, I'm happening to also submit a CSRF token |
Hi @markhobson. Thanks for bringing it up. This is a bit tricky, because this feature of adding support for custom authorization consent is essentially making authorized scopes not required, which per the spec, they are not. Therefore, we are looking for either scopes or some additional parameters to be present to determine whether to process the request as a consent. I don't know of any other signal we can look for to continue to support the deny consent flow. I could be wrong, but I think for consistency with your use case, the deny consent flow would have to submit the form without any parameters. If the CSRF token is also present as a form parameter, that might present a real problem with this approach, as I would think a CSRF token should be required when submitting authorization consent. We'll have to discuss this a bit more and see what options there are for this. |
Thanks for the report @markhobson. We'll address this before we release |
Thanks again @markhobson for catching this regression before the release next week. This should now be resolved via c418306. Can you please confirm the fix has restored original behaviour for your deny consent flow? |
Excellent ! Thanks for checking! |
Expected Behavior
When sending additional parameters from a consent-form, these additional parameters should by accessable by User-Code.
The OAuth2AuthorizationConsent should be customizable by a user-definable component before being passed to the OAuth2AuthorizationService.
Current Behavior
When sending additional parameters from a consent-form, these additional parameters are present inside the OAuth2AuthorizationCodeRequestAuthenticationToken.
The OAuth2AuthorizationConsent is created only using the authorized scopes.
Context
In my OAuth2-Server, a user can create multiple entities.
On the consent-page, the user can review all requested scopes and select which of its entities the client should be given access to.
My consent-page HTML looks like this:
I need some way to know which entities have been selected by the user on the consent-page.
In my case, all selected entity-ids are present in the OAuth2AuthorizationCodeRequestAuthenticationToken.getAdditionalParameters(), but these are never passed to any User-Code.
Ideally, I'd like to customize the OAuth2AuthorizationConsent before it's being passed to the OAuth2AuthorizationService with access to the additional parameters.
As a workaround, I currently use a custom OAuth2AuthorizationCodeRequestAuthenticationProvider:
Side Nodes
The additionalParameters are currently created by passing all Request-Parameters that are not explicitly known (such as scope, client_id and state), but only the first value is actually added to the additionalParameters.
This requires my consent-page to send each selected entity using a different name (like in the example HTML above).
Ideally, I would like to use one name (for example "entity") and send the selected entities with their id as a value (like it works with scope at the moment).
The text was updated successfully, but these errors were encountered: