-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Use substring instead of replaceFirst in OAuth2AuthorizationConsent #1223
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,7 +93,7 @@ public Set<String> getScopes() { | |
Set<String> authorities = new HashSet<>(); | ||
for (GrantedAuthority authority : getAuthorities()) { | ||
if (authority.getAuthority().startsWith(AUTHORITIES_SCOPE_PREFIX)) { | ||
authorities.add(authority.getAuthority().replaceFirst(AUTHORITIES_SCOPE_PREFIX, "")); | ||
authorities.add(authority.getAuthority().substring(AUTHORITIES_SCOPE_PREFIX.length())); | ||
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.
How did you conduct the test? 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. This is all the testing information: public static void main(String[] args) {
String scope = "SCOPE_";
String email = "SCOPE_email";
int count = 10000000;
long start1 = System.currentTimeMillis();
for (int i = 0; i < count; i++) {
String s = email.replaceFirst(scope, "");
}
long end1 = System.currentTimeMillis();
System.out.println("replaceFirst : " + (end1 - start1));
long start2 = System.currentTimeMillis();
for (int i = 0; i < count; i++) {
String s = email.substring(scope.length());
}
long end2 = System.currentTimeMillis();
System.out.println("substring : " + (end2 - start2));
System.out.println("count : " + count);
}
|
||
} | ||
} | ||
return authorities; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,12 +65,6 @@ public Authentication convert(HttpServletRequest request) { | |
principal = ANONYMOUS_AUTHENTICATION; | ||
} | ||
|
||
String sessionId = null; | ||
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. Please revert this as it's not related to the proposed 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. ok |
||
HttpSession session = request.getSession(false); | ||
if (session != null) { | ||
sessionId = session.getId(); | ||
} | ||
|
||
// client_id (OPTIONAL) | ||
String clientId = parameters.getFirst(OAuth2ParameterNames.CLIENT_ID); | ||
if (StringUtils.hasText(clientId) && | ||
|
@@ -92,6 +86,12 @@ public Authentication convert(HttpServletRequest request) { | |
throwError(OAuth2ErrorCodes.INVALID_REQUEST, OAuth2ParameterNames.STATE); | ||
} | ||
|
||
String sessionId = null; | ||
HttpSession session = request.getSession(false); | ||
if (session != null) { | ||
sessionId = session.getId(); | ||
} | ||
|
||
return new OidcLogoutAuthenticationToken(idTokenHint, principal, | ||
sessionId, clientId, postLogoutRedirectUri, state); | ||
} | ||
|
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 revert this as it's not related to the proposed
replaceFirst()
changeThere 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.
ok
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.
@jgrandja I will submit a new PR for this section. Do you think this is a good idea?
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.
The use of "less" is proper grammar so we will leave as-is