Skip to content
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

OIDC okta testing #386

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading