This commit is contained in:
@ -18,6 +18,7 @@ public class Configuration {
|
||||
private static final String ENV_OPENID_AUTH_URL = "MAVOR_OPENID_AUTH_URL";
|
||||
private static final String ENV_OPENID_TOKEN_URL = "MAVOR_OPENID_TOKEN_URL";
|
||||
private static final String ENV_OPENID_USERINFO_URL = "MAVOR_OPENID_USERINFO_URL";
|
||||
private static final String ENV_OPENID_LOGOUT_URL = "MAVOR_OPENID_LOGOUT_URL";
|
||||
|
||||
private String mavenExecutable;
|
||||
private String tempDir;
|
||||
@ -27,6 +28,7 @@ public class Configuration {
|
||||
private String openIdAuthUrl;
|
||||
private String openIdTokenUrl;
|
||||
private String openIdUserInfoUrl;
|
||||
private String openIdLogoutUrl;
|
||||
|
||||
public Configuration() throws IOException {
|
||||
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
||||
@ -49,6 +51,7 @@ public class Configuration {
|
||||
openIdAuthUrl = getNullSafeProperty(properties, ENV_OPENID_AUTH_URL);
|
||||
openIdTokenUrl = getNullSafeProperty(properties, ENV_OPENID_TOKEN_URL);
|
||||
openIdUserInfoUrl = getNullSafeProperty(properties, ENV_OPENID_USERINFO_URL);
|
||||
openIdLogoutUrl = getNullSafeProperty(properties, ENV_OPENID_LOGOUT_URL);
|
||||
}
|
||||
|
||||
private String getNullSafeProperty(Properties properties, String key) {
|
||||
@ -70,7 +73,7 @@ public class Configuration {
|
||||
public String getOpenIdClientSecret() {
|
||||
return openIdClientSecret;
|
||||
}
|
||||
|
||||
|
||||
public String getOpenIdRedirectUrl() {
|
||||
return openIdRedirectUrl;
|
||||
}
|
||||
@ -86,4 +89,8 @@ public class Configuration {
|
||||
public String getOpenIdUserInfoUrl() {
|
||||
return openIdUserInfoUrl;
|
||||
}
|
||||
|
||||
public String getOpenIdLogoutUrl() {
|
||||
return openIdLogoutUrl;
|
||||
}
|
||||
}
|
@ -2,23 +2,33 @@ package de.devloop.mavor.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import de.devloop.mavor.AuthenticatedServlet;
|
||||
import de.devloop.mavor.Configuration;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.annotation.WebServlet;
|
||||
import jakarta.servlet.http.HttpServlet;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
@WebServlet("/logout")
|
||||
public class Logout extends HttpServlet {
|
||||
private static final String OAUTH_LOGOUT_URL = "https://auth.devloop.de/application/o/devloop-mavor/end-session/";
|
||||
public class Logout extends AuthenticatedServlet {
|
||||
private Configuration configuration;
|
||||
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
public void init() throws ServletException {
|
||||
try {
|
||||
configuration = new Configuration();
|
||||
} catch (IOException e) {
|
||||
throw new ServletException("Configuration Error", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doAuthenticatedGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
HttpSession httpSession = req.getSession();
|
||||
if (httpSession != null) {
|
||||
httpSession.invalidate();
|
||||
}
|
||||
resp.sendRedirect(OAUTH_LOGOUT_URL);
|
||||
resp.sendRedirect(configuration.getOpenIdLogoutUrl());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user