secrets

package
v0.0.0-...-8b292c0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2022 License: MIT Imports: 6 Imported by: 2

Documentation

Overview

********************************************************************************** The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **********************************************************************************

********************************************************************************** The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **********************************************************************************

Index

Constants

This section is empty.

Variables

View Source
var (
	// InvalidManagerType is secure library error code that represents an
	// unsupoported secret manager type value was used
	InvalidManagerType = 1650
	// ErrInvalidManagerType is sued when an invalid ManagerType values was used
	ErrInvalidManagerType = fmt.Errorf("[%d] invlaid or unsupported manager type", InvalidManagerType)
)

Functions

This section is empty.

Types

type Manager

type Manager interface {
	GetSecret(key string) (Secret, error)
	AddSecret(key string, value Secret) error
	DeleteSecret(key string) error
	UpdateSecret(key string, value Secret) error
	Close() error
}

Manager is an interface that manages the retrieval and rotation of secrets used by applications, such as organizational tokens, application passwords and connection string, etc....

type ManagerConfiguration

type ManagerConfiguration struct {
	ConnectionString    string                 `json:"connectionstring" yaml:"connectionstring"`
	ManagerType         ManagerType            `json:"managertype" yaml:"managertype"`
	SecretDurationHours int64                  `json:"secretduration" yaml:"secretduration"`
	Parameters          map[string]interface{} `json:"parameters" yaml:"parameters"`
}

ManagerConfiguration holds all of the necessary configuration parameters required to configure a secrets manager connected to on-premise resources or a specific cloud provider

func (ManagerConfiguration) JSON

func (config ManagerConfiguration) JSON(pretty bool) []byte

JSON serilaizes the ManagerConfiguration to a JSON byte array, if an error occured it is returned

func (ManagerConfiguration) MarshalJSON

func (config ManagerConfiguration) MarshalJSON() ([]byte, error)

MarshalJSON is a method implemented allowing custom serialization of the ManagerConfiguration to JSON

func (ManagerConfiguration) MarshalYAML

func (config ManagerConfiguration) MarshalYAML() ([]byte, error)

MarshalYAML is a method implemented allowing custom serialization of the ManagerConfiguration to YAML

func (*ManagerConfiguration) UnmarshalJSON

func (config *ManagerConfiguration) UnmarshalJSON(data []byte) error

UnmarshalJSON is a method implemented allowing custom de-serialization ManagerConfiguration from JSON

func (*ManagerConfiguration) UnmarshalYAML

func (config *ManagerConfiguration) UnmarshalYAML(data []byte) error

UnmarshalYAML is a method implemented allowing custom de-serialization ManagerConfiguration from YAML

func (ManagerConfiguration) YAML

func (config ManagerConfiguration) YAML() []byte

ToYAML serializes and returns the current SecretsConfiguration object to a JSON string representation, other wise an error is returned

type ManagerType

type ManagerType int

ManagerType represents an enumerated type for the different supported secrets managers an application can leverage

const (
	// AWSSECRETS represents the AWS Secrets Manager service
	AWSSECRETS ManagerType = iota
	// LOCALSECRETS represents an embedded persistent secrets store for development
	// use
	LOCALSECRETS
)

func ManagerTypeFromString

func ManagerTypeFromString(mgrTypeString string) (returnType ManagerType, err error)

ManagerTypeFromString returns the manager type from a string representation

func (ManagerType) String

func (mgrType ManagerType) String() string

String returns the string representation of the ManagerType

type Secret

type Secret struct {
	Name           string         `json:"name" yaml:"name"`
	Value          interface{}    `json:"value" yaml:"value"`
	Expires        time.Time      `json:"expires" yaml:"expires"`
	PreviousValues []SimpleSecret `json:"previousvalues" yaml:"previousvalues"`
}

Secret is an object that holds private information used by applications and it holds all of the supporting fields that can be used to support the ongoing rotation of a secret

func NewSecret

func NewSecret(name string, value interface{}, secretDurationHours int64) *Secret

NewSecret creates and returns a reference to a new secret

func (Secret) JSON

func (secret Secret) JSON(pretty bool) []byte

JSON serilaizes the current Secret to a JSON byte array, if an error occured it is returned

func (*Secret) UpdateValue

func (secret *Secret) UpdateValue(value interface{}, expireDuration time.Duration) error

UpdateValue replaces the current value for the secret and adds the current value to the previous values

func (Secret) YAML

func (secret Secret) YAML() []byte

YAML serilaizes the current Secret to a YAML byte array, if an error occured it is returned

type SimpleSecret

type SimpleSecret struct {
	Expires int64       `json:"expiredtime" yaml:"expiredtime"`
	Value   interface{} `json:"value" yaml:"value"`
}

SimpleSecret is a simple representation of a secret value containing the value itself and the expires value in unix time

Directories

Path Synopsis
********************************************************************************** The MIT License (MIT) Copyright (c) 2022 Sean Beard Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
********************************************************************************** The MIT License (MIT) Copyright (c) 2022 Sean Beard Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
********************************************************************************** The MIT License (MIT) Copyright (c) 2022 Sean Beard Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
********************************************************************************** The MIT License (MIT) Copyright (c) 2022 Sean Beard Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL