Documentation ¶
Index ¶
- Variables
- type AccountServerExchanger
- type Exchanger
- type Interface
- type Memory
- func (m *Memory) Delete(gatewayID string) error
- func (m *Memory) GetToken(gatewayID string) (string, error)
- func (m *Memory) SetExchanger(e Exchanger)
- func (m *Memory) SetKey(gatewayID string, key string) error
- func (m *Memory) SetToken(gatewayID string, token string, expires time.Time) error
- func (m *Memory) ValidateKey(gatewayID string, key string) error
- type Redis
- func (r *Redis) Delete(gatewayID string) error
- func (r *Redis) GetToken(gatewayID string) (string, error)
- func (r *Redis) SetExchanger(e Exchanger)
- func (r *Redis) SetKey(gatewayID string, key string) error
- func (r *Redis) SetToken(gatewayID string, token string, expires time.Time) error
- func (r *Redis) ValidateKey(gatewayID string, key string) error
Constants ¶
This section is empty.
Variables ¶
var DefaultRedisPrefix = "gateway:"
DefaultRedisPrefix is used as prefix when no prefix is given
var ErrGatewayNoValidToken = errors.New("Gateway does not have a valid access token")
ErrGatewayNoValidToken is returned when a gateway does not have a valid access token
var ErrGatewayNotFound = errors.New("Gateway not found")
ErrGatewayNotFound is returned when a gateway was not found
Functions ¶
This section is empty.
Types ¶
type AccountServerExchanger ¶
type AccountServerExchanger struct {
// contains filtered or unexported fields
}
AccountServerExchanger uses a TTN Account Server to exchange the key for a token
type Exchanger ¶
type Exchanger interface {
Exchange(gatewayID, key string) (token string, expires time.Time, err error)
}
Exchanger interface exchanges a gateway access key for a gateway token
type Interface ¶
type Interface interface { SetToken(gatewayID string, token string, expires time.Time) error SetKey(gatewayID string, key string) error ValidateKey(gatewayID string, key string) error Delete(gatewayID string) error // GetToken returns the access token for a gateway; it exchanges the key for an access token if necessary GetToken(gatewayID string) (token string, err error) SetExchanger(Exchanger) }
Interface for gateway authentication
type Memory ¶
type Memory struct { Exchanger // contains filtered or unexported fields }
Memory implements the authentication interface with an in-memory backend
func (*Memory) SetExchanger ¶
SetExchanger sets the component that will exchange access keys for access tokens
type Redis ¶
type Redis struct { Exchanger // contains filtered or unexported fields }
Redis implements the authentication interface with a Redis backend
func (*Redis) SetExchanger ¶
SetExchanger sets the component that will exchange access keys for access tokens