Documentation ¶
Overview ¶
Package auth provides user authentication and login services and APIs. It supplies the "jellyauth" component.
To use the jellyauth component, simply add a "jellyauth" section to your config and call jelly.Use(auth.Component) before loading config. This config section overrides the typical API defaults and will create a fully functional system simply by being enabled, albeit with an unpersisted, in-memory database.
TODO: carry over config instructions from the example.
Index ¶
- Constants
- Variables
- type ComponentInfo
- type Config
- func (cfg *Config) Common() jelly.CommonConfig
- func (cfg *Config) FillDefaults() jelly.APIConfig
- func (cfg *Config) Get(key string) interface{}
- func (cfg *Config) Keys() []string
- func (cfg *Config) Set(key string, value interface{}) error
- func (cfg *Config) SetFromString(key string, value string) error
- func (cfg *Config) Validate() error
Constants ¶
View Source
const ( ConfigKeySecret = "secret" ConfigKeySetAdmin = "set_admin" ConfigKeyUnauthDelay = "unauth_delay" )
View Source
const ( MaxSecretSize = 64 MinSecretSize = 32 )
View Source
const (
Version = "0.0.1"
)
Variables ¶
View Source
var ( // Component holds the component information for jellyauth. This is passed // to jelly.Use to enable the use of jellyauth in a server. Component jelly.Component = ComponentInfo{} )
View Source
var (
Issuer = "jelly"
)
Functions ¶
This section is empty.
Types ¶
type ComponentInfo ¶
type ComponentInfo struct{}
func (ComponentInfo) API ¶
func (ci ComponentInfo) API() jelly.API
func (ComponentInfo) Config ¶
func (ci ComponentInfo) Config() jelly.APIConfig
func (ComponentInfo) Name ¶
func (ci ComponentInfo) Name() string
type Config ¶
type Config struct { CommonConf jelly.CommonConfig // Secret is the secret used for signing tokens. If not provided, a default // key is used. Secret []byte // SetAdmin sets the initial admin user in the DB. If it doesn't exist, // it's created on initialization. Format must be USERNAME:PASSWORD. This // will not default; if none is provided, no user is created. If the user // already exists, it will have its password set to the given one. SetAdmin string // UnauthDelayMillis is the amount of additional time to wait // (in milliseconds) before sending a response that indicates either that // the client was unauthorized or the client was unauthenticated. This is // something of an "anti-flood" measure for naive clients attempting // non-parallel connections. If not set it will default to 1 second // (1000ms). Set this to any negative number to disable the delay. UnauthDelayMillis int }
func (*Config) Common ¶
func (cfg *Config) Common() jelly.CommonConfig
func (*Config) FillDefaults ¶
FillDefaults returns a new *Config identical to cfg but with unset values set to their defaults and values normalized.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.