You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dlab.apache.org by bh...@apache.org on 2019/09/20 09:12:50 UTC
[incubator-dlab] branch DLAB-terraform updated: [DLAB-1018]: Added
possibility to logout
This is an automated email from the ASF dual-hosted git repository.
bhliva pushed a commit to branch DLAB-terraform
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
The following commit(s) were added to refs/heads/DLAB-terraform by this push:
new dfa74fa [DLAB-1018]: Added possibility to logout
new 5c68417 Merge pull request #314 from ofuks/DLAB-1018
dfa74fa is described below
commit dfa74fa0d78ac8d47403843edcaca06041b68c70
Author: Oleh Fuks <ol...@gmail.com>
AuthorDate: Wed Sep 18 15:31:22 2019 +0300
[DLAB-1018]: Added possibility to logout
---
.../dlab/backendapi/resources/KeycloakResource.java | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/services/self-service/src/main/java/com/epam/dlab/backendapi/resources/KeycloakResource.java b/services/self-service/src/main/java/com/epam/dlab/backendapi/resources/KeycloakResource.java
index c1802bd..fae5418 100644
--- a/services/self-service/src/main/java/com/epam/dlab/backendapi/resources/KeycloakResource.java
+++ b/services/self-service/src/main/java/com/epam/dlab/backendapi/resources/KeycloakResource.java
@@ -6,7 +6,9 @@ import com.epam.dlab.backendapi.service.SecurityService;
import com.google.inject.Inject;
import io.dropwizard.auth.Auth;
+import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.net.URI;
@@ -16,8 +18,10 @@ import java.net.URISyntaxException;
public class KeycloakResource {
private static final String LOGIN_URI_FORMAT = "%s/realms/%s/protocol/openid-connect/auth?client_id=%s" +
"&response_type=code";
+ private static final String LOGOUT_URI_FORMAT = "%s/realms/%s/protocol/openid-connect/logout?redirect_uri=";
private final SecurityService securityService;
private final String loginUri;
+ private final String logoutUri;
@Inject
public KeycloakResource(SecurityService securityService, SelfServiceApplicationConfiguration configuration) {
@@ -27,6 +31,10 @@ public class KeycloakResource {
configuration.getKeycloakConfiguration().getAuthServerUrl(),
configuration.getKeycloakConfiguration().getRealm(),
configuration.getKeycloakConfiguration().getResource());
+ logoutUri =
+ String.format(LOGOUT_URI_FORMAT,
+ configuration.getKeycloakConfiguration().getAuthServerUrl(),
+ configuration.getKeycloakConfiguration().getRealm());
}
@GET
@@ -47,4 +55,17 @@ public class KeycloakResource {
public Response authorize(@Auth UserInfo userInfo) {
return Response.ok().build();
}
+
+ @GET
+ @Path("/logout")
+ public Response logout(final @Context HttpServletRequest request) throws URISyntaxException {
+ StringBuilder redirectUri = new StringBuilder(logoutUri);
+ redirectUri.append(request.getScheme());
+ redirectUri.append("://");
+ redirectUri.append(request.getServerName());
+ redirectUri.append("/#/login");
+ return Response.noContent()
+ .location(new URI(redirectUri.toString()))
+ .build();
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org