Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Replace file based with use of Secret Provider to get Access Tokens #784

Merged

Conversation

lenny-goodell
Copy link
Member

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Currently expecting the Registry/Config Access tokens to be retrieved for files using the file location config settings.

Issue Number: #769

What is the new behavior?

Now uses SecretProvider to retrieve the access tokens.
File location config settings have been removed

Does this PR introduce a breaking change?

  • Yes
  • No

BREAKING CHANGE: All App Services running with the secure Edgex Stack now need to have the SecretStore configured, a Vault token created and run with EDGEX_SECURITY_SECRET_STORE=true.

Are there any new imports or modules? If so, what are they used for and why?

no

Are there any specific instructions or things that should be known prior to reviewing?

Other information

…s Tokens

closes #769

BREAKING CHANGE: All App Services running with the secure Edgex Stack now need to have the SecretStore configured, a Vault token created and run with EDGEX_SECURITY_SECRET_STORE=true.

Signed-off-by: lenny <[email protected]>
jim-wang-intel
jim-wang-intel previously approved these changes Apr 7, 2021
Copy link
Contributor

@jim-wang-intel jim-wang-intel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -430,7 +429,7 @@ func (svc *Service) Initialize() error {
secretProvider := bootstrapContainer.SecretProviderFrom(svc.dic.Get)
credentials, err := secretProvider.GetSecrets(svc.config.Database.Type)
if err != nil {
return fmt.Errorf("unable to set RedisStreams password from DB credentials")
return fmt.Errorf("unable to set RedisStreams password from DB credentials: %s", err.Error())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we are supposed to use %w now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, not sure what %w is. It is a string returned from err.Error() so %s is most appropriate. Some folks us %v which will work also, but I like to be more explicate.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also %v leaves it up to reflection to figure our the best way to convert the value to a string. So when it is a string why not skip the reflection and use %s...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return fmt.Errorf("unable to set RedisStreams password from DB credentials: %s", err.Error())
return fmt.Errorf("unable to set RedisStreams password from DB credentials: %w", err)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, just looked up %w. It is specifically for when wrapping errors . Good to know. :-) THX!

Wrapping an error with %w makes it available to errors.Is and errors.As:

err := fmt.Errorf("access denied: %w", ErrPermission)
...
if errors.Is(err, ErrPermission) ...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. If that's the case, we shouldn't propagate that error at all.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, it isn't leaking the credential that it couldn't get from the SecretStore. ;-)
The error give details on why if could find the credentials.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if that is the case, then it is ok; i was just worries the error was wrapped from vault or redis's server's error which might have some sensitive infor there. ok if not

Copy link
Member Author

@lenny-goodell lenny-goodell Apr 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bnevis-i , you good with this explanation of why it isn't a creds leak?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

@lenny-goodell lenny-goodell merged commit c52b117 into edgexfoundry:master Apr 7, 2021
@lenny-goodell lenny-goodell deleted the access-token-reworked branch April 7, 2021 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants