Skip to content

Commit

Permalink
The "saferJWT" method should be called only when logging. It should n…
Browse files Browse the repository at this point in the history
…ot truncate the token normally. (#373)

(cherry picked from commit 7e1abcd)
  • Loading branch information
afabiani committed Oct 10, 2024
1 parent 50a38e4 commit ebe9b6e
Showing 1 changed file with 12 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import static it.geosolutions.geostore.services.rest.security.oauth2.OAuth2Utils.*;

import java.util.Objects;
import java.util.Optional;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -88,33 +89,27 @@ protected OAuth2AccessToken acquireAccessToken(OAuth2ClientContext oauth2Context
&& (!accessTokenRequest.getAuthorizationCode().isEmpty())) {
LOGGER.debug(
"OIDC: received a CODE from Identity Provider - handing it in for ID/Access Token");
LOGGER.debug("OIDC: CODE=" + accessTokenRequest.getAuthorizationCode());
LOGGER.debug("OIDC: CODE={}", accessTokenRequest.getAuthorizationCode());
if (result != null) {
LOGGER.debug(
"OIDC: Identity Provider returned Token, type="
+ result.getTokenType());
LOGGER.debug("OIDC: SCOPES=" + String.join(" ", result.getScope()));
final String accessToken = saferJWT(result.getValue());
LOGGER.debug("OIDC: ACCESS TOKEN:" + accessToken);
RequestContextHolder.getRequestAttributes()
"OIDC: Identity Provider returned Token, type={}",
result.getTokenType());
LOGGER.debug("OIDC: SCOPES={}", String.join(" ", result.getScope()));
final String accessToken = result.getValue();
LOGGER.debug("OIDC: ACCESS TOKEN:{}", saferJWT(accessToken));
Objects.requireNonNull(RequestContextHolder.getRequestAttributes())
.setAttribute(ACCESS_TOKEN_PARAM, accessToken, 0);
if (result.getAdditionalInformation().containsKey("refresh_token")) {
final String refreshToken =
saferJWT(
(String)
result.getAdditionalInformation()
.get("refresh_token"));
LOGGER.debug("OIDC: REFRESH TOKEN:" + refreshToken);
(String) result.getAdditionalInformation().get("refresh_token");
LOGGER.debug("OIDC: REFRESH TOKEN:{}", saferJWT(refreshToken));
RequestContextHolder.getRequestAttributes()
.setAttribute(REFRESH_TOKEN_PARAM, accessToken, 0);
}
if (result.getAdditionalInformation().containsKey("id_token")) {
final String idToken =
saferJWT(
(String)
result.getAdditionalInformation()
.get("id_token"));
LOGGER.debug("OIDC: ID TOKEN:" + idToken);
(String) result.getAdditionalInformation().get("id_token");
LOGGER.debug("OIDC: ID TOKEN:{}", saferJWT(idToken));
RequestContextHolder.getRequestAttributes()
.setAttribute(ID_TOKEN_PARAM, accessToken, 0);
}
Expand Down

0 comments on commit ebe9b6e

Please sign in to comment.