Keep your secrets safe and sound in the cloud! π
An R package that makes it easy and secure to manage your secrets using Google Cloud Secret Manager. Whether you're building a Shiny app, running R scripts in production, or managing sensitive configuration, googlesecretmanager
has got you covered!
# Install the package
remotes::install_github("brancengregory/googlesecretmanager")
# Load and authenticate (opens browser)
library(googlesecretmanager)
gargle::credentials_app_default()
# Start managing secrets!
sm_project_set("my-project-id")
sm_secret_create("api-key", replication = list(automatic = list()))
sm_secret_version_add("api-key", "your-secret-value")
You can install the development version of googlesecretmanager from GitHub using:
# install.packages("remotes")
remotes::install_github("brancengregory/googlesecretmanager")
This package uses gargle for secure authentication with Google Cloud. Choose your preferred method:
library(googlesecretmanager)
gargle::credentials_app_default() # Opens browser for authentication
library(googlesecretmanager)
gargle::credentials_service_account(
path = "path/to/service-account-key.json"
)
library(googlesecretmanager)
token <- gargle::token_fetch(
scopes = "https://www.googleapis.com/auth/cloud-platform"
)
googlesecretmanager_auth(token = token)
# Store an API key
sm_secret_create("stripe-api-key")
sm_secret_version_add("stripe-api-key", "sk_live_...")
# Retrieve in your application
api_key <- sm_secret_version_get("stripe-api-key")
# Store database credentials
db_config <- list(
host = "db.example.com",
user = "admin",
password = "secret123"
)
sm_secret_create("db-config")
sm_secret_version_add("db-config", jsonlite::toJSON(db_config))
# Use in your application
config <- jsonlite::fromJSON(sm_secret_version_get("db-config"))
# Add a new version
sm_secret_version_add("api-key", "new-secret-value")
# List versions
versions <- sm_secret_version_ls("api-key")
# Delete old versions
sm_secret_version_delete("api-key", "old-version-id")
- π Secure secret management with Google Cloud
- π Version control for secrets
- π Multiple authentication methods
- π¦ Easy integration with R applications
- π οΈ Comprehensive API coverage
- β‘ Efficient secret retrieval
- π― Project-level operations
- π Detailed error messages
- Never commit secrets to version control
- Use appropriate IAM roles and permissions
- Rotate secrets regularly
- Enable audit logging in Google Cloud
- Use service accounts for production
- Keep your R session secure
- Be cautious with secret output in logs
-
Authentication Failed
- Check your Google Cloud credentials
- Verify project permissions
- Ensure correct scopes are set
-
Secret Not Found
- Verify project ID
- Check secret name spelling
- Confirm secret exists in Google Cloud Console
-
Permission Denied
- Review IAM roles
- Check service account permissions
- Verify project access
This package is built with:
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Submit a pull request
- π Package Documentation
- π Google Cloud Secret Manager Docs
- π Report Issues
This project is licensed under the MIT License - see the LICENSE file for details.