Skip to content

devantler/dotnet-secret-manager

Repository files navigation

🔓 .NET Secret Manager

License Test codecov

A simple .NET library to manage cryptographic keys.

Show/hide folder structure
.
├── .github
│   └── workflows
├── Devantler.SecretManager.Core
├── Devantler.SecretManager.SOPS.LocalAge
│   ├── Models
│   └── Utils
└── Devantler.SecretManager.SOPS.LocalAge.Tests
    ├── SOPSLocalAgeSecretManagerTests
    └── Utils
        └── SOPSConfigHelperTests

11 directories

Prerequisites

🚀 Getting Started

To get started, you can install the packages from NuGet.

# For the Age key model
dotnet add package Devantler.SecretManager.SOPS.LocalAge

If you need to create a new implementation for a secret manager, you can install the core package.

dotnet add package Devantler.Keys.Core

📝 Usage

Local Age Secret Manager

The Local Age Secret Manager is a simple secret manager to manage Age keys on your local machine. The secret manager saves and loads keys from your SOPS keyring by default.

Create a new key

To create a new key, you can use the CreateKeyAsync method.

using Devantler.SecretManager.SOPS.LocalAge;

var SecretManager = new SOPSLocalAgeSecretManager();

var key = await SecretManager.CreateKeyAsync();

To delete a key, you can use the DeleteKeyAsync method.

using Devantler.Keys.Age;
using Devantler.SecretManager.SOPS.LocalAge;

var SecretManager = new SOPSLocalAgeSecretManager();

var ageKey = AgeKeygen.InMemory();
await SecretManager.DeleteKeyAsync(ageKey);

Get an existing key

To get an existing key, you can use the GetKeyAsync method.

using Devantler.SecretManager.SOPS.LocalAge;

var SecretManager = new SOPSLocalAgeSecretManager();

var key = await SecretManager.GetKeyAsync("<public key>");

Import a key

To import a key, you can use the ImportKeyAsync method.

using Devantler.Keys.Age;
using Devantler.SecretManager.SOPS.LocalAge;

var SecretManager = new SOPSLocalAgeSecretManager();

var ageKey = AgeKeygen.InMemory();

var key = await SecretManager.ImportKeyAsync(ageKey);

Check if a key exists

To check if a key exists, you can use the KeyExistsAsync method.

using Devantler.SecretManager.SOPS.LocalAge;

var SecretManager = new SOPSLocalAgeSecretManager();

var exists = await SecretManager.KeyExistsAsync("<public key>");

List all keys

To list all keys, you can use the ListKeysAsync method.

using Devantler.SecretManager.SOPS.LocalAge;

var SecretManager = new SOPSLocalAgeSecretManager();

var keys = await SecretManager.ListKeysAsync();

About

A simple .NET library to manage SOPS secrets.

Resources

License

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Packages

 
 
 

Contributors 4

  •  
  •  
  •  
  •  

Languages