Documentation ¶
Overview ¶
Package security implements security-related features such as signature creation and verification, secrets processing etc.
Index ¶
- func Decrypt(src io.Reader, key PrivateKey) (*bytes.Buffer, error)
- func DecryptRequest(key PrivateKey) func(next http.Handler) http.Handler
- func Encrypt(src io.Reader, key PublicKey) (*bytes.Buffer, error)
- func FilterRequest(trustedSubnet *net.IPNet) func(next http.Handler) http.Handler
- func UnaryRequestsFilter(trustedSubnet *net.IPNet) grpc.UnaryServerInterceptor
- type DatabaseURL
- type PrivateKey
- type PublicKey
- type Secret
- type Signer
- func (s *Signer) CalculateRecordSignature(data storage.Record) (string, error)
- func (s *Signer) CalculateSignature(name string, data metrics.Metric) (string, error)
- func (s *Signer) VerifyRecordSignature(data storage.Record, hash string) (bool, error)
- func (s *Signer) VerifySignature(name string, data metrics.Metric, hash string) (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecryptRequest ¶
func DecryptRequest(key PrivateKey) func(next http.Handler) http.Handler
DecryptRequest is a HTTP middleware that decrypts request's body using RSA algorithm.
func FilterRequest ¶
FilterRequest is a HTTP middleware that rejects requests which don't match trusted subnet.
func UnaryRequestsFilter ¶
func UnaryRequestsFilter( trustedSubnet *net.IPNet, ) grpc.UnaryServerInterceptor
UnaryRequestsFilter is grpc unary interceptor that rejects requests which don't match trusted subnet.
Types ¶
type DatabaseURL ¶
type DatabaseURL string
A DatabaseURL is designed to store database connection URLs and avoid leaking of login and password values during logging.
func (DatabaseURL) String ¶
func (u DatabaseURL) String() string
String returns masked representation of stored value.
type PrivateKey ¶
type PrivateKey *rsa.PrivateKey
PrivateKey is RSA key used to decrypt data.
func NewPrivateKey ¶
func NewPrivateKey(path entity.FilePath) (PrivateKey, error)
NewPrivateKey reads RSA private key from file.
type Secret ¶
type Secret string
A Secret is designed to store sensitive data (e.g. passwords) and avoid leaking of values during logging.
type Signer ¶
type Signer struct {
// contains filtered or unexported fields
}
A Signer provides signature generation and verification functionality.
func NewSigner ¶
NewSigner creates new Signer object with the given secret. The secret is used to generate/verify payload signature.
func (*Signer) CalculateRecordSignature ¶
CalculateRecordSignature generates signature for provided record.
func (*Signer) CalculateSignature ¶
CalculateSignature generates signature for provided payload.
func (*Signer) VerifyRecordSignature ¶
VerifyRecordSignature checks signature of provided record.