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

build(snap): Snap package build for setup consul acl #3223

Merged

Conversation

jim-wang-intel
Copy link
Contributor

@jim-wang-intel jim-wang-intel commented Mar 4, 2021

part of securing consul phase 1 in snap build, change details:

  • Add token for consul secret engine in snap
  • Add env. for ACL enable: ENABLE_REGISTRY_ACL: true
  • Add env. for consul secret engine admin token: SECRETSTORE_CONSULSECRETSADMINTOKENPATH
  • Add logic for copying the needed configuration toml from security-bootstrapper
  • Add consul-bootstrapper one-shot service for setting up Consul's ACL
  • Add feature flag logic in start_consul.sh shell script
  • Consul-bootstrapper one-shot service to launch using shell script

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)

If your build fails due to your commit message not passing the build checks, please review the guidelines here: https://github.com/edgexfoundry/edgex-go/blob/master/.github/Contributing.md.

What is the current behavior?

N/A

Issue Number: #3222

What is the new behavior?

Add implementation in snap for setting up consul's acl

Does this PR introduce a breaking change?

  • Yes
  • No

New Imports

  • Yes
  • [x ] No

Specific Instructions

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

snap package build and need the patch updates

Other information

@jim-wang-intel jim-wang-intel added enhancement New feature or request snap Snap packaging security-services 3-high priority denoting release-blocking issues blocked ireland labels Mar 4, 2021
@jim-wang-intel jim-wang-intel added this to the Ireland milestone Mar 4, 2021
@jim-wang-intel jim-wang-intel changed the title Snap setup consul acl snap(build): Snap package build for setup consul acl Mar 4, 2021
@jim-wang-intel jim-wang-intel changed the title snap(build): Snap package build for setup consul acl build(snap): Snap package build for setup consul acl Mar 4, 2021
@jim-wang-intel jim-wang-intel force-pushed the snap-setup-consul-acl branch 3 times, most recently from f6c5a0d to 0cea5ec Compare March 8, 2021 22:47
@jim-wang-intel jim-wang-intel marked this pull request as ready for review March 8, 2021 22:48
@jim-wang-intel jim-wang-intel force-pushed the snap-setup-consul-acl branch from 0cea5ec to e16aee3 Compare March 11, 2021 21:02
siggiskulason
siggiskulason previously approved these changes Mar 22, 2021
Copy link

@siggiskulason siggiskulason left a comment

Choose a reason for hiding this comment

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

LGTM. This PR meets the requirements of the feature request, as follows:

  • Add token for consul secret engine in snap
    I see the token in /var/snap/edgexfoundry/x1/secrets/consul-acl-token/bootstrap_token.json and in the log we get

    "bootstrap token is written to /var/snap/edgexfoundry/x1/secrets/consul-acl- 
    token/bootstrap_token.json"
    
  • Add env. for ACL enable: ENABLE_REGISTRY_ACL: true
    snapcraft.yaml sets ENABLE_REGISTRY_ACL to true and the log shows
    "setupRegistryACL successfully done"

  • Add env. for consul secret engine admin token: SECRETSTORE_CONSULSECRETSADMINTOKENPATH
    snapcraft.yaml sets SECRETSTORE_CONSULSECRETSADMINTOKENPATH: $SNAP_DATA/secrets/edgex-consul/admin/token.json
    and logs shows

"successfully retrieved secretstore management token from /var/snap/edgexfoundry/x1/secrets/edgex-consul/admin/token.json"
  • Add logic for copying the needed configuration toml from security-bootstrapper

    • The two files have been copied to
    /var/snap/edgexfoundry/x1/config/security-bootstrapper$ ls -alR
    
    ./res:
    total 12
    drwxr-xr-x 2 root root 4096 Mar 22 15:11 .
    drwxr-xr-x 4 root root 4096 Mar 22 15:11 ..
    -rwxr-xr-x 1 root root 1765 Mar 22 15:11 configuration.toml
    
    ./res-bootstrap-redis:
    total 12
    drwxr-xr-x 2 root root 4096 Mar 22 15:11 .
    drwxr-xr-x 4 root root 4096 Mar 22 15:11 ..
    -rwxr-xr-x 1 root root 1459 Mar 22 15:11 configuration.toml
    
  • Add consul-bootstrapper one-shot service for setting up Consul's ACL
    security-consul-bootstrapper oneshot daemon is defined in snapcraft.yaml.

    setting ENABLE_REGISTRY_ACL to false results in

    "in setup-consul-acl.sh: ENABLE_REGISTRY_ACL = false"
    "ACL not enabled, skip Consul's ACL setup"
    
  • Add feature flag logic in start_consul.sh shell script

    • /var/snap/edgexfoundry/current/consul/config/consul_acl.json has been updated
  • Consul-bootstrapper one-shot service to launch using shell script
    setup-consul-acl.sh runs and sets up the registry ACL. Log shows
    "in setup-consul-acl.sh: ENABLE_REGISTRY_ACL = true"

@jim-wang-intel
Copy link
Contributor Author

LGTM. This PR meets the requirements of the feature request, as follows:

* [x]  Add token for consul secret engine in snap
  I see the token in /var/snap/edgexfoundry/x1/secrets/consul-acl-token/bootstrap_token.json and in the log we get
  ```
  "bootstrap token is written to /var/snap/edgexfoundry/x1/secrets/consul-acl- 
  token/bootstrap_token.json"
  ```

* [x]  Add env. for ACL enable: ENABLE_REGISTRY_ACL: true
  snapcraft.yaml sets ENABLE_REGISTRY_ACL to true and the log shows
  "setupRegistryACL successfully done"

* [x]  Add env. for consul secret engine admin token: SECRETSTORE_CONSULSECRETSADMINTOKENPATH
  snapcraft.yaml sets SECRETSTORE_CONSULSECRETSADMINTOKENPATH: $SNAP_DATA/secrets/edgex-consul/admin/token.json
  and logs shows
"successfully retrieved secretstore management token from /var/snap/edgexfoundry/x1/secrets/edgex-consul/admin/token.json"
* [x]  Add logic for copying the needed configuration toml from security-bootstrapper
  
  * The two files have been copied to
  
  ```
  /var/snap/edgexfoundry/x1/config/security-bootstrapper$ ls -alR
  
  ./res:
  total 12
  drwxr-xr-x 2 root root 4096 Mar 22 15:11 .
  drwxr-xr-x 4 root root 4096 Mar 22 15:11 ..
  -rwxr-xr-x 1 root root 1765 Mar 22 15:11 configuration.toml
  
  ./res-bootstrap-redis:
  total 12
  drwxr-xr-x 2 root root 4096 Mar 22 15:11 .
  drwxr-xr-x 4 root root 4096 Mar 22 15:11 ..
  -rwxr-xr-x 1 root root 1459 Mar 22 15:11 configuration.toml
  ```

* [x]  Add consul-bootstrapper one-shot service for setting up Consul's ACL
  security-consul-bootstrapper oneshot daemon is defined in snapcraft.yaml.
  setting ENABLE_REGISTRY_ACL to false results in
  ```
  "in setup-consul-acl.sh: ENABLE_REGISTRY_ACL = false"
  "ACL not enabled, skip Consul's ACL setup"
  ```

* [x]  Add feature flag logic in start_consul.sh shell script
  
  * /var/snap/edgexfoundry/current/consul/config/consul_acl.json has been updated

* [x]  Consul-bootstrapper one-shot service to launch using shell script
  setup-consul-acl.sh runs and sets up the registry ACL. Log shows
  `"in setup-consul-acl.sh: ENABLE_REGISTRY_ACL = true"`

Thank you very much, @siggiskulason for your thorough reviews and verification.
I'll rebase to the latest master branch and push.

- Add token for consul secret engine in snap
- Add env. for ACL enable: ENABLE_REGISTRY_ACL: true
- Add env. for consul secret engine admin token: SECRETSTORE_CONSULSECRETSADMINTOKENPATH
- Add logic for copying the needed configuration toml from security-bootstrapper
- Add consul-bootstrapper one-shot service for setting up Consul's ACL
- Add feature flag logic in start_consul.sh shell script
- Add env. overrides for consul-bootstrapper
- Make consul-bootstrapper use shell script as command to run setupRegistryACL

Closes: edgexfoundry#3222

Signed-off-by: Jim Wang <[email protected]>
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

Copy link
Member

@lenny-goodell lenny-goodell left a comment

Choose a reason for hiding this comment

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

LGTM

@jim-wang-intel jim-wang-intel merged commit eeaee6b into edgexfoundry:master Mar 22, 2021
@jim-wang-intel jim-wang-intel deleted the snap-setup-consul-acl branch March 22, 2021 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3-high priority denoting release-blocking issues blocked enhancement New feature or request ireland security-services snap Snap packaging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Secure Consul Ph. 1] Snap: Enable and Bootstrap Consul ACL to configure Vault's Consul secret engine Acces
4 participants