Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

SUBMARINE-1417. Retrieve SUBMARINE_AUTH_SECRET from environment variable instead of using hard-coded value #1125

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ env:
VERSION: "0.9.0-SNAPSHOT"
BUILD_FLAG: "clean install -ntp -DskipTests -am"
TEST_FLAG: "test -DskipRat -ntp"
SUBMARINE_AUTH_SECRET: "SUBMARINE_SECRET_12345678901234567890"
jobs:
generate-k8s-versions-array:
runs-on: ubuntu-latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@

public class SubmarineConfVars {
private static final Logger LOG = LoggerFactory.getLogger(SubmarineConfVars.class);
/**
* Retrieves the secret from the environment variable "SUBMARINE_AUTH_DEFAULT_SECRET".
* Throws runtimeException if the environment variable is not set or empty.
*
* @return The secret as a String
*/
private static String getSecretFromEnv() {
String secret = System.getenv("SUBMARINE_AUTH_SECRET");
if (secret == null || secret.isEmpty()) {
secret = "";
}
return secret;
}
public enum ConfVars {
SUBMARINE_CONF_DIR("submarine.conf.dir", "conf"),
SUBMARINE_LOCALIZATION_MAX_ALLOWED_FILE_SIZE_MB(
Expand Down Expand Up @@ -93,7 +106,7 @@ public enum ConfVars {

/* auth */
SUBMARINE_AUTH_TYPE("submarine.auth.type", "simple"),
SUBMARINE_AUTH_DEFAULT_SECRET("submarine.auth.default.secret", "SUBMARINE_SECRET_12345678901234567890"),
SUBMARINE_AUTH_DEFAULT_SECRET("submarine.auth.default.secret", getSecretFromEnv()),
SUBMARINE_AUTH_MAX_AGE_ENV("submarine.auth.maxAge", 60 * 60 * 24);

private String varName;
Expand Down
Loading