Skip to content

Commit

Permalink
Correct error during refresh token flow without offline_access in sco…
Browse files Browse the repository at this point in the history
…pe parameter
  • Loading branch information
cgeorgilakis committed Aug 30, 2023
1 parent a9f9834 commit d1f4bf0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ Full Keycloak upstream jira issue can be shown if filtered by Fix version.

Our Keycloak version is working well with PostgreSQL database. For using other SQL databases, text field in database need to be evaluated.

## [Unreleased]
### Fixed
- Fix refresh flow with scope parameter problem[EGI dev oidc client refresh flow not allowed](https://trello.com/c/rwDjqUF0/2076-egi-dev-oidc-client-refresh-flow-not-allowed)

## [18.0.1-2.15] - 2023-23-08

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<jboss.snapshots.repo.url>https://s01.oss.sonatype.org/content/repositories/snapshots/</jboss.snapshots.repo.url>

<quarkus.version>2.7.5.Final</quarkus.version>
<eosc-kc.version>${project.version}-2.15</eosc-kc.version>
<eosc-kc.version>${project.version}-2.16rc1</eosc-kc.version>

<!--
Performing a Wildfly upgrade? Run the:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ public RefreshResult refreshAccessToken(KeycloakSession session, UriInfo uriInfo

if (generateRefreshToken) {
//refresh token must have same scope as old refresh token (type, scope, expiration)
responseBuilder.generateRefreshToken(refreshToken.getScope());
responseBuilder.generateRefreshToken(refreshToken.getScope(), clientSession);
}

if (validation.newToken.getAuthorization() != null
Expand Down Expand Up @@ -1159,12 +1159,14 @@ public AccessTokenResponseBuilder generateRefreshToken() {
return this;
}

public AccessTokenResponseBuilder generateRefreshToken(String scope) {
public AccessTokenResponseBuilder generateRefreshToken(String scope, AuthenticatedClientSessionModel clientSession) {
if (accessToken == null) {
throw new IllegalStateException("accessToken not set");
}

boolean offlineTokenRequested = Arrays.asList(scope.split(" ")).contains(OAuth2Constants.OFFLINE_ACCESS) ;
if (offlineTokenRequested)
clientSessionCtx = DefaultClientSessionContext.fromClientSessionAndScopeParameter(clientSession, scope, session);
generateRefreshToken(offlineTokenRequested);
refreshToken.setScope(scope);
return this;
Expand Down

0 comments on commit d1f4bf0

Please sign in to comment.