Skip to content

Commit

Permalink
More places in which the bearer token should be extracted
Browse files Browse the repository at this point in the history
  • Loading branch information
aaime committed Sep 19, 2018
1 parent 6797e27 commit e9e21d2
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,7 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
throws IOException, ServletException {

// Search for an access_token on the request (simulating SSO)
String accessToken = getParameterValue("access_token", request);
if (accessToken == null) {
accessToken = getBearerToken(request);
}
String accessToken = getAccessTokenFromRequest(request);

OAuth2AccessToken token = restTemplate.getOAuth2ClientContext().getAccessToken();

Expand Down Expand Up @@ -201,7 +198,7 @@ protected String getParameterValue(String paramName, ServletRequest request) {
/** The cache key is the authentication key (global identifier) */
@Override
public String getCacheKey(HttpServletRequest request) {
final String access_token = getParameterValue("access_token", request);
final String access_token = getAccessTokenFromRequest(request);
return access_token != null ? access_token : getCustomSessionCookieValue(request);
}

Expand Down Expand Up @@ -369,7 +366,7 @@ protected String getPreAuthenticatedPrincipal(HttpServletRequest req, HttpServle
*/

// Search for an access_token on the request (simulating SSO)
final String accessToken = getParameterValue("access_token", req);
String accessToken = getAccessTokenFromRequest(req);

if (accessToken != null) {
restTemplate
Expand Down Expand Up @@ -460,6 +457,14 @@ protected String getPreAuthenticatedPrincipal(HttpServletRequest req, HttpServle
return principal;
}

private String getAccessTokenFromRequest(ServletRequest req) {
String accessToken = getParameterValue("access_token", req);
if (accessToken == null) {
accessToken = getBearerToken(req);
}
return accessToken;
}

protected void configureRestTemplate() {
AuthorizationCodeResourceDetails details =
(AuthorizationCodeResourceDetails) restTemplate.getResource();
Expand Down

0 comments on commit e9e21d2

Please sign in to comment.