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

Commit 7a1d551

Browse files
authored
SUBMARINE-1417. Retrieve SUBMARINE_AUTH_SECRET from environment variable instead of using hard-coded value (#1125)
1 parent 4e68894 commit 7a1d551

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

.github/workflows/master.yml

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ env:
2222
VERSION: "0.9.0-SNAPSHOT"
2323
BUILD_FLAG: "clean install -ntp -DskipTests -am"
2424
TEST_FLAG: "test -DskipRat -ntp"
25+
SUBMARINE_AUTH_SECRET: "SUBMARINE_SECRET_12345678901234567890"
2526
jobs:
2627
generate-k8s-versions-array:
2728
runs-on: ubuntu-latest

submarine-commons/commons-utils/src/main/java/org/apache/submarine/commons/utils/SubmarineConfVars.java

+14-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,19 @@
2323

2424
public class SubmarineConfVars {
2525
private static final Logger LOG = LoggerFactory.getLogger(SubmarineConfVars.class);
26+
/**
27+
* Retrieves the secret from the environment variable "SUBMARINE_AUTH_DEFAULT_SECRET".
28+
* Throws runtimeException if the environment variable is not set or empty.
29+
*
30+
* @return The secret as a String
31+
*/
32+
private static String getSecretFromEnv() {
33+
String secret = System.getenv("SUBMARINE_AUTH_SECRET");
34+
if (secret == null || secret.isEmpty()) {
35+
secret = "";
36+
}
37+
return secret;
38+
}
2639
public enum ConfVars {
2740
SUBMARINE_CONF_DIR("submarine.conf.dir", "conf"),
2841
SUBMARINE_LOCALIZATION_MAX_ALLOWED_FILE_SIZE_MB(
@@ -93,7 +106,7 @@ public enum ConfVars {
93106

94107
/* auth */
95108
SUBMARINE_AUTH_TYPE("submarine.auth.type", "simple"),
96-
SUBMARINE_AUTH_DEFAULT_SECRET("submarine.auth.default.secret", "SUBMARINE_SECRET_12345678901234567890"),
109+
SUBMARINE_AUTH_DEFAULT_SECRET("submarine.auth.default.secret", getSecretFromEnv()),
97110
SUBMARINE_AUTH_MAX_AGE_ENV("submarine.auth.maxAge", 60 * 60 * 24);
98111

99112
private String varName;

0 commit comments

Comments
 (0)