-
Notifications
You must be signed in to change notification settings - Fork 24
demo(docs): Updated vault/openBao plugin #2839
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
Draft
dmihalcik-virtru
wants to merge
7
commits into
main
Choose a base branch
from
DSPX-1842-vaultsample
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d7213ab
feat(core): Actually use KeyManager ProviderConfig
dmihalcik-virtru da9d531
Update kas.go
dmihalcik-virtru 0c84bfd
Update kas.go
dmihalcik-virtru f000ac8
fix unit test
dmihalcik-virtru 9120ca2
chore(docs): example with vault/openbao
dmihalcik-virtru 68d0607
update actions
dmihalcik-virtru c31b5d0
lint fixes
dmihalcik-virtru File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # ignores for CKMS Sample Code | ||
|
|
||
| # Generated keydata | ||
| *.crt | ||
| *.key | ||
| *.pem | ||
|
|
||
| # Logfiles | ||
| vault-startup.log | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| # Sample Key Management System Integration with OpenBao | ||
|
|
||
| This folder includes an example Cryptographic Key Management System (CKMS) extension for OpenTDF. | ||
| It uses Vault or OpenBao to store KAS asymmetric key data, | ||
| provided via a `trust.KeyService` plugin. | ||
|
|
||
| ## Starting Vault | ||
|
|
||
| Start up vault, configured to run in dev mode with local storage. | ||
|
|
||
| ```sh | ||
| LOCAL_HOSTNAME=$(hostname) | ||
| vault server -dev -dev-root-token-id root -dev-tls -dev-tls-cert-dir=./ | ||
| ``` | ||
|
|
||
| Install the generated CA certificate into the system keychain. | ||
|
|
||
| ```sh | ||
| sudo security add-trusted-cert -d -r trustRoot -k "/Library/Keychains/System.keychain" ./vault-ca.pem | ||
| ``` | ||
|
|
||
| Copy the configuration details somewhere. | ||
| Copy and paste the environment variable configuration into a new shell. | ||
|
|
||
| ```sh | ||
| export VAULT_ADDR="https://127.0.0.1:8200" | ||
| export VAULT_CACERT="$(pwd)/vault-ca.pem" | ||
| ``` | ||
|
|
||
| Validate vault is running, and log in | ||
|
|
||
| ```sh | ||
| vault status | ||
| echo root | vault login - | ||
| ``` | ||
|
|
||
| Let's create some roles, policies, and tokens that apply them: | ||
|
|
||
| ```sh | ||
| vault secrets enable -path=secret kv-v2 | ||
|
|
||
| vault policy write kas-admin ./vault/policy-admin.hcl | ||
| vault policy write kas-service ./vault/policy-service.hcl | ||
| vault policy write kas-viewer ./vault/policy-viewer.hcl | ||
|
|
||
| vault token create -policy="kas-admin" -policy="kas-viewer" | ||
| # Use this token to create and delete KAS keys | ||
| # export KAS_ADMIN_TOKEN=<TOKEN> | ||
| echo ${KAS_ADMIN_TOKEN} | vault login - | ||
| vault kv put secret/kas_keypair/r1 private="$(<../../kas-private.pem | base64)" public="$(<../../kas-cert.pem)" algorithm="rsa:2048"" | ||
| ``` | ||
|
|
||
| ```sh | ||
| echo root | vault login - | ||
|
|
||
| # Create a role to from within KAS | ||
| vault auth enable approle | ||
| vault write auth/approle/role/kas policies="kas-service,kas-viewer" | ||
| vault read auth/approle/role/kas/role-id | ||
| vault write -f auth/approle/role/kas/secret-id | ||
| ## Use the role_id and secret_id from the above outputs to create a token with this: | ||
| # export KAS_APPROLE_ROLEID=<ROLE_ID> | ||
| # export KAS_APPROLE_SECRETID=<SECRET_ID> | ||
| vault write auth/approle/login role_id=${KAS_APPROLE_ROLEID} secret_id=${KAS_APPROLE_SECRETID} | ||
| ``` | ||
|
|
||
| Set KAS_SERVICE_TOKEN to the token returned from the above command. | ||
|
|
||
| ```sh | ||
| echo ${KAS_SERVICE_TOKEN} | vault login - | ||
| vault kv list -mount=secret kas_keypair | ||
| ``` | ||
|
|
||
|
|
||
| ### Start platform services with sample CKMS plugin | ||
|
|
||
| Run the example | ||
|
|
||
| ```sh | ||
| go run examples/ckms | ||
| ``` | ||
|
|
||
| #### | ||
| #### Add key based configuration using a new KAS key in the CKMS | ||
|
|
||
|
|
||
| ### Encrypt something | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| logger: | ||
| level: debug | ||
| type: text | ||
| output: stdout | ||
| # DB and Server configurations are defaulted for local development | ||
| # db: | ||
| # host: localhost | ||
| # port: 5432 | ||
| # user: postgres | ||
| # password: changeme | ||
| services: | ||
| entityresolution: | ||
| log_level: info | ||
| url: http://localhost:8888/auth | ||
| clientid: "tdf-entity-resolution" | ||
| clientsecret: "secret" | ||
| realm: "opentdf" | ||
| legacykeycloak: true | ||
| inferid: | ||
| from: | ||
| email: true | ||
| username: true | ||
| # policy is enabled by default in mode 'all' | ||
| # policy: | ||
| # enabled: true | ||
| # list_request_limit_default: 1000 | ||
| # list_request_limit_max: 2500 | ||
| server: | ||
| tls: | ||
| enabled: false | ||
| cert: ./keys/platform.crt | ||
| key: ./keys/platform-key.pem | ||
| auth: | ||
| enabled: true | ||
| enforceDPoP: false | ||
| public_client_id: "opentdf-public" | ||
| audience: "http://localhost:8080" | ||
| issuer: http://localhost:8888/auth/realms/opentdf | ||
| policy: | ||
| ## Dot notation is used to access nested claims (i.e. realm_access.roles) | ||
| # Claim that represents the user (i.e. email) | ||
| username_claim: # preferred_username | ||
| # That claim to access groups (i.e. realm_access.roles) | ||
| groups_claim: # realm_access.roles | ||
| ## Extends the builtin policy | ||
| extension: | | ||
| g, opentdf-admin, role:admin | ||
| g, opentdf-standard, role:standard | ||
| ## Custom policy that overrides builtin policy (see examples https://github.com/casbin/casbin/tree/master/examples) | ||
| csv: #| | ||
| # p, role:admin, *, *, allow | ||
| ## Custom model (see https://casbin.org/docs/syntax-for-models/) | ||
| model: #| | ||
| # [request_definition] | ||
| # r = sub, res, act, obj | ||
| # | ||
| # [policy_definition] | ||
| # p = sub, res, act, obj, eft | ||
| # | ||
| # [role_definition] | ||
| # g = _, _ | ||
| # | ||
| # [policy_effect] | ||
| # e = some(where (p.eft == allow)) && !some(where (p.eft == deny)) | ||
| # | ||
| # [matchers] | ||
| # m = g(r.sub, p.sub) && globOrRegexMatch(r.res, p.res) && globOrRegexMatch(r.act, p.act) && globOrRegexMatch(r.obj, p.obj) | ||
| trace: | ||
| enabled: false | ||
| provider: | ||
| name: file # file | otlp | ||
| file: | ||
| path: "./traces/traces.log" | ||
| prettyPrint: true # Optional, default is compact JSON | ||
| maxSize: 50 # Optional, default 20MB | ||
| maxBackups: 5 # Optional, default 10 | ||
| maxAge: 14 # Optional, default 30 days | ||
| compress: true # Optional, default false | ||
| # otlp: | ||
| # protocol: grpc # Optional, defaults to grpc | ||
| # endpoint: "localhost:4317" | ||
| # insecure: true # Set to false if Jaeger requires TLS | ||
| # headers: {} # Add if authentication is needed | ||
| # HTTP | ||
| # protocol: "http/protobuf" | ||
| # endpoint: "http://localhost:4318" # Default OTLP HTTP port | ||
| # insecure: true # If collector is just HTTP, not HTTPS | ||
| # headers: {} # Add if authentication is needed | ||
| cors: | ||
| # "*" to allow any origin or a specific domain like "https://yourdomain.com" | ||
| allowedorigins: | ||
| - "*" | ||
| # List of methods. Examples: "GET,POST,PUT" | ||
| allowedmethods: | ||
| - GET | ||
| - POST | ||
| - PATCH | ||
| - PUT | ||
| - DELETE | ||
| - OPTIONS | ||
| # List of headers that are allowed in a request | ||
| allowedheaders: | ||
| - ACCEPT | ||
| - Authorization | ||
| - Content-Type | ||
| - X-CSRF-Token | ||
| - X-Request-ID | ||
| # List of response headers that browsers are allowed to access | ||
| exposedheaders: | ||
| - Link | ||
| # Sets whether credentials are included in the CORS request | ||
| allowcredentials: true | ||
| # Sets the maximum age (in seconds) of a specific CORS preflight request | ||
| maxage: 3600 | ||
| grpc: | ||
| reflectionEnabled: true # Default is false | ||
| port: 8080 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| version: "3.9" | ||
| services: | ||
| ckms: | ||
| image: hashicorp/vault:latest | ||
| cap_add: | ||
| - IPC_LOCK | ||
| command: vault server -config vault/config/local.json | ||
| environment: | ||
| VAULT_ADDR: 'https://127.0.0.1:8200' | ||
| VAULT_LOCAL_CONFIG: '{"listener":[{"tcp":{"address": "0.0.0.0:8200","tls_disable":"1"}}],"ui":true,"storage":[{"file":{"path":"/vault/data"}}]}' | ||
| healthcheck: | ||
| retries: 5 | ||
| ports: | ||
| - 8200:8200 | ||
| restart: always | ||
| volumes: | ||
| - ./vault/config:/vault/config | ||
| - ./vault/data:/vault/data |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check failure
Code scanning / zizmor
runtime artifacts potentially vulnerable to a cache poisoning attack Error