{"id":1647,"date":"2020-05-20T18:27:56","date_gmt":"2020-05-20T23:27:56","guid":{"rendered":"https:\/\/blog.iqonda.net\/?p=1647"},"modified":"2020-05-20T18:30:31","modified_gmt":"2020-05-20T23:30:31","slug":"test-oci-oracle-cloud-infrastructure-vault-secret","status":"publish","type":"post","link":"https:\/\/blog.ls-al.com\/test-oci-oracle-cloud-infrastructure-vault-secret\/","title":{"rendered":"Test OCI (Oracle Cloud Infrastructure) Vault Secret"},"content":{"rendered":"
\nassume oci cli working<\/p>\n<\/blockquote>\n
test an old cli script to list buckets<\/h2>\n
$\u00a0.\/list_buckets.sh <\/p>\n
{\n \"data\": [\n {\n \"compartment-id\": \"*masked*\",\n \"created-by\": \"*masked*\",\n \"defined-tags\": null,\n \"etag\": \"*masked*\",\n \"freeform-tags\": null,\n \"name\": \"bucket-20200217-1256\",\n \"namespace\": \"*masked*\",\n \"time-created\": \"2020-02-17T18:56:07.773000+00:00\"\n }\n ]\n}<\/code><\/pre>\n
test old python script<\/h2>\n
$\u00a0python3 show_user.py \n{\n \"capabilities\": {\n \"can_use_api_keys\": true,\n \"can_use_auth_tokens\": true,\n \"can_use_console_password\": true,\n \"can_use_customer_secret_keys\": true,\n \"can_use_o_auth2_client_credentials\": true,\n \"can_use_smtp_credentials\": true\n },\n \"compartment_id\": \"*masked*\",\n \"defined_tags\": {},\n \"description\": \"*masked*\",\n \"email\": \"*masked*\",\n \"external_identifier\": null,\n \"freeform_tags\": {},\n \"id\": \"*masked*\",\n \"identity_provider_id\": null,\n \"inactive_status\": null,\n \"is_mfa_activated\": false,\n \"lifecycle_state\": \"ACTIVE\",\n \"name\": \"*masked*\",\n \"time_created\": \"2020-02-11T18:24:37.809000+00:00\"\n}<\/code><\/pre>\n
create secret in console<\/h2>\n
\n
- Security > Vault > testvault<\/li>\n
- Create key rr<\/li>\n
- Create secret rr<\/li>\n<\/ul>\n
test python code<\/h2>\n
$\u00a0python3 check-secret.py *masked*\n Reading vaule of secret_id *masked*.\n Decoded content of the secret is: blah.<\/code><\/pre>\n
test cli<\/h2>\n
$\u00a0oci vault secret list --compartment-id *masked*\n\n \"data\": [\n {\n \"compartment-id\": \"*masked*\",\n \"defined-tags\": {\n \"Oracle-Tags\": {\n \"CreatedBy\": \"*masked*\",\n \"CreatedOn\": \"2020-05-19T19:13:52.028Z\"\n }\n },\n \"description\": \"test\",\n \"freeform-tags\": {},\n \"id\": \"*masked*\",\n \"key-id\": \"*masked*\",\n \"lifecycle-details\": null,\n \"lifecycle-state\": \"ACTIVE\",\n \"secret-name\": \"rr\",\n \"time-created\": \"2020-05-19T19:13:51.804000+00:00\",\n \"time-of-current-version-expiry\": null,\n \"time-of-deletion\": null,\n \"vault-id\": \"*masked*\"\n }\n ]\n }\n\n$\u00a0oci vault secret get --secret-id *masked*\n {\n \"data\": {\n \"compartment-id\": \"*masked*\",\n \"current-version-number\": 1,\n \"defined-tags\": {\n \"Oracle-Tags\": {\n \"CreatedBy\": \"*masked*\",\n \"CreatedOn\": \"2020-05-19T19:13:52.028Z\"\n }\n },\n \"description\": \"test\",\n \"freeform-tags\": {},\n \"id\": \"*masked*\",\n \"key-id\": \"*masked*\",\n \"lifecycle-details\": null,\n \"lifecycle-state\": \"ACTIVE\",\n \"metadata\": null,\n \"secret-name\": \"rr\",\n \"secret-rules\": [],\n \"time-created\": \"2020-05-19T19:13:51.804000+00:00\",\n \"time-of-current-version-expiry\": null,\n \"time-of-deletion\": null,\n \"vault-id\": \"*masked*\"\n },\n \"etag\": \"*masked*\"\n }\n\n$\u00a0oci secrets secret-bundle get --secret-id *masked*\n {\n \"data\": {\n \"metadata\": null,\n \"secret-bundle-content\": {\n \"content\": \"YmxhaA==\",\n \"content-type\": \"BASE64\"\n },\n \"secret-id\": \"*masked*\",\n \"stages\": [\n \"CURRENT\",\n \"LATEST\"\n ],\n \"time-created\": \"2020-05-19T19:13:51.804000+00:00\",\n \"time-of-deletion\": null,\n \"time-of-expiry\": null,\n \"version-name\": null,\n \"version-number\": 1\n },\n \"etag\": \"*masked*--gzip\"\n }\n\n$\u00a0echo YmxhaA== | base64 --decode\n blah<\/code><\/pre>\n
one liner<\/h2>\n
$ oci secrets secret-bundle get --secret-id ocid1.vaultsecret.oc1.phx.*masked* --query \"data .{s:\\\"secret-bundle-content\\\"}\" | jq -r '.s.content' | base64 --decode\nblah<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"
https:\/\/github.com\/oracle\/oci-python-sdk\/blob\/master\/examples\/kms_example.py https:\/\/www.ateam-oracle.com\/secure-way-of-managing-secrets-in-oci assume oci cli working test an old cli script to list buckets $\u00a0.\/list_buckets.sh { “data”: [ { “compartment-id”:<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[87],"tags":[],"class_list":["post-1647","post","type-post","status-publish","format-standard","hentry","category-oci"],"_links":{"self":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts\/1647","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/comments?post=1647"}],"version-history":[{"count":0,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts\/1647\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/media?parent=1647"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/categories?post=1647"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/tags?post=1647"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}