Skip to content

go golang secrets-management encryption decryption aes crypto security open-source secret-management local-first data-security key-management lightweight cli package

License

Notifications You must be signed in to change notification settings

vivekjha1213/go-secretsafe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-secretsafe

go-secretsafe Logo

Go Version Build Status License Contributions Welcome PRs Welcome Issues Open Forks Stars Downloads

go-secretsafe is a robust Go package for managing secrets securely. It provides encryption, storage, caching, and versioning capabilities for handling sensitive information in your applications.

Table of Contents

Features

  • Secure encryption and decryption of secrets
  • Local file storage for secrets (encrypted at rest)
  • In-memory caching for fast retrieval of frequently used secrets
  • Versioning support for tracking changes to secrets
  • Custom error types for better error handling and debugging
  • Simple and intuitive API for managing secrets
  • Configurable options for encryption algorithms, storage locations, and cache settings

Project Structure

go-secretsafe/
├── cmd/
│   └── secretsafe/
│       └── main.go         # Main application entry point
├── pkg/
│   └── secretsafe/
│       ├── cache.go        # In-memory cache implementation
│       ├── encryption.go   # Encryption and decryption logic
│       ├── manager.go      # Secret management operations
│       ├── storage.go      # Local file storage for secrets
│       ├── utils/          # Utility functions and helpers
│       └── versioning.go   # Version control for secrets
├── tests/                  # Test files
├── LICENSE
├── README.md
├── go.mod
└── go.sum

Architecture Diagram

Screenshot 2024-09-16 at 1 50 19 AM

Installation

To install go-secretsafe, use the following command:

go get github.com/vivekjha1213/go-secretsafe

Usage

Here's a basic example of how to use go-secretsafe:

package main

import (
    "fmt"
    "github.com/vivekjha1213/go-secretsafe/pkg/secretsafe"
)

func main() {
    manager, err := secretsafe.NewManager()
    if err != nil {
        fmt.Printf("Error creating manager: %v\n", err)
        return
    }

    // Set a secret
    err = manager.SetSecret("database", "password", "mysecretpassword")
    if err != nil {
        fmt.Printf("Error setting secret: %v\n", err)
        return
    }

    // Get a secret
    password, err := manager.GetSecret("database", "password")
    if err != nil {
        fmt.Printf("Error getting secret: %v\n", err)
        return
    }

    fmt.Printf("Retrieved password: %s\n", password)

    // Delete a secret
    err = manager.DeleteSecret("database", "password")
    if err != nil {
        fmt.Printf("Error deleting secret: %v\n", err)
        return
    }

    fmt.Println("Secret deleted successfully")
}

Configuration

go-secretsafe can be configured with custom options:

manager, err := secretsafe.NewManager(
    secretsafe.WithEncryptionAlgorithm("aes256"),
    secretsafe.WithStoragePath("/path/to/secrets"),
    secretsafe.WithCacheSize(100),
)

API Reference

NewManager(options ...Option) (*Manager, error)

Creates a new instance of Manager with optional configuration.

(m *Manager) SetSecret(namespace, key, value string) error

Sets a secret value for the given namespace and key.

(m *Manager) GetSecret(namespace, key string) (string, error)

Retrieves a secret value for the given namespace and key.

(m *Manager) DeleteSecret(namespace, key string) error

Deletes a secret value for the given namespace and key.

(m *Manager) ListSecrets(namespace string) ([]string, error)

Lists all keys in the given namespace.

(m *Manager) SecretExists(namespace, key string) bool

Checks if a secret exists for the given namespace and key.

Testing

To run the tests for go-secretsafe, use the following command:

go test ./...

Contributing

We welcome contributions from the community. To contribute:

  1. Fork this repository
  2. Create a new branch for your feature or bug fix
  3. Commit your changes
  4. Push to your fork
  5. Open a pull request

Please make sure to write appropriate unit tests and follow the existing code style.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Support

For any questions, issues, or support requests, please:

  1. Check the documentation
  2. Search for existing issues
  3. Open a new issue if needed
  4. Contact vivekjha1213@gmail.com for further assistance

Thank you for using go-secretsafe! We hope it helps you manage your secrets securely and efficiently.

About

go golang secrets-management encryption decryption aes crypto security open-source secret-management local-first data-security key-management lightweight cli package

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages