setting web root via configuration
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
8a85bca1ef
commit
85d16ebfc7
@ -9,6 +9,7 @@ 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
|
||||||
@ -20,6 +21,7 @@ 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
|
||||||
|
@ -11,9 +11,10 @@ public class AuthenticatedServlet extends BaseServlet {
|
|||||||
|
|
||||||
@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("/mavor/authenticate");
|
resp.sendRedirect(configuration.getWebRoot() + "/authenticate");
|
||||||
} else {
|
} else {
|
||||||
doAuthenticatedGet(req, resp);
|
doAuthenticatedGet(req, resp);
|
||||||
}
|
}
|
||||||
@ -21,9 +22,10 @@ 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("/mavor/authenticate");
|
resp.sendRedirect(configuration.getWebRoot() + "/authenticate");
|
||||||
} else {
|
} else {
|
||||||
doAuthenticatedPost(req, resp);
|
doAuthenticatedPost(req, resp);
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@ import java.io.IOException;
|
|||||||
|
|
||||||
import jakarta.servlet.ServletException;
|
import jakarta.servlet.ServletException;
|
||||||
import jakarta.servlet.http.HttpServlet;
|
import jakarta.servlet.http.HttpServlet;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
public class BaseServlet extends HttpServlet {
|
public class BaseServlet extends HttpServlet {
|
||||||
protected Configuration configuration;
|
protected Configuration configuration;
|
||||||
@ -16,4 +18,14 @@ public class BaseServlet extends HttpServlet {
|
|||||||
throw new ServletException("Configuration Error", 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());
|
||||||
|
}
|
||||||
}
|
}
|
@ -57,7 +57,7 @@ public class Authentication extends BaseServlet {
|
|||||||
|
|
||||||
session.setOAuthToken(token.getAccessToken());
|
session.setOAuthToken(token.getAccessToken());
|
||||||
session.setUsername(userInfo.getEmail());
|
session.setUsername(userInfo.getEmail());
|
||||||
resp.sendRedirect("/mavor/");
|
resp.sendRedirect(configuration.getWebRoot());
|
||||||
} else {
|
} else {
|
||||||
throw new ServletException("OpenID state mismatch!");
|
throw new ServletException("OpenID state mismatch!");
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ public class DownloadZip extends AuthenticatedServlet {
|
|||||||
throw new ServletException("-.-");
|
throw new ServletException("-.-");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Main.redirectToMe(resp);
|
resp.sendRedirect(configuration.getWebRoot());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,4 @@ 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="/mavor/download/zip?file=${zipFilename}">${zipFilename}</a><br/>
|
Download dependencies (Link only works once!): <a href="${WEB_ROOT}/download/zip?file=${zipFilename}">${zipFilename}</a><br/>
|
||||||
<a href="/mavor/logout">logout</a> | <a href="/mavor">back</a><br/>
|
<a href="${WEB_ROOT}/logout">logout</a> | <a href="${WEB_ROOT}">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="/mavor/download/jars">
|
<form method="get" action="${WEB_ROOT}/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="/mavor/download/jars">
|
<form method="post" action="${WEB_ROOT}/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="/mavor/logout">logout</a>
|
<a href="${WEB_ROOT}/logout">logout</a>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user