in streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/setup/StreamPipesEnvChecker.java [80:132]
private boolean updateJwtSettings() {
LocalAuthConfig localAuthConfig = coreConfig.getLocalAuthConfig();
boolean incompleteConfig = false;
var signingMode = env.getJwtSigningMode();
var jwtSecret = env.getJwtSecret();
var publicKeyLoc = env.getJwtPublicKeyLoc();
var privateKeyLoc = env.getJwtPrivateKeyLoc();
if (signingMode.exists()) {
localAuthConfig.setJwtSigningMode(JwtSigningMode.valueOf(signingMode.getValue()));
} else {
if (localAuthConfig.getJwtSigningMode() != JwtSigningMode.HMAC) {
localAuthConfig.setJwtSigningMode(JwtSigningMode.HMAC);
}
}
if (jwtSecret.exists()) {
localAuthConfig.setTokenSecret(jwtSecret.getValue());
}
if (publicKeyLoc.exists()) {
try {
localAuthConfig.setPublicKey(readPublicKey(publicKeyLoc.getValue()));
} catch (IOException e) {
incompleteConfig = true;
LOG.warn("Could not read public key at location " + publicKeyLoc.getValue());
}
}
if (!signingMode.exists()) {
LOG.info(
"No JWT signing mode provided (using default settings), "
+ "consult the docs to learn how to provide JWT settings");
} else if (localAuthConfig.getJwtSigningMode() == JwtSigningMode.HMAC && !jwtSecret.exists()) {
LOG.warn(
"JWT signing mode set to HMAC but no secret provided (falling back to auto-generated secret), "
+ "provide a {} variable",
jwtSecret.getEnvVariableName());
} else if (localAuthConfig.getJwtSigningMode() == JwtSigningMode.RSA
&& ((!publicKeyLoc.exists() || !privateKeyLoc.exists()) || incompleteConfig)) {
LOG.warn(
"JWT signing mode set to RSA but no public or private key location provided, "
+ "do you provide {} and {} variables?",
privateKeyLoc.getEnvVariableName(),
publicKeyLoc.getEnvVariableName());
}
if (!incompleteConfig) {
LOG.info("Updating local auth config with signing mode {}", localAuthConfig.getJwtSigningMode().name());
coreConfig.setLocalAuthConfig(localAuthConfig);
return true;
} else {
return false;
}
}