Skip to content

Commit

Permalink
- Improvements with OKTA OIDC provider integration (#386)
Browse files Browse the repository at this point in the history
  • Loading branch information
afabiani authored Nov 12, 2024
1 parent c4d3b18 commit 94b0eab
Show file tree
Hide file tree
Showing 6 changed files with 431 additions and 185 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@

@XmlRootElement
public class SessionToken {
String token_type;
String access_token;
String refresh_token;
Long expires;
private String token_type;
private String access_token;
private String refresh_token;
private Long expires;
private String error;
private String warning;

@XmlElement(name = "token_type")
public String getTokenType() {
Expand Down Expand Up @@ -38,11 +40,29 @@ public void setExpires(Long expires) {
}

@XmlElement(name = "refresh_token")
public String getRefreshToken() {
return refresh_token;
}

public void setRefreshToken(String refresh_token) {
this.refresh_token = refresh_token;
}

public String getRefreshToken() {
return refresh_token;
@XmlElement(name = "error")
public String getError() {
return error;
}

public void setError(String error) {
this.error = error;
}

@XmlElement(name = "warning")
public String getWarning() {
return warning;
}

public void setWarning(String warning) {
this.warning = warning;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,16 @@ private SessionToken sessionToken(String accessToken, String refreshToken, Date
public void doLogout(String sessionId) {
HttpServletRequest request = OAuth2Utils.getRequest();
HttpServletResponse response = OAuth2Utils.getResponse();
AdapterConfig configuration =
GeoStoreContext.bean(KeyCloakConfiguration.class).readAdapterConfig();

// Check if request, response, or configuration are null
if (request == null || response == null || configuration == null) {
LOGGER.warn(
"Request, response, or configuration is null, unable to proceed with logout.");
return;
}

KeyCloakHelper helper = GeoStoreContext.bean(KeyCloakHelper.class);
KeycloakDeployment deployment = helper.getDeployment(request, response);
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
Expand All @@ -146,12 +156,10 @@ public void doLogout(String sessionId) {
refreshToken = ((KeycloakTokenDetails) authentication.getDetails()).getRefreshToken();
}
String logoutUrl = deployment.getLogoutUrl().build().toString();
AdapterConfig adapterConfig =
GeoStoreContext.bean(KeyCloakConfiguration.class).readAdapterConfig();
Configuration clientConfiguration = helper.getClientConfiguration(adapterConfig);
Configuration clientConfiguration = helper.getClientConfiguration(configuration);
Http http = new Http(clientConfiguration, (params, headers) -> {});
String clientId = adapterConfig.getResource();
String secret = (String) adapterConfig.getCredentials().get("secret");
String clientId = configuration.getResource();
String secret = (String) configuration.getCredentials().get("secret");
try {
http.post(logoutUrl)
.form()
Expand Down
Loading

0 comments on commit 94b0eab

Please sign in to comment.