Compare commits
No commits in common. "85d16ebfc7df6f4acae512917c3cc4d70720c84b" and "aa11ffc47b8b75ae4794e48060b6deb4ffbb60b8" have entirely different histories.
85d16ebfc7
...
aa11ffc47b
@ -9,7 +9,6 @@ this environment variables are preset in docker image:
|
|||||||
* `MAVOR_TEMP_DIR`: path to a readable and writeable directory to temporarily store files
|
* `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:
|
this environemnt variables are required to be set in docker container:
|
||||||
* `MAVOR_WEB_ROOT`: Base URL of how the client access the web page
|
|
||||||
* `MAVOR_OPENID_CLIENT_ID`: OpenID Client ID
|
* `MAVOR_OPENID_CLIENT_ID`: OpenID Client ID
|
||||||
* `MAVOR_OPENID_CLIENT_SECRET`: OpenID Client Secret - not yet providing docker secrets
|
* `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_REDIRECT_URL`: OpenID Redirect URL - where to redirect after authentication
|
||||||
@ -21,7 +20,6 @@ this environemnt variables are required to be set in docker container:
|
|||||||
## Development
|
## Development
|
||||||
To avoid setting environment variables during devleopment, create `src/main/resources/development.properties` with content like:
|
To avoid setting environment variables during devleopment, create `src/main/resources/development.properties` with content like:
|
||||||
```
|
```
|
||||||
MAVOR_WEB_ROOT=http://localhost:8080/mavor
|
|
||||||
MAVOR_MAVEN_EXECUTABLE=/usr/bin/mvn
|
MAVOR_MAVEN_EXECUTABLE=/usr/bin/mvn
|
||||||
MAVOR_TEMP_DIR=/home/damage/Temp
|
MAVOR_TEMP_DIR=/home/damage/Temp
|
||||||
MAVOR_OPENID_CLIENT_ID=foo
|
MAVOR_OPENID_CLIENT_ID=foo
|
||||||
|
@ -3,18 +3,18 @@ package de.devloop.mavor;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import jakarta.servlet.ServletException;
|
import jakarta.servlet.ServletException;
|
||||||
|
import jakarta.servlet.http.HttpServlet;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
public class AuthenticatedServlet extends BaseServlet {
|
public class AuthenticatedServlet extends HttpServlet {
|
||||||
protected Session session;
|
protected Session session;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected final void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
protected final void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||||
super.doGet(req, resp);
|
|
||||||
session = new Session(req.getSession(true));
|
session = new Session(req.getSession(true));
|
||||||
if (!session.isAuthenticated()) {
|
if (!session.isAuthenticated()) {
|
||||||
resp.sendRedirect(configuration.getWebRoot() + "/authenticate");
|
resp.sendRedirect("/mavor/authenticate");
|
||||||
} else {
|
} else {
|
||||||
doAuthenticatedGet(req, resp);
|
doAuthenticatedGet(req, resp);
|
||||||
}
|
}
|
||||||
@ -22,10 +22,9 @@ public class AuthenticatedServlet extends BaseServlet {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected final void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
protected final void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||||
super.doPost(req, resp);
|
|
||||||
session = new Session(req.getSession(true));
|
session = new Session(req.getSession(true));
|
||||||
if (!session.isAuthenticated()) {
|
if (!session.isAuthenticated()) {
|
||||||
resp.sendRedirect(configuration.getWebRoot() + "/authenticate");
|
resp.sendRedirect("/mavor/authenticate");
|
||||||
} else {
|
} else {
|
||||||
doAuthenticatedPost(req, resp);
|
doAuthenticatedPost(req, resp);
|
||||||
}
|
}
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
package de.devloop.mavor;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import jakarta.servlet.ServletException;
|
|
||||||
import jakarta.servlet.http.HttpServlet;
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
public class BaseServlet extends HttpServlet {
|
|
||||||
protected Configuration configuration;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init() throws ServletException {
|
|
||||||
try {
|
|
||||||
configuration = new Configuration();
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new ServletException("Configuration Error", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
|
||||||
req.setAttribute("WEB_ROOT", configuration.getWebRoot());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
|
||||||
req.setAttribute("WEB_ROOT", configuration.getWebRoot());
|
|
||||||
}
|
|
||||||
}
|
|
@ -9,8 +9,6 @@ public class Configuration {
|
|||||||
|
|
||||||
private static final String DEVELOPMENT_PROPERTIES = "development.properties";
|
private static final String DEVELOPMENT_PROPERTIES = "development.properties";
|
||||||
|
|
||||||
private static final String ENV_WEB_ROOT = "MAVOR_WEB_ROOT";
|
|
||||||
|
|
||||||
private static final String ENV_MAVEN_EXECUTABLE = "MAVOR_MAVEN_EXECUTABLE";
|
private static final String ENV_MAVEN_EXECUTABLE = "MAVOR_MAVEN_EXECUTABLE";
|
||||||
private static final String ENV_TEMP_DIR = "MAVOR_TEMP_DIR";
|
private static final String ENV_TEMP_DIR = "MAVOR_TEMP_DIR";
|
||||||
|
|
||||||
@ -22,7 +20,6 @@ public class Configuration {
|
|||||||
private static final String ENV_OPENID_USERINFO_URL = "MAVOR_OPENID_USERINFO_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 static final String ENV_OPENID_LOGOUT_URL = "MAVOR_OPENID_LOGOUT_URL";
|
||||||
|
|
||||||
private String webRoot;
|
|
||||||
private String mavenExecutable;
|
private String mavenExecutable;
|
||||||
private String tempDir;
|
private String tempDir;
|
||||||
private String openIdClientId;
|
private String openIdClientId;
|
||||||
@ -46,7 +43,6 @@ public class Configuration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initByProperties(Properties properties) {
|
private void initByProperties(Properties properties) {
|
||||||
webRoot = getNullSafeProperty(properties, ENV_WEB_ROOT);
|
|
||||||
mavenExecutable = getNullSafeProperty(properties, ENV_MAVEN_EXECUTABLE);
|
mavenExecutable = getNullSafeProperty(properties, ENV_MAVEN_EXECUTABLE);
|
||||||
tempDir = getNullSafeProperty(properties, ENV_TEMP_DIR);
|
tempDir = getNullSafeProperty(properties, ENV_TEMP_DIR);
|
||||||
openIdClientId = getNullSafeProperty(properties, ENV_OPENID_CLIENT_ID);
|
openIdClientId = getNullSafeProperty(properties, ENV_OPENID_CLIENT_ID);
|
||||||
@ -62,10 +58,6 @@ public class Configuration {
|
|||||||
return Objects.requireNonNull(properties.getProperty(key));
|
return Objects.requireNonNull(properties.getProperty(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getWebRoot() {
|
|
||||||
return webRoot;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMavenExecutable() {
|
public String getMavenExecutable() {
|
||||||
return mavenExecutable;
|
return mavenExecutable;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ package de.devloop.mavor.servlet;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import de.devloop.mavor.BaseServlet;
|
import de.devloop.mavor.Configuration;
|
||||||
import de.devloop.mavor.Session;
|
import de.devloop.mavor.Session;
|
||||||
import de.devloop.openid.AuthenticationUrl;
|
import de.devloop.openid.AuthenticationUrl;
|
||||||
import de.devloop.openid.OpenID;
|
import de.devloop.openid.OpenID;
|
||||||
@ -12,11 +12,12 @@ import de.devloop.openid.Token;
|
|||||||
import de.devloop.openid.UserInfo;
|
import de.devloop.openid.UserInfo;
|
||||||
import jakarta.servlet.ServletException;
|
import jakarta.servlet.ServletException;
|
||||||
import jakarta.servlet.annotation.WebServlet;
|
import jakarta.servlet.annotation.WebServlet;
|
||||||
|
import jakarta.servlet.http.HttpServlet;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
@WebServlet("/authenticate")
|
@WebServlet("/authenticate")
|
||||||
public class Authentication extends BaseServlet {
|
public class Authentication extends HttpServlet {
|
||||||
|
|
||||||
private static final String PARAMETER_STATE = "state";
|
private static final String PARAMETER_STATE = "state";
|
||||||
private static final String PARAMETER_CODE = "code";
|
private static final String PARAMETER_CODE = "code";
|
||||||
@ -26,7 +27,12 @@ public class Authentication extends BaseServlet {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() throws ServletException {
|
public void init() throws ServletException {
|
||||||
super.init();
|
Configuration configuration;
|
||||||
|
try {
|
||||||
|
configuration = new Configuration();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new ServletException("Configuration Error", e);
|
||||||
|
}
|
||||||
|
|
||||||
openIdConfiguration = new OpenIdConfiguration();
|
openIdConfiguration = new OpenIdConfiguration();
|
||||||
openIdConfiguration.setAuthUrl(configuration.getOpenIdAuthUrl());
|
openIdConfiguration.setAuthUrl(configuration.getOpenIdAuthUrl());
|
||||||
@ -57,7 +63,7 @@ public class Authentication extends BaseServlet {
|
|||||||
|
|
||||||
session.setOAuthToken(token.getAccessToken());
|
session.setOAuthToken(token.getAccessToken());
|
||||||
session.setUsername(userInfo.getEmail());
|
session.setUsername(userInfo.getEmail());
|
||||||
resp.sendRedirect(configuration.getWebRoot());
|
resp.sendRedirect("/mavor/");
|
||||||
} else {
|
} else {
|
||||||
throw new ServletException("OpenID state mismatch!");
|
throw new ServletException("OpenID state mismatch!");
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ import java.util.zip.ZipOutputStream;
|
|||||||
|
|
||||||
import de.devloop.mavor.Artifact;
|
import de.devloop.mavor.Artifact;
|
||||||
import de.devloop.mavor.AuthenticatedServlet;
|
import de.devloop.mavor.AuthenticatedServlet;
|
||||||
|
import de.devloop.mavor.Configuration;
|
||||||
import jakarta.servlet.RequestDispatcher;
|
import jakarta.servlet.RequestDispatcher;
|
||||||
import jakarta.servlet.ServletException;
|
import jakarta.servlet.ServletException;
|
||||||
import jakarta.servlet.annotation.WebServlet;
|
import jakarta.servlet.annotation.WebServlet;
|
||||||
@ -34,6 +35,17 @@ public class DownloadJars extends AuthenticatedServlet {
|
|||||||
private static final String PARAMETER_POM = "pom";
|
private static final String PARAMETER_POM = "pom";
|
||||||
private static final String PARAMETER_TYPE = "type";
|
private static final String PARAMETER_TYPE = "type";
|
||||||
|
|
||||||
|
private Configuration configuration;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() throws ServletException {
|
||||||
|
try {
|
||||||
|
configuration = new Configuration();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new ServletException("Configuration Error", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doAuthenticatedPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
protected void doAuthenticatedPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||||
doAuthenticatedGet(req, resp);
|
doAuthenticatedGet(req, resp);
|
||||||
|
@ -5,6 +5,7 @@ import java.io.FileInputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import de.devloop.mavor.AuthenticatedServlet;
|
import de.devloop.mavor.AuthenticatedServlet;
|
||||||
|
import de.devloop.mavor.Configuration;
|
||||||
import jakarta.servlet.ServletException;
|
import jakarta.servlet.ServletException;
|
||||||
import jakarta.servlet.annotation.WebServlet;
|
import jakarta.servlet.annotation.WebServlet;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
@ -15,6 +16,17 @@ public class DownloadZip extends AuthenticatedServlet {
|
|||||||
|
|
||||||
private static final String PARAMETER_FILENAME = "file";
|
private static final String PARAMETER_FILENAME = "file";
|
||||||
|
|
||||||
|
private Configuration configuration;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() throws ServletException {
|
||||||
|
try {
|
||||||
|
configuration = new Configuration();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new ServletException("Configuration Error", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doAuthenticatedGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
protected void doAuthenticatedGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||||
File tempDir = new File(configuration.getTempDir());
|
File tempDir = new File(configuration.getTempDir());
|
||||||
@ -34,7 +46,7 @@ public class DownloadZip extends AuthenticatedServlet {
|
|||||||
throw new ServletException("-.-");
|
throw new ServletException("-.-");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
resp.sendRedirect(configuration.getWebRoot());
|
Main.redirectToMe(resp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package de.devloop.mavor.servlet;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import de.devloop.mavor.AuthenticatedServlet;
|
import de.devloop.mavor.AuthenticatedServlet;
|
||||||
|
import de.devloop.mavor.Configuration;
|
||||||
import jakarta.servlet.ServletException;
|
import jakarta.servlet.ServletException;
|
||||||
import jakarta.servlet.annotation.WebServlet;
|
import jakarta.servlet.annotation.WebServlet;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
@ -11,6 +12,16 @@ import jakarta.servlet.http.HttpSession;
|
|||||||
|
|
||||||
@WebServlet("/logout")
|
@WebServlet("/logout")
|
||||||
public class Logout extends AuthenticatedServlet {
|
public class Logout extends AuthenticatedServlet {
|
||||||
|
private Configuration configuration;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() throws ServletException {
|
||||||
|
try {
|
||||||
|
configuration = new Configuration();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new ServletException("Configuration Error", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doAuthenticatedGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
protected void doAuthenticatedGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||||
|
@ -19,4 +19,8 @@ public class Main extends AuthenticatedServlet {
|
|||||||
|
|
||||||
view.forward(req, resp);
|
view.forward(req, resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void redirectToMe(HttpServletResponse resp) throws IOException {
|
||||||
|
resp.sendRedirect("/mavor");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
<%@ page isELIgnored="false" %>
|
<%@ page isELIgnored="false" %>
|
||||||
<html>
|
<html>
|
||||||
<body style="background-color:black; color:white">
|
<body style="background-color:black; color:white">
|
||||||
Download dependencies (Link only works once!): <a href="${WEB_ROOT}/download/zip?file=${zipFilename}">${zipFilename}</a><br/>
|
Download dependencies (Link only works once!): <a href="/mavor/download/zip?file=${zipFilename}">${zipFilename}</a><br/>
|
||||||
<a href="${WEB_ROOT}/logout">logout</a> | <a href="${WEB_ROOT}">back</a><br/>
|
<a href="/mavor/logout">logout</a> | <a href="/mavor">back</a><br/>
|
||||||
Maven Output:<br/>
|
Maven Output:<br/>
|
||||||
<pre>${stdout}</pre>
|
<pre>${stdout}</pre>
|
||||||
</body>
|
</body>
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<body style="background-color:black; color:white">
|
<body style="background-color:black; color:white">
|
||||||
<h2>Hello ${username}</h2>
|
<h2>Hello ${username}</h2>
|
||||||
<form method="get" action="${WEB_ROOT}/download/jars">
|
<form method="get" action="/mavor/download/jars">
|
||||||
<input type="hidden" name="type" value="artifact"/>
|
<input type="hidden" name="type" value="artifact"/>
|
||||||
Repository: <input type="text" name="repository" value="https://source.devloop.de/api/packages/damage/maven/" /><br/>
|
Repository: <input type="text" name="repository" value="https://source.devloop.de/api/packages/damage/maven/" /><br/>
|
||||||
Group ID: <input type="text" name="groupId" value="org.apache.activemq"/><br/>
|
Group ID: <input type="text" name="groupId" value="org.apache.activemq"/><br/>
|
||||||
@ -11,11 +11,11 @@
|
|||||||
Version: <input type="text" name="version" value="2.39.0"/><br/>
|
Version: <input type="text" name="version" value="2.39.0"/><br/>
|
||||||
<input type="submit"/>
|
<input type="submit"/>
|
||||||
</form>
|
</form>
|
||||||
<form method="post" action="${WEB_ROOT}/download/jars">
|
<form method="post" action="/mavor/download/jars">
|
||||||
<input type="hidden" name="type" value="pom"/>
|
<input type="hidden" name="type" value="pom"/>
|
||||||
POM: <textarea name="pom" cols="80" rows="20"></textarea><br/>
|
POM: <textarea name="pom" cols="80" rows="20"></textarea><br/>
|
||||||
<input type="submit"/>
|
<input type="submit"/>
|
||||||
</form>
|
</form>
|
||||||
<a href="${WEB_ROOT}/logout">logout</a>
|
<a href="/mavor/logout">logout</a>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user