-
-
Notifications
You must be signed in to change notification settings - Fork 659
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(webserver): add a default jwt token + a warning
close #470
- Loading branch information
1 parent
4f6f23b
commit 985df0a
Showing
2 changed files
with
45 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.akhq.configs; | ||
|
||
import io.micronaut.context.annotation.Context; | ||
import io.micronaut.context.annotation.Value; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import javax.annotation.PostConstruct; | ||
import javax.inject.Singleton; | ||
|
||
@Singleton | ||
@Slf4j | ||
@Context | ||
public class JwtSecurityWarning { | ||
protected static String DEFAULT = "pleasechangeme!pleasechangeme!pleasechangeme!pleasechangeme!" + | ||
"pleasechangeme!pleasechangeme!pleasechangeme!pleasechangeme!pleasechangeme!pleasechangeme!" + | ||
"pleasechangeme!pleasechangeme!pleasechangeme!pleasechangeme!pleasechangeme!pleasechangeme!"; | ||
|
||
@Value("${micronaut.security.token.jwt.signatures.secret.generator.secret}") | ||
protected String secret; | ||
|
||
@Value("${micronaut.security.enabled:false}") | ||
protected Boolean enabled; | ||
|
||
@PostConstruct | ||
public void start() { | ||
if (enabled && secret.equals(DEFAULT)) { | ||
log.warn(""); | ||
log.warn("##############################################################"); | ||
log.warn("# SECURITY WARNING #"); | ||
log.warn("##############################################################"); | ||
log.warn(""); | ||
log.warn("You still use the default jwt secret."); | ||
log.warn("This known secret can be used to impersonate anyone."); | ||
log.warn("Please change 'micronaut.security.token.jwt.signatures.secret.generator.secret' configuration, or ask your administrator to do it !"); | ||
log.warn(""); | ||
log.warn("##############################################################"); | ||
log.warn(""); | ||
} | ||
} | ||
} |
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