security

package
v2.0.73+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2017 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChannelInvalid = uint8(iota)
	ChannelStatic
	ChannelWildcard
)

Channel types

View Source
const (
	AllowNone      = uint32(0)              // Key has no privileges.
	AllowMaster    = uint32(1 << 0)         // Key should be allowed to generate other keys.
	AllowRead      = uint32(1 << 1)         // Key should be allowed to subscribe to the target channel.
	AllowWrite     = uint32(1 << 2)         // Key should be allowed to publish to the target channel.
	AllowStore     = uint32(1 << 3)         // Key should be allowed to write to the message history of the target channel.
	AllowLoad      = uint32(1 << 4)         // Key should be allowed to write to read the message history of the target channel.
	AllowPresence  = uint32(1 << 5)         // Key should be allowed to query the presence on the target channel.
	AllowReadWrite = AllowRead | AllowWrite // Key should be allowed to read and write to the target channel.
	AllowStoreLoad = AllowStore | AllowLoad // Key should be allowed to read and write the message history.
)

Access types for a security key.

View Source
const (
	LicenseTypeUnknown = iota
	LicenseTypeCloud
	LicenseTypeOnPremise
)

Various license types

Variables

This section is empty.

Functions

This section is empty.

Types

type AwsCredentials

type AwsCredentials struct {
	AccessKey string        `json:"access_key"`     // The access key.
	SecretKey string        `json:"secret_key"`     // The secret key.
	Token     string        `json:"security_token"` // The token.
	Duration  time.Duration `json:"-"`              // The duration of the credentials.
	Expires   time.Time     `json:"-"`              // The expiration date of the credentials.
}

AwsCredentials represents Amazon Web Services credentials.

type Channel

type Channel struct {
	Key         []byte          // Gets or sets the API key of the channel.
	Channel     []byte          // Gets or sets the channel string.
	Query       []uint32        // Gets or sets the full ssid.
	Options     []ChannelOption // Gets or sets the options.
	ChannelType uint8
}

Channel represents a parsed MQTT topic.

func ParseChannel

func ParseChannel(text []byte) (channel *Channel)

ParseChannel attempts to parse the channel from the underlying slice.

type ChannelOption

type ChannelOption struct {
	Key   string
	Value string
}

ChannelOption represents a key/value pair option.

type Cipher

type Cipher struct {
	// contains filtered or unexported fields
}

Cipher represents a security cipher which can encrypt/decrypt security keys.

func NewCipher

func NewCipher(value string) (*Cipher, error)

NewCipher creates a new cipher.

func (*Cipher) DecryptKey

func (c *Cipher) DecryptKey(buffer []byte) (Key, error)

DecryptKey decrypts the security key from a base64 encoded string.

func (*Cipher) EncryptKey

func (c *Cipher) EncryptKey(k Key) (string, error)

EncryptKey encrypts the key and return a base-64 encoded string.

type Contract

type Contract interface {
	Validate(key Key) bool // Validate checks the security key with the contract.
}

Contract represents an interface for a contract.

type EnvironmentProvider

type EnvironmentProvider struct {
}

EnvironmentProvider represents a security provider which uses environment variables to store secrets.

func (*EnvironmentProvider) Configure

func (p *EnvironmentProvider) Configure(c *config.Config) error

Configure configures the security provider.

func (*EnvironmentProvider) GetSecret

func (p *EnvironmentProvider) GetSecret(secretName string) (string, bool)

GetSecret retrieves a secret from the provider

type Key

type Key []byte

Key represents a security key.

func (Key) Contract

func (k Key) Contract() int32

Contract gets the contract id.

func (Key) Expires

func (k Key) Expires() time.Time

Expires gets the expiration date for the key.

func (Key) IsEmpty

func (k Key) IsEmpty() bool

IsEmpty checks whether the key is empty or not.

func (Key) IsExpired

func (k Key) IsExpired() bool

IsExpired gets whether the key has expired or not.

func (Key) IsMaster

func (k Key) IsMaster() bool

IsMaster gets whether the key is a master key..

func (Key) Master

func (k Key) Master() uint16

Master gets the master key id.

func (Key) Permissions

func (k Key) Permissions() uint32

Permissions gets the permission flags.

func (Key) Salt

func (k Key) Salt() uint16

Salt gets the random salt of the key

func (Key) SetContract

func (k Key) SetContract(value int32)

SetContract sets the contract id.

func (Key) SetExpires

func (k Key) SetExpires(value time.Time)

SetExpires sets the expiration date for the key.

func (Key) SetMaster

func (k Key) SetMaster(value uint16)

SetMaster sets the master key id.

func (Key) SetPermissions

func (k Key) SetPermissions(value uint32)

SetPermissions sets the permission flags.

func (Key) SetSalt

func (k Key) SetSalt(value uint16)

SetSalt sets the random salt of the key.

func (Key) SetSignature

func (k Key) SetSignature(value int32)

SetSignature sets the signature of the contract.

func (Key) SetTarget

func (k Key) SetTarget(value uint32)

SetTarget sets the target for the key.

func (Key) Signature

func (k Key) Signature() int32

Signature gets the signature of the contract.

func (Key) Target

func (k Key) Target() uint32

Target gets the target for the key.

type License

type License struct {
	EncryptionKey string    // Gets or sets the encryption key.
	Contract      int32     // Gets or sets the contract id.
	Signature     int32     // Gets or sets the signature of the contract.
	Expires       time.Time // Gets or sets the expiration date for the license.
	Type          uint32    // Gets or sets the license type.
}

License represents a security license for the service.

func ParseLicense

func ParseLicense(data string) (*License, error)

ParseLicense decrypts the license and verifies it.

func (*License) Cipher

func (l *License) Cipher() (*Cipher, error)

Cipher creates a new cipher for the licence

func (*License) String

func (l *License) String() string

String converts the license to string.

type Provider

type Provider interface {
	config.SecretStore
}

Provider represents a contract for a security provider.

func NewEnvironmentProvider

func NewEnvironmentProvider() Provider

NewEnvironmentProvider creates a new environment security provider.

type VaultProvider

type VaultProvider struct {
	// contains filtered or unexported fields
}

VaultProvider represents a security provider which uses hashicorp vault to store secrets.

func NewVaultProvider

func NewVaultProvider(user string) *VaultProvider

NewVaultProvider creates a new environment security provider.

func (*VaultProvider) Configure

func (p *VaultProvider) Configure(c *config.Config) error

Configure configures the security provider.

func (*VaultProvider) GetSecret

func (p *VaultProvider) GetSecret(secretName string) (string, bool)

GetSecret retrieves a secret from the provider

Jump to

Keyboard shortcuts

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