diff --git a/pkg/store/artifactory_store.go b/pkg/store/artifactory_store.go index d4fa83cd2..4874f75b4 100644 --- a/pkg/store/artifactory_store.go +++ b/pkg/store/artifactory_store.go @@ -79,7 +79,11 @@ func NewArtifactoryStore(options ArtifactoryStoreOptions) (Store, error) { if err != nil { return nil, err } - rtDetails.SetAccessToken(token) + + // If the token is set to "anonymous", we don't need to set the access token. + if token != "anonymous" { + rtDetails.SetAccessToken(token) + } serviceConfig, err := config.NewConfigBuilder(). SetServiceDetails(rtDetails). @@ -89,7 +93,6 @@ func NewArtifactoryStore(options ArtifactoryStoreOptions) (Store, error) { SetOverallRequestTimeout(1 * time.Minute). SetHttpRetries(0). Build() - if err != nil { return nil, err } @@ -112,15 +115,9 @@ func (s *ArtifactoryStore) getKey(stack string, component string, key string) (s return "", fmt.Errorf("stack delimiter is not set") } - stackParts := strings.Split(stack, *s.stackDelimiter) - componentParts := strings.Split(component, "/") - - parts := []string{s.repoName, s.prefix} - parts = append(parts, stackParts...) - parts = append(parts, componentParts...) - parts = append(parts, key) - - return strings.ReplaceAll(strings.Join(parts, "/"), "//", "/"), nil + prefixParts := []string{s.repoName, s.prefix} + prefix := strings.Join(prefixParts, "/") + return getKey(prefix, *s.stackDelimiter, stack, component, key, "/") } func (s *ArtifactoryStore) Get(stack string, component string, key string) (interface{}, error) { diff --git a/website/docs/core-concepts/projects/configuration/stores.mdx b/website/docs/core-concepts/projects/configuration/stores.mdx index 41b2acf70..94ce60b0a 100644 --- a/website/docs/core-concepts/projects/configuration/stores.mdx +++ b/website/docs/core-concepts/projects/configuration/stores.mdx @@ -83,9 +83,10 @@ stores: The Artifactory store supports using an access token for authentication. The access token can be set directly in the `atmos.yaml` or via the `JFROG_ACCESS_TOKEN` or `ARTIFACTORY_ACCESS_TOKEN` environment variables. -NOTE: It is not recommended to set the access token in plain text in `atmos.yaml` as it is not secure. Specifying the -access token via config is allowed so that you can support the use case where you have multiple Artifactory stores -in `atmos.yaml` and you need to specify different access tokens for each. In this case, you can use the `!env` +It is also possible to specify the access token as `anonymous` to use the anonymous user to access the Artifactory +repository if the repository is configured to allow anonymous access. + +**NOTE:** Storing sensitive access tokens in plain text in `atmos.yaml` is not secure and should be avoided. However, it's recommended for the `anonymous` use case or when managing multiple Artifactory stores with different access tokens. In such cases, use [`!env`](/core-concepts/stacks/yaml-functions/env) function to reference tokens securely. YAML function to set the access token from an environment variable. ### AWS SSM Parameter Store