Documentation
¶
Overview ¶
Package openpgp implements a go-mail middleware to encrypt mails via OpenPGP
Index ¶
- Constants
- Variables
- type Action
- type Config
- func NewConfig(pr, pu string, o ...Option) (*Config, error)
- func NewConfigFromKeyFiles(pr, pu string, o ...Option) (*Config, error)
- func NewConfigFromKeysByteSlices(pr, pu []byte, o ...Option) (*Config, error)
- func NewConfigFromPrivKeyByteSlice(p []byte, o ...Option) (*Config, error)
- func NewConfigFromPrivKeyFile(f string, o ...Option) (*Config, error)
- func NewConfigFromPubKeyByteSlice(p []byte, o ...Option) (*Config, error)
- func NewConfigFromPubKeyFile(f string, o ...Option) (*Config, error)
- type Middleware
- type Option
- type PGPScheme
Constants ¶
const ( // Type is the type of Middleware Type mail.MiddlewareType = "openpgp" // Version is the version number of the Middleware Version = "0.0.1" )
Variables ¶
var ( // ErrNoPrivKey should be returned if a private key is needed but not provided ErrNoPrivKey = errors.New("no private key provided") // ErrNoPubKey should be returned if a public key is needed but not provided ErrNoPubKey = errors.New("no public key provided") // ErrUnsupportedAction should be returned if a not supported action is set ErrUnsupportedAction = errors.New("unsupported action") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Action represents the encryption/signing action that the Middlware should perform Action Action // Logger represents a log that satisfies the log.Logger interface Logger *log.Logger // PrivKey represents the OpenPGP/GPG private key part used for signing the mail PrivKey string // PublicKey represents the OpenPGP/GPG public key used for encrypting the mail PublicKey string // Schema represents one of the supported PGP encryption schemes Scheme PGPScheme // contains filtered or unexported fields }
Config is the confiuration to use in Middleware creation
func NewConfig ¶
NewConfig returns a new Config struct. All values can be prefilled/overriden using the With*() Option methods
func NewConfigFromKeyFiles ¶
NewConfigFromKeyFiles returns a new Config from a given OpenPGP/GPG private and public key files.
func NewConfigFromKeysByteSlices ¶
NewConfigFromKeysByteSlices returns a new Config from a given OpenPGP/GPG public and private keys byte slices.
func NewConfigFromPrivKeyByteSlice ¶
NewConfigFromPrivKeyByteSlice returns a new Config from a given OpenPGP/GPG private key byte slice.
func NewConfigFromPrivKeyFile ¶
NewConfigFromPrivKeyFile returns a new Config from a given OpenPGP/GPG private key file.
func NewConfigFromPubKeyByteSlice ¶
NewConfigFromPubKeyByteSlice returns a new Config from a given OpenPGP/GPG public key byte slice.
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
Middleware is the middleware struct for the openpgp middleware
func NewMiddleware ¶
func NewMiddleware(c *Config) *Middleware
NewMiddleware returns a new Middleware from a given Config. The returned Middleware satisfies the mail.Middleware interface
func (*Middleware) Handle ¶
func (m *Middleware) Handle(msg *mail.Msg) *mail.Msg
Handle is the handler method that satisfies the mail.Middleware interface
func (*Middleware) Type ¶
func (m *Middleware) Type() mail.MiddlewareType
Type returns the MiddlewareType for this Middleware
type Option ¶
type Option func(cfg *Config)
Option returns a function that can be used for grouping SignerConfig options
func WithLogger ¶
WithLogger sets a slog.Logger for the Config
func WithPrivKeyPass ¶
WithPrivKeyPass sets a passphrase for the PrivKey in the Config
type PGPScheme ¶
type PGPScheme int
PGPScheme is an alias type for an int
const ( // SchemePGPInline represents the PGP/Inline scheme // // Note: Inline PGP only supports plain text mails. Content bodies of type // HTML (or alternative body parts of the same type) will be ignored SchemePGPInline PGPScheme = iota // SchemePGPMIME represents the OpenPGP/MIME (RFC 4880 and 3156) scheme SchemePGPMIME // Not supported yet )