Skip to content
Snippets Groups Projects
Verified Commit 98e14752 authored by Timm Fitschen's avatar Timm Fitschen
Browse files

WIP: pipeline

parent 338fe34d
Branches
Tags
No related merge requests found
......@@ -29,6 +29,7 @@ log/
OUTBOX
ConsistencyTest.xml
testlog/
authtoken/
# python
__pycache__
- purpose: scripting:administration/diagnostics.py
roles:
- administration
- roles:
- administration
output:
file: "authtoken/admin_token.json"
schedule: "0/10 * * ? * * *"
- roles:
- administration
output:
file: "authtoken/admin_token_3_attempts.json"
schedule: "0/10 * * ? * * *"
maxAttempts: 3
- roles:
- administration
output:
file: "authtoken/admin_token_expired.json"
expiresAfterSeconds: 0
- roles:
- administration
output:
file: "authtoken/admin_token_crud.json"
schedule: "0/10 * * ? * * *"
......@@ -120,6 +120,9 @@ SESSION_TIMEOUT_MS=600000
# 7days
ONE_TIME_TOKEN_EXPIRES_MS=604800000
# Path to config file for one time tokens.
AUTHTOKEN_CONFIG=
# Timeout after which a consumed one-time token expires regardless of the
# maximum of attempts that are allowed for that token. This is only a default
# value. The actual timeout of each token can be configured otherwise.
......
......@@ -131,6 +131,7 @@ public class ServerProperties extends Properties {
public static final String KEY_TIMEZONE = "TIMEZONE";
public static final String KEY_WEBUI_HTTP_HEADER_CACHE_MAX_AGE =
"WEBUI_HTTP_HEADER_CACHE_MAX_AGE";
public static final String KEY_AUTHTOKEN_CONFIG = "AUTHTOKEN_CONFIG";
/**
* Read the config files and initialize the server properties.
......
......@@ -28,7 +28,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
......@@ -39,6 +38,8 @@ import java.util.Map;
import org.apache.shiro.subject.Subject;
import org.eclipse.jetty.util.ajax.JSON;
import org.quartz.SchedulerException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class OneTimeAuthenticationToken extends SelfValidatingAuthenticationToken {
......@@ -50,6 +51,7 @@ public class OneTimeAuthenticationToken extends SelfValidatingAuthenticationToke
Integer.parseInt(
CaosDBServer.getServerProperty(ServerProperties.KEY_ONE_TIME_TOKEN_EXPIRES_MS));
public static final String REALM_NAME = "OneTimeAuthenticationToken"; // TODO move to UserSources
public static final Logger LOGGER = LoggerFactory.getLogger(OneTimeAuthenticationToken.class);
private long maxAttempts;
private long attemptsTimeout;
......@@ -198,11 +200,12 @@ public class OneTimeAuthenticationToken extends SelfValidatingAuthenticationToke
public static void initConfig() throws Exception {
resetConfig();
try (FileInputStream f = new FileInputStream("conf/ext/authtoken.yaml")) {
try (FileInputStream f =
new FileInputStream(
CaosDBServer.getServerProperty(ServerProperties.KEY_AUTHTOKEN_CONFIG))) {
initConfig(f);
} catch (FileNotFoundException e) {
// TODO log and use default config
e.printStackTrace();
} catch (IOException e) {
LOGGER.error("Could not load the auth token configuration", e);
}
}
......
package caosdb.server.accessControl;
import caosdb.server.CaosDBServer;
import com.google.common.io.Files;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import org.quartz.CronScheduleBuilder;
......@@ -21,8 +23,13 @@ public class OneTimeTokenToFile implements Job {
public OneTimeTokenToFile() {}
public static void output(OneTimeAuthenticationToken t, String file) throws IOException {
output(t, new File(file));
}
public static void output(OneTimeAuthenticationToken t, File file) throws IOException {
Files.createParentDirs(file);
try (PrintWriter writer = new PrintWriter(file, "utf-8")) {
writer.println(t.toString());
writer.print(t.toString());
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment