-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
129 changed files
with
316,067 additions
and
1,362 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,12 +26,12 @@ jobs: | |
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up JDK 17 | ||
- name: Set up JDK 21 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
java-version: '21' | ||
distribution: 'microsoft' | ||
- name: Build with Gradle | ||
uses: gradle/[email protected] | ||
with: | ||
arguments: build | ||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@v3 | ||
- name: Execute Gradle build | ||
run: ./gradlew build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package whelk; | ||
|
||
import io.prometheus.client.exporter.MetricsServlet; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.eclipse.jetty.ee8.nested.ServletConstraint; | ||
import org.eclipse.jetty.ee8.security.ConstraintAware; | ||
import org.eclipse.jetty.ee8.security.ConstraintMapping; | ||
import org.eclipse.jetty.ee8.servlet.ServletContextHandler; | ||
import org.eclipse.jetty.security.HashLoginService; | ||
import org.eclipse.jetty.security.LoginService; | ||
import org.eclipse.jetty.server.Server; | ||
import org.eclipse.jetty.util.resource.PathResourceFactory; | ||
import org.eclipse.jetty.util.resource.Resource; | ||
import whelk.apixserver.ApixCatServlet; | ||
import whelk.apixserver.ApixSearchServlet; | ||
|
||
public class ApixServer extends XlServer { | ||
private static final Logger log = LogManager.getLogger(ApixServer.class); | ||
|
||
private static final String USER_PROPERTIES_PATH_PARAMETER = "xl.apix-users.properties"; | ||
|
||
@Override | ||
protected void configureHandlers(Server server) { | ||
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SECURITY); | ||
context.setContextPath("/"); | ||
|
||
if (context.getSecurityHandler() instanceof ConstraintAware security) | ||
{ | ||
ServletConstraint constraint = new ServletConstraint(); | ||
constraint.setAuthenticate(true); | ||
constraint.setRoles(new String[]{ "apix" }); | ||
|
||
ConstraintMapping mapping = new ConstraintMapping(); | ||
mapping.setPathSpec("/apix/*"); | ||
mapping.setConstraint(constraint); | ||
security.addConstraintMapping(mapping); | ||
|
||
// One row per user: | ||
// <username>: <password> [, <role>...} | ||
// for example: | ||
// foo: bar, apix | ||
String fileName = System.getProperty(USER_PROPERTIES_PATH_PARAMETER, ""); | ||
if ("".equals(fileName)) { | ||
throw new IllegalStateException(USER_PROPERTIES_PATH_PARAMETER + " not configured"); | ||
} | ||
|
||
Resource config = new PathResourceFactory().newResource(fileName); | ||
LoginService loginService = new HashLoginService("ApixRealm", config); | ||
server.addBean(loginService); | ||
context.getSecurityHandler().setAuthMethod("BASIC"); | ||
context.getSecurityHandler().setLoginService(loginService); | ||
log.info("Getting APIX users from {}", fileName); | ||
} | ||
else | ||
{ | ||
throw new RuntimeException("Not a ConstraintAware SecurityHandler"); | ||
} | ||
|
||
context.addServlet(MetricsServlet.class, "/metrics"); | ||
context.addServlet(ApixCatServlet.class, "/apix/0.1/cat/*"); | ||
context.addServlet(ApixSearchServlet.class, "/apix/0.1/cat/libris/search"); | ||
|
||
serveStaticContent(context); | ||
|
||
server.setHandler(context); | ||
} | ||
|
||
public static void main(String[] args) throws Exception { | ||
new ApixServer().run(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.