-
-
Notifications
You must be signed in to change notification settings - Fork 109
OidcProperty follow-ups; Fix application of clock skew to generated credentials
#654
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
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
85b77e7
This is actually non-null
Vlatombe ad2e6b1
No need for isApplicable, use a static factory method instead.
Vlatombe 70a38fa
Only throw ObjectStreamException in readResolve
Vlatombe 6e4127b
Fix reviews
Vlatombe e2b8e19
Can't use the static factory for DisableTokenVerification, as there i…
Vlatombe 56c562a
Simplify readResolve, these are handled in corresponding properties c…
Vlatombe 3332e15
Clean up test references of removed methods
Vlatombe 9a9a85d
Spotless
Vlatombe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -372,43 +372,49 @@ | |
| } | ||
|
|
||
| @SuppressWarnings("deprecated") | ||
| protected Object readResolve() throws IOException, FormException { | ||
| protected Object readResolve() throws ObjectStreamException { | ||
| if (properties == null) { | ||
| properties = new DescribableList<>(Saveable.NOOP); | ||
| } | ||
| // Fail if migrating to a FIPS non-compliant config | ||
| if (FIPS140.useCompliantAlgorithms()) { | ||
| if (isDisableSslVerification()) { | ||
| throw new IllegalStateException(Messages.OicSecurityRealm_DisableSslVerificationFipsMode()); | ||
| if (FIPS140.useCompliantAlgorithms() && isDisableSslVerification()) { | ||
| throw new IllegalStateException(Messages.OicSecurityRealm_DisableSslVerificationFipsMode()); | ||
| } | ||
| try { | ||
| if (nonceDisabled) { | ||
| properties.replace(new DisableNonce()); | ||
| } | ||
| if (isDisableTokenVerification() || properties.get(DisableTokenVerification.class) != null) { | ||
| throw new IllegalStateException(Messages.OicSecurityRealm_DisableTokenVerificationFipsMode()); | ||
| if (pkceEnabled) { | ||
| properties.replace(new Pkce()); | ||
| } | ||
| if (isEscapeHatchEnabled() || properties.get(EscapeHatch.class) != null) { | ||
| throw new IllegalStateException(Messages.OicSecurityRealm_EscapeHatchFipsMode()); | ||
| if (disableTokenVerification) { | ||
| properties.replace(new DisableTokenVerification()); | ||
| } | ||
| if (allowedTokenExpirationClockSkewSeconds != null) { | ||
| var value = allowedTokenExpirationClockSkewSeconds.intValue(); | ||
| if (value != 60) { | ||
| properties.replace(new AllowedTokenExpirationClockSkew(value)); | ||
| } | ||
| } | ||
| if (loginQueryParameters != null) { | ||
| properties.replace(new LoginQueryParameters(loginQueryParameters)); | ||
| } | ||
| if (logoutQueryParameters != null) { | ||
| properties.replace(new LogoutQueryParameters(logoutQueryParameters)); | ||
| } | ||
| if (escapeHatchEnabled) { | ||
| properties.replace(new EscapeHatch(escapeHatchUsername, escapeHatchGroup, escapeHatchSecret)); | ||
| } | ||
| } catch (IOException e) { | ||
| var ose = new InvalidObjectException("Error while migrating properties"); | ||
| ose.initCause(e); | ||
| throw ose; | ||
| } catch (FormException e) { | ||
| var ose = new InvalidObjectException(e.getFormField() + ": " + e.getMessage()); | ||
| ose.initCause(e); | ||
| throw ose; | ||
| } | ||
| if (nonceDisabled) { | ||
| properties.replace(new DisableNonce()); | ||
| } | ||
| if (pkceEnabled) { | ||
| properties.replace(new Pkce()); | ||
| } | ||
| if (disableTokenVerification) { | ||
| properties.replace(new DisableTokenVerification()); | ||
| } | ||
| if (allowedTokenExpirationClockSkewSeconds != null && allowedTokenExpirationClockSkewSeconds != 60L) { | ||
| properties.replace(new AllowedTokenExpirationClockSkew(allowedTokenExpirationClockSkewSeconds.intValue())); | ||
| } | ||
| if (loginQueryParameters != null) { | ||
| properties.replace(new LoginQueryParameters(loginQueryParameters)); | ||
| } | ||
| if (logoutQueryParameters != null) { | ||
| properties.replace(new LogoutQueryParameters(logoutQueryParameters)); | ||
| } | ||
| if (escapeHatchEnabled) { | ||
| properties.replace(new EscapeHatch(escapeHatchUsername, escapeHatchGroup, escapeHatchSecret)); | ||
| } | ||
|
|
||
| if (!Strings.isNullOrEmpty(endSessionUrl)) { | ||
| this.endSessionEndpoint = endSessionUrl + "/"; | ||
| } | ||
|
|
@@ -463,26 +469,6 @@ | |
| return this; | ||
| } | ||
|
|
||
| @Deprecated | ||
| public void setLoginQueryParameters(List<LoginQueryParameter> values) { | ||
| this.loginQueryParameters = values; | ||
| } | ||
|
|
||
| @Deprecated | ||
| public List<LoginQueryParameter> getLoginQueryParameters() { | ||
| return loginQueryParameters; | ||
| } | ||
|
|
||
| @Deprecated | ||
| public void setLogoutQueryParameters(List<LogoutQueryParameter> values) { | ||
| this.logoutQueryParameters = values; | ||
| } | ||
|
|
||
| @Deprecated | ||
| public List<LogoutQueryParameter> getLogoutQueryParameters() { | ||
| return logoutQueryParameters; | ||
| } | ||
|
|
||
| public String getClientId() { | ||
| return clientId; | ||
| } | ||
|
|
@@ -555,26 +541,6 @@ | |
| return postLogoutRedirectUrl; | ||
| } | ||
|
|
||
| @Deprecated | ||
| public boolean isEscapeHatchEnabled() { | ||
| return escapeHatchEnabled; | ||
| } | ||
|
|
||
| @Deprecated | ||
| public String getEscapeHatchUsername() { | ||
| return escapeHatchUsername; | ||
| } | ||
|
|
||
| @Deprecated | ||
| public Secret getEscapeHatchSecret() { | ||
| return escapeHatchSecret; | ||
| } | ||
|
|
||
| @Deprecated | ||
| public String getEscapeHatchGroup() { | ||
| return escapeHatchGroup; | ||
| } | ||
|
|
||
| public boolean isRootURLFromRequest() { | ||
| return rootURLFromRequest; | ||
| } | ||
|
|
@@ -583,18 +549,6 @@ | |
| return sendScopesInTokenRequest; | ||
| } | ||
|
|
||
| public boolean isPkceEnabled() { | ||
| return pkceEnabled; | ||
| } | ||
|
|
||
| public boolean isDisableTokenVerification() { | ||
| return disableTokenVerification; | ||
| } | ||
|
|
||
| public boolean isNonceDisabled() { | ||
| return nonceDisabled; | ||
| } | ||
|
|
||
| public boolean isTokenExpirationCheckDisabled() { | ||
| return tokenExpirationCheckDisabled; | ||
| } | ||
|
|
@@ -603,15 +557,6 @@ | |
| return allowTokenAccessWithoutOicSession; | ||
| } | ||
|
|
||
| /** | ||
| * @deprecated use {@link AllowedTokenExpirationClockSkew} instead. | ||
| * @return | ||
| */ | ||
| @Deprecated | ||
| public Long getAllowedTokenExpirationClockSkewSeconds() { | ||
| return allowedTokenExpirationClockSkewSeconds; | ||
| } | ||
|
|
||
| public DescribableList<OidcProperty, OidcPropertyDescriptor> getProperties() { | ||
| return properties; | ||
| } | ||
|
|
@@ -737,19 +682,6 @@ | |
| this.postLogoutRedirectUrl = Util.fixEmptyAndTrim(postLogoutRedirectUrl); | ||
| } | ||
|
|
||
| @Deprecated | ||
| public void setEscapeHatchEnabled(boolean escapeHatchEnabled) throws FormException { | ||
| if (FIPS140.useCompliantAlgorithms() && escapeHatchEnabled) { | ||
| throw new FormException("Escape Hatch cannot be enabled in FIPS environment", "escapeHatchEnabled"); | ||
| } | ||
| this.escapeHatchEnabled = escapeHatchEnabled; | ||
| } | ||
|
|
||
| @Deprecated | ||
| public void setEscapeHatchUsername(String escapeHatchUsername) { | ||
| this.escapeHatchUsername = Util.fixEmptyAndTrim(escapeHatchUsername); | ||
| } | ||
|
|
||
| @DataBoundSetter | ||
| public void setEscapeHatchSecret(Secret escapeHatchSecret) { | ||
| if (escapeHatchSecret != null) { | ||
|
|
@@ -765,18 +697,6 @@ | |
| this.escapeHatchSecret = escapeHatchSecret; | ||
| } | ||
|
|
||
| @Deprecated | ||
| protected boolean checkEscapeHatch(String username, String password) { | ||
| final boolean isUsernameMatch = username.equals(this.escapeHatchUsername); | ||
| final boolean isPasswordMatch = BCrypt.checkpw(password, Secret.toString(this.escapeHatchSecret)); | ||
| return isUsernameMatch & isPasswordMatch; | ||
| } | ||
|
|
||
| @Deprecated | ||
| public void setEscapeHatchGroup(String escapeHatchGroup) { | ||
| this.escapeHatchGroup = Util.fixEmptyAndTrim(escapeHatchGroup); | ||
| } | ||
|
|
||
| @DataBoundSetter | ||
| public void setRootURLFromRequest(boolean rootURLFromRequest) { | ||
| this.rootURLFromRequest = rootURLFromRequest; | ||
|
|
@@ -787,26 +707,6 @@ | |
| this.sendScopesInTokenRequest = sendScopesInTokenRequest; | ||
| } | ||
|
|
||
| @Deprecated | ||
| public void setPkceEnabled(boolean pkceEnabled) { | ||
| this.pkceEnabled = pkceEnabled; | ||
| } | ||
|
|
||
| @DataBoundSetter | ||
| @Deprecated | ||
| public void setDisableTokenVerification(boolean disableTokenVerification) throws FormException { | ||
|
Comment on lines
-795
to
-797
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this break CasC even if you set the flag to tolerate deprecated properties? (see #655) |
||
| if (FIPS140.useCompliantAlgorithms() && disableTokenVerification) { | ||
| throw new FormException( | ||
| Messages.OicSecurityRealm_DisableTokenVerificationFipsMode(), "disableTokenVerification"); | ||
| } | ||
| this.disableTokenVerification = disableTokenVerification; | ||
| } | ||
|
|
||
| @Deprecated | ||
| public void setNonceDisabled(boolean nonceDisabled) { | ||
| this.nonceDisabled = nonceDisabled; | ||
| } | ||
|
|
||
| @DataBoundSetter | ||
| public void setTokenExpirationCheckDisabled(boolean tokenExpirationCheckDisabled) { | ||
| this.tokenExpirationCheckDisabled = tokenExpirationCheckDisabled; | ||
|
|
@@ -817,14 +717,6 @@ | |
| this.allowTokenAccessWithoutOicSession = allowTokenAccessWithoutOicSession; | ||
| } | ||
|
|
||
| /** | ||
| * @deprecated use {@link AllowedTokenExpirationClockSkew} instead. | ||
| */ | ||
| @Deprecated | ||
| public void setAllowedTokenExpirationClockSkewSeconds(Long allowedTokenExpirationClockSkewSeconds) { | ||
| this.allowedTokenExpirationClockSkewSeconds = allowedTokenExpirationClockSkewSeconds; | ||
| } | ||
|
|
||
| @Override | ||
| public String getLoginUrl() { | ||
| // Login begins with our doCommenceLogin(String,String) method | ||
|
|
@@ -1279,7 +1171,7 @@ | |
| refreshToken != null ? refreshToken.getValue() : null, | ||
| accessToken == null ? 0 : accessToken.getLifetime(), | ||
| CLOCK.millis(), | ||
| getAllowedTokenExpirationClockSkewSeconds()); | ||
| (long) client.getConfiguration().getMaxClockSkew()); | ||
|
jtnord marked this conversation as resolved.
|
||
|
|
||
| loginAndSetUserData(username, idToken, profile.getAttributes(), oicCredentials); | ||
|
|
||
|
|
@@ -1456,7 +1348,7 @@ | |
| refreshToken.getValue(), | ||
| accessToken.getLifetime(), | ||
| CLOCK.millis(), | ||
| getAllowedTokenExpirationClockSkewSeconds()); | ||
| (long) client.getConfiguration().getMaxClockSkew()); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto |
||
|
|
||
| loginAndSetUserData(username, idToken, profile.getAttributes(), refreshedCredentials); | ||
| return true; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
(ignore WS)