Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/hex-vvbitwarden.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions packages.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ VU Analytics has created a number of packages to simplify its work. These packag

These packages include:

- vvbitwarden; for secure secret management with Bitwarden Secrets Manager

- vvcanvas; for communicating with the CANVAS LMS

- vvtableau; for using Tableau REST API
Expand Down
159 changes: 159 additions & 0 deletions posts/vvbitwarden.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
---
title: "Introduction to vvbitwarden"
author: "VU Analytics"
date: "2024-07-22"
categories: [R, Packages, Security, Secrets Management, vusaverse] # self-defined categories
---

# Secure Secret Management with vvbitwarden

### Introduction

We're excited to introduce `vvbitwarden`, a powerful R package designed to bridge the gap between R workflows and secure secret management. In today's data-driven landscape, managing sensitive information like API keys, database credentials, and authentication tokens securely is paramount. The `vvbitwarden` package provides a seamless interface to interact with Bitwarden Secrets Manager, enabling secure retrieval and management of secrets directly from your R environment.

### What is vvbitwarden?

[![vvbitwarden](/assets/hex-vvbitwarden.png)](https://github.com/vusaverse/vvbitwarden)

The `vvbitwarden` package is an R interface to Bitwarden Secrets Manager, allowing users to securely retrieve secrets stored in their Bitwarden vault. It leverages the Bitwarden Secrets Manager CLI (BWS CLI) to provide a secure and efficient way to access sensitive information without hardcoding credentials in your R scripts or applications.

Whether you're developing R packages, building Shiny applications, or conducting data analysis that requires access to secure resources, `vvbitwarden` ensures your sensitive information remains protected while maintaining ease of use.

### Prerequisites

Before using `vvbitwarden`, you'll need to install the Bitwarden Secrets Manager CLI (BWS CLI) on your system. This CLI tool is essential for the package to communicate with your Bitwarden vault securely.

You can download and install the BWS CLI from the official Bitwarden documentation: [Secrets Manager CLI](https://bitwarden.com/help/secrets-manager-cli/)

### Getting Started with vvbitwarden

Installation is straightforward using the development version from GitHub:

```r
# Install the development version from GitHub
devtools::install_github("vusaverse/vvbitwarden")

# Load the package
library(vvbitwarden)
```

### Setting Up Authentication

Before retrieving secrets, you'll need to configure your Bitwarden access credentials. You can do this by setting environment variables:

```r
# Set environment variables for authentication
Sys.setenv(BITWARDEN_ACCESS_TOKEN = "your_access_token_here")
Sys.setenv(BITWARDEN_SERVER_URL = "https://vault.bitwarden.eu") # Optional, defaults to EU server
```

Alternatively, you can pass these parameters directly to the functions.

### Core Functionality

#### Retrieving Secrets

The primary function `get_bws_secret()` allows you to securely retrieve secrets from your Bitwarden Secrets Manager vault:

```r
# Retrieve a secret using environment variables for authentication
api_key <- get_bws_secret("my_api_key")

# Or specify authentication parameters directly
database_password <- get_bws_secret(
key = "db_password",
access_token = "your_access_token",
server_url = "https://vault.bitwarden.eu"
)

# Use the retrieved secrets in your R workflow
# For example, connecting to a database
library(DBI)
con <- dbConnect(
RMySQL::MySQL(),
host = "localhost",
user = "myuser",
password = database_password, # Securely retrieved password
dbname = "mydatabase"
)
```

#### Utility Functions

The package also provides helper functions for managing authentication:

```r
# Get the configured access token
token <- get_bws_access_token()

# Get the configured server URL
server <- get_bws_server_url()
```

### Key Features

- **Secure Secret Retrieval**: Access secrets stored in Bitwarden Secrets Manager without exposing them in your code
- **Environment Variable Support**: Seamless integration with environment-based configuration
- **Flexible Authentication**: Support for both environment variables and direct parameter passing
- **Cross-Platform Compatibility**: Works on any system where the BWS CLI can be installed
- **Simple API**: Intuitive functions that integrate naturally with R workflows
- **Enterprise-Ready**: Built on Bitwarden's enterprise-grade security infrastructure

### Real-World Use Cases

`vvbitwarden` is particularly valuable for:

- **Data Pipeline Security**: Securely accessing database credentials and API keys in automated workflows
- **Shiny Application Deployment**: Managing sensitive configuration without hardcoding credentials
- **Package Development**: Enabling secure testing and development environments
- **Research Data Access**: Safely handling credentials for accessing external data sources
- **Cloud Integration**: Securely managing cloud service credentials and tokens

### Security Best Practices

When using `vvbitwarden`, consider these security practices:

1. **Never hardcode access tokens** in your R scripts
2. **Use environment variables** for authentication in production environments
3. **Regularly rotate** your Bitwarden access tokens
4. **Limit access permissions** to only the secrets your application needs
5. **Monitor secret access** through Bitwarden's audit logs

### Contributing to vvbitwarden

`vvbitwarden` is an open-source project, and we welcome contributions from the R community. Whether you want to report bugs, suggest features, or contribute code improvements, you can get involved through our [GitHub repository](https://github.com/vusaverse/vvbitwarden).

### Future Development

We're continuously working to enhance `vvbitwarden` with additional features such as:

- Support for creating and updating secrets
- Batch secret retrieval operations
- Enhanced error handling and logging
- Integration with other R package development workflows

### Conclusion

The `vvbitwarden` package represents a significant step forward in bringing enterprise-grade security to R workflows. By providing a simple yet powerful interface to Bitwarden Secrets Manager, it enables R users to maintain the highest security standards without sacrificing productivity or ease of use.

Security should never be an afterthought in data science and R development. With `vvbitwarden`, you can ensure that your sensitive information remains protected while maintaining the flexibility and power that makes R such a valuable tool for data analysis and application development.

Ready to enhance your R workflow security? Install `vvbitwarden` today and start managing your secrets with confidence!

### Further reading

**Liked this post?** Check out more R-related content on [r-bloggers.com](https://www.r-bloggers.com/).

Have a look at our other packages in the `vusaverse` collection:

- [`polyglotr`](https://tomeriko96.github.io/polyglotr/): R package for translation services
- [`vvdoctor`](https://vusaverse.github.io/vvdoctor/): Shiny app for statistics.
- [`vvcanvas`](https://vusaverse.github.io/vvcanvas/): R package for Canvas LMS.
- [`vvtableau`](https://vusaverse.github.io/vvtableau/): R package for Tableau Server.
- [`vvtermtime`](https://vusaverse.github.io/vvtermtime/): R package for Semestry TermTime.
- [`vvauditor`](https://vusaverse.github.io/vvauditor/): R package for auditing data.
- [`vvconverter`](https://vusaverse.github.io/vvconverter/): R package for converting data.
- [`vvfiller`](https://vusaverse.github.io/vvfiller/): R package for filling data.
- [`vvmover`](https://vusaverse.github.io/vvmover/): R package for reading and writing data.
- [`vvsculptor`](https://vusaverse.github.io/vvsculptor/): R package for sculpting data.
- [`vvshiny`](https://vusaverse.github.io/vvshiny/): R package to create shiny apps.