Skip to content

Commit

Permalink
Removed create-default-file-if-not-exists setting
Browse files Browse the repository at this point in the history
  • Loading branch information
ClaudioWaldvogel committed Nov 24, 2022
1 parent 2a21308 commit 5093f9f
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 21 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ inspectit-eum-server:
frequency: 60s
token-directory: "" # Empty by default to force users to provide one
default-file-name: "default-token-file.yaml"
create-default-file-if-not-exists: true
```
##### Metrics Definition
A metric is defined through the following attributes:
Expand Down Expand Up @@ -177,14 +176,14 @@ inspectit-eum-server:
watch: true
# How often directory should be watched for changes
frequency: 60s
# The directory where token files are stored
token-directory: "" # Empty by default to force users to provide one
# The directory where token files are stored. Empty by default to force users to provide one
token-directory: ""
# The name of the initial token file
default-file-name: "default-token-file.yaml"
```
or via environment variables:
```bash
INSPECTIT_EUM_SERVER_SECURITY_AUTH_PROVIDER_SIMPLE_CONFIG_DIRECTORY=<my-directory>
INSPECTIT_EUM_SERVER_SECURITY_AUTH_PROVIDER_SIMPLE_TOKEN_DIRECTORY=<my-directory>
INSPECTIT_EUM_SERVER_SECURITY_AUTH_PROVIDER_SIMPLE_ENABLED=TRUE;
INSPECTIT_EUM_SERVER_SECURITY_ENABLED=TRUE
```
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ public class SimpleApiTokenAuthenticationProviderSettings {
*/
private String defaultFileName;


@AssertTrue(message = "configDirectory can not be null or empty if SimpleApiTokenAuthentication is enabled")
public boolean isConfigDirectoryNotNullIfEnabled() {
@AssertTrue(message = "tokenDirectory can not be null or empty if SimpleApiTokenAuthentication is enabled")
public boolean isTokenDirectoryNotNullIfEnabled() {
return !isEnabled() || (isEnabled() && StringUtils.hasText(tokenDirectory));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,9 @@
* watch: true
* # How often directory should be watched for changes
* frequency: 60s
* # The directory where token files are stored
* token-directory: "" # Empty by default to force users to provide one
* # The directory where token files are stored. Empty by default to force users to provide one
* token-directory: ""
* # Flag indicates if a default token file should be created with an initial token
* create-default-file-if-not-exists: true
* # The name of the initial token file
* default-file-name: "default-token-file.yaml"
* </pre>
*/
Expand Down Expand Up @@ -133,11 +131,9 @@ private void startWatchingTokenDirectory() {
}

private void createDefaultTokenProviderFile() {
if (StringUtils.hasText(configuration.getSecurity().getAuthProvider().getSimple().getDefaultFileName())) {
File file = new File(tokenDirectory.getAbsolutePath() + File.separator + configuration.getSecurity()
.getAuthProvider()
.getSimple()
.getDefaultFileName());
String defaultFileName = configuration.getSecurity().getAuthProvider().getSimple().getDefaultFileName();
if (StringUtils.hasText(defaultFileName)) {
File file = new File(tokenDirectory.getAbsolutePath() + File.separator + defaultFileName);
if (!file.exists()) {
log.debug("Create initial token file: {}", file.getAbsolutePath());
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ public class DirectoryPoller {
private ScheduledFuture<?> pollingTask;

/**
* Flag to indicate that we need to shutdown the used executor on destroy.
* Flag to indicate that the {@link #defaultExecutor()} is used, which is initialized by {@link DirectoryPoller} itself
* and needs to be shutdown on destroy.
*/
private boolean isDefaultExecutor = false;

Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,9 @@ inspectit-eum-server:
watch: true
# How often directory should be watched for changes
frequency: 60s
# The directory where token files are stored
token-directory: "" # Empty by default to force users to provide one
# The name of the initial token file
# The directory where token files are stored. Empty by default to force users to provide one
token-directory: ""
# The name of the initial token file. If a name is provided file will be created with an initial token
default-file-name: "default-token-file.yaml"


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static class Initializer implements ApplicationContextInitializer<ConfigurableAp
@Override
public void initialize(ConfigurableApplicationContext applicationContext) {
String tokenDir = getClass().getClassLoader().getResource("security/simple-auth-provider").getFile();
TestPropertyValues.of("inspectit-eum-server.security.enabled=true", "inspectit-eum-server.security.auth-provider.simple.enabled=true", "inspectit-eum-server.security.auth-provider.simple.token-directory=" + tokenDir, "inspectit-eum-server.security.auth-provider.simple.default-file-name=\"\"")
TestPropertyValues.of("inspectit-eum-server.security.enabled=true", "inspectit-eum-server.security.auth-provider.simple.enabled=true", "inspectit-eum-server.security.auth-provider.simple.token-directory=" + tokenDir, "inspectit-eum-server.security.auth-provider.simple.default-file-name=")
.applyTo(applicationContext);
}
}
Expand Down

0 comments on commit 5093f9f

Please sign in to comment.