Skip to content

Add Support for Secret Manager #35

@flopshot

Description

@flopshot

Motivation

For Serverless products like Cloud Run, one should not be injecting secrets into your backend service via Environment Variables. Thus, one should use Google Cloud's Secret Manager to query for sensitive information like Database Passwords. It seems that there would be a great advantage to have the logic to retrieve secrets in GoogleCloudKit

Implementation

Much of the work for authentication can be re-used from GoogleCloudCore. A request would only need the OAuth token, provided by OAuthRefreshable. From the Secret Manager api docs, a request would be simple enough to implement with the token

Create a Secret

curl "https://secretmanager.googleapis.com/v1/projects/project-id/secrets?secretId=my-secret" \
    --request "POST" \
    --header "authorization: Bearer $(gcloud auth print-access-token)" \
    --header "content-type: application/json" \
    --header "x-goog-user-project: project-id" \
    --data "{\"replication\": {\"automatic\": {}}}"

Retrieve a Secret

curl "https://secretmanager.googleapis.com/v1/projects/project-id/secrets/my-secret/versions/1:access" \
    --request "GET" \
    --header "authorization: Bearer $(gcloud auth print-access-token)" \
    --header "content-type: application/json" \
    --header "x-goog-user-project: project-id"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions