-
Notifications
You must be signed in to change notification settings - Fork 56
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
feat: Add optional capability to seed service secrets #276
Conversation
Secrets are seeded from a JSON file specifed by the SecretStore.SecretsFile setting If SecretsFile setting is blank, seeding is skipped. closes #273 Signed-off-by: Leonard Goodell <[email protected]>
LGTM. Thanks for the testing instructions. I tested this with my ONVIF camera, the edgexfoundry snap and a natively running device-camera, setting the following in the camera
with
and then running with
that works fine:
|
@siggiskulason Excellent!! Thanks! |
Signed-off-by: Leonard Goodell <[email protected]>
c1ffab0
to
7df6da5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Signed-off-by: Leonard Goodell <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of inline comments...
Signed-off-by: Leonard Goodell <[email protected]>
b81f151
to
366f197
Compare
Signed-off-by: Leonard Goodell <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please tell us about the new dependency.
@bnevis-i , it is new to this module, but not EdgeX. It is on the approved list here: |
Signed-off-by: Leonard Goodell <[email protected]>
…ets file Signed-off-by: Leonard Goodell <[email protected]>
Signed-off-by: Leonard Goodell <[email protected]>
bootstrap/secret/secret.go
Outdated
|
||
lc.Debugf("SecretsFile is '%s'", secretConfig.SecretsFile) | ||
|
||
if len(strings.TrimSpace(secretConfig.SecretsFile)) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code would be less complex if this was changed to if len == 0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How? still an if/else just reversing the logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
secureProvider.SetClient(secretClient)
lc.Debugf("SecretsFile is '%s'", secretConfig.SecretsFile)
if len(strings.TrimSpace(secretConfig.SecretsFile)) > 0 {
err = secureProvider.LoadServiceSecrets(secretStoreConfig)
if err != nil {
return nil, err
}
} else {
lc.Infof("SecretsFile not set, skipping seeding of service secrets.")
}
provider = secureProvider
secureProvider.SetClient(secretClient)
lc.Debugf("SecretsFile is '%s'", secretConfig.SecretsFile)
if len(strings.TrimSpace(secretConfig.SecretsFile)) == 0 {
lc.Infof("SecretsFile not set, skipping seeding of service secrets.")
break
}
err = secureProvider.LoadServiceSecrets(secretStoreConfig)
if err != nil {
return nil, err
}
provider = secureProvider
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep! :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am always an advocate of early return to avoid indentation, just didn't see it here. THX!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opps, not so fast. This skips the following important code when you do the break
that you added, so still need the if/else of have repeated code.
provider = secureProvider
lc.Info("Created SecretClient")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, was able to move that code up before handling of the secrets file and now the break you added will work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Signed-off-by: Leonard Goodell <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just want to clarify what's expected if the scrub fails, should the secrets provisioned into vault also be scrubbed? You also could structure the code such that the write to vault doesn't happen until after the JSON file gets scrubbed... If @bnevis-i you're OK with the way this is implemented, then I'll just approve, but as implemented this isn't being handled as a single transaction.
Yes, if the scrub fails the secrets will still be in the secret store. It is impossible to truly have a single transaction here as neither Vault nor the file system support a two-phase commit protocol. I'd rather have this behavior than the possibility that the JSON is scrubbed and then Vault fails, because there is no recovery from that. |
@tonyespy, The secrets do not need to be scrubbed from vault if file write fails. No harm in them still being there. Once write issue is resolved they will be over written. Trying to scrub them out of vault will add unneeded complexity. |
* feat: Add optional capability to seed service secrets Secrets are seeded from a JSON file specified by the SecretStore.SecretsFile setting If SecretsFile setting is blank, seeding is skipped. * feat: Add DisableScrubSecretsFile setting to control scrubbing of secrets file closes edgexfoundry#273 Signed-off-by: Leonard Goodell <[email protected]>
Secrets are seeded from a JSON file specified by the SecretStore.SecretsFile setting
If SecretsFile setting is blank, seeding is skipped.
closes #273
This PR depends on edgexfoundry/go-mod-secrets#126 to be merged first.
PR Checklist
Please check if your PR fulfills the following requirements:
BREAKING CHANGE:
describing the break)feat: Document new Seeding Service Secrets capability edgex-docs#587
Testing Instructions
make run ds-camera
SecretStore
for device camerago.mod
go.mod
cmd
folder in device-camera-go/tmp/camera-secrets.json
with the following JSON:sudo EDGEX_SECURITY_SECRET_STORE=true SECRETSTORE_SECRETSFILE=/tmp/camera-secrets.json ./device-camera
And will
NOT
display any error getting secrets, but will fail to initialize the camera since no camera exists.9. The
/tmp/camera-secrets.json
file contents are now:/tmp/camera-secrets.json
file contents as above with secret data.sudo EDGEX_SECURITY_SECRET_STORE=true SECRETSTORE_SECRETSFILE=/tmp/camera-secrets.json SECRETSTORE_DISABLESCRUBSECRETSFILE=true ./device-camera
/tmp/camera-secrets.json
file contents will not be changed. I.e. secret data will still be present in the fileNew Dependency Instructions (If applicable)
N/A