Documentation
¶
Index ¶
Constants ¶
const ( AuthParam = "param" AuthHeader = "header" )
const ( KeyManagerEnv = "env" KeyManagerFile = "file" KeyManagerSecretsManager = "aws_sm" )
const Timeout = time.Hour * 24 * 7
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Auth ¶
type Auth interface {
Authenticate(*http.Request, KeyManager) bool
}
Auth is the generic interface for how the client passes in their API key for authentication
type Env ¶
type Env struct {
// contains filtered or unexported fields
}
Env takes a comma separated env var and uses the content as keys
func (*Env) ValidateKey ¶
ValidateKey returns a boolean to whether a key given is present
type File ¶
type File struct {
// contains filtered or unexported fields
}
File manages keys on the local disk
func (*File) ValidateKey ¶
ValidateKey returns a boolean to whether a key given is present in the file
type Header ¶
type Header struct{}
Header is the Auth implementation that requires `X-API-KEY` to be set in the request headers
func (*Header) Authenticate ¶
func (p *Header) Authenticate(r *http.Request, km KeyManager) bool
Authenticate takes the `X-API-KEY` in the request headers and then authenticates it with the KeyManager
type KeyManager ¶
type KeyManager interface { ValidateKey(string) bool FetchKeys() error // contains filtered or unexported methods }
KeyManager is a generic interface for implementing a specific backend for managing API keys
func NewKeyManager ¶
func NewKeyManager(keyManagerType string, id string) KeyManager
NewKeyManager returns a pointer of an KeyManager implementation based on the type of KeyManager that was provided
type Keys ¶
type Keys []string
Keys type is the representation of how keys are stored in the manager
type Param ¶
type Param struct{}
Param is the Auth implementation that requires `apikey` in GET parameters to be set with the key
func (*Param) Authenticate ¶
func (p *Param) Authenticate(r *http.Request, km KeyManager) bool
Authenticate takes the `apikey` in the GET param and then authenticates it with the KeyManager
type SecretsManager ¶
type SecretsManager struct {
// contains filtered or unexported fields
}
SecretsManager is the KeyManager implementation for AWS Secrets Manager
func (*SecretsManager) FetchKeys ¶
func (sm *SecretsManager) FetchKeys() error
FetchKeys sets the keys from the manager backend into memory for use on client auth
func (*SecretsManager) ValidateKey ¶
func (sm *SecretsManager) ValidateKey(key string) bool
ValidateKey returns a boolean to whether a key given is present in the manager
type WebsocketProxy ¶
type WebsocketProxy interface { Dial() (*websocket.Conn, error) Handler(w http.ResponseWriter, r *http.Request) Close() Wait(<-chan os.Signal) }
WebsocketProxy is the generic interface for a proxy implementation
func NewProxy ¶
func NewProxy( url *url.URL, header http.Header, origins []string, auth Auth, keyManager KeyManager, ) (WebsocketProxy, error)
NewProxy returns a configured WebsocketProxy instance and fetches keys if required
func NewSimpleProxy ¶
func NewSimpleProxy(url *url.URL) (WebsocketProxy, error)
NewSimpleProxy returns a configured proxy instance from just a url