-
Notifications
You must be signed in to change notification settings - Fork 152
Remove usage of com.nimbusds.oauth2 from grant-related classes #926
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
Conversation
msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/OAuthAuthorizationGrant.java
Outdated
Show resolved
Hide resolved
msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/AcquireTokenByAuthorizationGrantSupplier.java
Outdated
Show resolved
Hide resolved
msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/OnBehalfOfRequest.java
Outdated
Show resolved
Hide resolved
msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/OnBehalfOfRequest.java
Outdated
Show resolved
Hide resolved
msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/RefreshTokenRequest.java
Show resolved
Hide resolved
msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/OAuthAuthorizationGrant.java
Outdated
Show resolved
Hide resolved
msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/OAuthAuthorizationGrant.java
Show resolved
Hide resolved
msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/OAuthAuthorizationGrant.java
Show resolved
Hide resolved
msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/OAuthAuthorizationGrant.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments marked with issue
…tion-library-for-java into avdunn/nimbus-grants # Conflicts: # msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/OnBehalfOfRequest.java
msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/OAuthAuthorizationGrant.java
Show resolved
Hide resolved
params.putAll(authGrant.toParameters()); | ||
|
||
authGrant = new OAuthAuthorizationGrant(updatedGrant, authGrant.getParameters()); | ||
authGrant = new OAuthAuthorizationGrant(params, null, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe some constructor overloads if null, null
is a commonish case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This spot and one other in a test were the only places that used a double null, however another also had a null for the third parameter (claims) but not the second (scopes).
In the latest commit I added a constructor that omits the claims parameter, as that's the one that's most likely to be null in a flow.
msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/AcquireTokenByAuthorizationGrantSupplier.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
High level looks good. Two themes:
- Replace
Map<String, List<String>>
as the representation of params with some type with good helpers. OAuthAuthorizationGrant
seems immutable, so it doesn't need to recreate the params and add claims etc every time. Just do it at construction.
} else { | ||
authorizationGrant = new AuthorizationCodeGrant( | ||
new AuthorizationCode(parameters.authorizationCode()), parameters.redirectUri()); | ||
params.put("code_verifier", Collections.singletonList(parameters.codeVerifier())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure how much of PKCE was handled by nimbus, so please make sure we have enough tests that validate that auth_code uses PKCE. Both desktop and web app scenarios.
Ensure Base64URL decoding is used
Update version and changelog for release 1.20.1
Address codeql alerts
msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/AcquireTokenByAuthorizationGrantSupplier.java
Show resolved
Hide resolved
|
||
if (msalRequest.application().authenticationAuthority.authorityType != AuthorityType.AAD) { | ||
return authGrant; | ||
//Additional processing is only needed if it's a password grant with a non-AAD authority |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
User Real discovery needs to be done only for AAD authority. For non-AAD authority, perform the basic grant only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you got the condition correct, but the comment wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, the if statement correctly exits the method if it's not-AAD, however when writing the comment I just said "non-AAD" because of the != AuthorityType.AAD
part
Comment fixed in the latest commit
…tion-library-for-java into avdunn/nimbus-grants # Conflicts: # msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/TokenRequestExecutor.java
This PR removes the com.nimbusds.oauth2 dependency from various classes that deal with different grant types, as per #909
The dependency was mainly used by these classes to create maps of different parameters needed for each OAuth grant type, so the changes are mostly the same for each file:
com.nimbusds.oauth2.sdk.AuthorizationGrant
and various similar importsAuthorizationGrant
subclasses with our existingOAuthAuthorizationGrant
classAuthorizationGrant.toParameters()
method with our ownMap<String, List<String>>
creationGrantConstants
file for standardized OAuth parameter names and values