-
Notifications
You must be signed in to change notification settings - Fork 155
1211 Support stormpath_factor_challenge grant type; expose more info … #1214
Conversation
…from OAuthExceptions.
| /** | ||
| * Constructs {@link OAuthStormpathFactorChallengeGrantRequestAuthenticator}s. | ||
| * | ||
| * @since 1.1.0 |
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.
1.3.1
|
seems like a few new classes/interfaces in here. Add some new tests? |
mrioan
left a comment
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.
@palimpsestor I provided a few comments. Back to you
| catch (ResourceException re) { | ||
| assertEquals(re.getStatus(), 400) | ||
| assertEquals(re.getCode(), 13104) | ||
| assertEquals("The code submitted is not valid.", re.getDeveloperMessage()) |
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.
@palimpsestor We do not assert messages any longer, doing that has caused tests to begin to fail out of the blue since the the backend sometimes change them. Code and Status must be asserted since they are part of the "contract"
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.
Removed that assertion.
| private static final int KEY_MODULUS = (int) Math.pow(10, CODE_DIGITS); | ||
| private static final int CODE_DIGITS = 6; | ||
|
|
||
| private static int calculateCode(byte[] key, long tm) { |
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.
@palimpsestor Could you please add a comment here explaining what this function does? It seems that eventually we might need to reduce this logic but it will be difficult to achieve that without first understanding what this does. Thanks!
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.
Added a comment, and went ahead and simplified this method a bit. This is roughly identical to what we use on the IAM side when verifying a challenge to a Google Authenticator factor.
| private static final ObjectMapper objectMapper; | ||
|
|
||
| static { | ||
| objectMapper = new ObjectMapper(); |
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.
Can't this be initialized in line 30?
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.
Yes.
| } | ||
|
|
||
| json += "}"; | ||
| public OAuthException(OAuthErrorCode code, Map<String, Object> error, String message) { |
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.
Could you please move this constructor to line 59 so all the constructors are together?
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.
Done.
| if (action instanceof String) { | ||
| // get action map from error based on the action | ||
| Map<String, Object> errorMap = new LinkedHashMap<>(); | ||
| errorMap.put("error_description", defaultError.getProperty("error_description")); |
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.
Can't all this hardcoded properties being exposed in a single place as constants in order to be referenced here? This will help both avoid typos and avoid issues if any property is changed in the future
| @@ -0,0 +1,14 @@ | |||
| package com.stormpath.sdk.oauth; | |||
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.
Missing license header
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.
Added.
| @@ -0,0 +1,9 @@ | |||
| package com.stormpath.sdk.oauth; | |||
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.
Missing license header
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.
Added.
| /** | ||
| * @since 1.3.1 | ||
| */ | ||
| public interface OAuthStormpathFactorChallengeGrantRequestAuthenticator extends OAuthRequestAuthenticator<OAuthGrantRequestAuthenticationResult> { |
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.
Please add a short description to this interface, developers will be seeing this interface
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.
Added.
| @@ -0,0 +1,7 @@ | |||
| package com.stormpath.sdk.oauth; | |||
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.
Missing license header
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.
Added.
| /** | ||
| * @since 1.3.1 | ||
| */ | ||
| public interface OAuthStormpathFactorChallengeGrantRequestAuthenticatorFactory extends OAuthRequestAuthenticatorFactory<OAuthStormpathFactorChallengeGrantRequestAuthenticator> { |
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.
Please add a short description to this interface, developers will be seeing this interface
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.
Added.
|
@palimpsestor Travis is failing with this error: |
|
@palimpsestor. Approved. Merging now |
resolves #1211
…from OAuthExceptions.