more configurations..
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
damage 2024-12-23 14:58:50 +01:00
parent 10537ea96b
commit aff6987fe2
3 changed files with 42 additions and 9 deletions

View File

@ -3,13 +3,29 @@
download a maven artifact and all its dependencies as zip
## Environment Variables
all environemnt variables are required
* `MAVOR_MAVEN_EXECUTABLE`: path to the maven executable, e.g. `/usr/bin/mvn`
* `MAVOR_TEMP_DIR`: path to a readable and writeable directory to temporarily store files, e.g. `/home/damage/Temp`
this environment variables are preset in docker image:
* `MAVOR_MAVEN_EXECUTABLE`: path to the maven executable
* `MAVOR_TEMP_DIR`: path to a readable and writeable directory to temporarily store files
this environemnt variables are required to be set in docker container:
* `MAVOR_OPENID_CLIENT_ID`: OpenID Client ID
* `MAVOR_OPENID_CLIENT_SECRET`: OpenID Client Secret - not yet providing docker secrets
* `MAVOR_OPENID_REDIRECT_URL`: OpenID Redirect URL - where to redirect after authentication
* `MAVOR_OPENID_AUTH_URL`: OpenID Authentication URL - where to redirect client for authentication
* `MAVOR_OPENID_TOKEN_URL`: OpenID Token URL - where to get a valid token after authentication
* `MAVOR_OPENID_USERINFO_URL`: OpenID User Info URL - where to get user informations from
* `MOVOR_OPENID_LOGOUT_URL`: OpenID Logout URL - where to redirect client for logout
## Development
To avoid setting environment variables during devleopment, create `src/main/resources/development.properties` with content like:
```
MAVOR_MAVEN_EXECUTABLE=/usr/bin/mvn
MAVOR_TEMP_DIR=/home/damage/Temp
MAVOR_OPENID_CLIENT_ID=foo
MAVOR_OPENID_CLIENT_SECRET=bar
MAVOR_OPENID_REDIRECT_URL=http://localhost:8080/mavor/authenticate
MAVOR_OPENID_AUTH_URL=https://auth.devloop.de/application/o/authorize/
MAVOR_OPENID_TOKEN_URL=https://auth.devloop.de/application/o/token/
MAVOR_OPENID_USERINFO_URL=https://auth.devloop.de/application/o/userinfo/
MOVOR_OPENID_LOGOUT_URL=https://auth.devloop.de/application/o/devloop-mavor-development/end-session/
```

View File

@ -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;
}
}

View File

@ -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());
}
}