Documentation
¶
Index ¶
- Variables
- func New(c Config) (*auth, error)
- func TokenName(ctx context.Context) string
- func TokenScope(ctx context.Context) []string
- func WithToken(ctx context.Context, token Token) context.Context
- func WithTokenName(ctx context.Context, token Token) context.Context
- func WithTokenScope(ctx context.Context, token Token) context.Context
- type Config
- type Token
- type TokenCreate
- type TokenJar
Constants ¶
This section is empty.
Variables ¶
View Source
var (
// Root scope allows ANY operation
ScopeRoot = scopePrefix + "root"
)
Functions ¶
func TokenScope ¶ added in v1.4.7
TokenScope returns the token scope from the context, or nil
func WithTokenName ¶ added in v1.4.7
WithTokenName returns a context with the given auth token name
Types ¶
type Config ¶
type Config struct { TokenJar TokenJar `hcl:"token_jar" description:"Persistent storage for tokens"` TokenBytes int `hcl:"token_bytes" description:"Number of bytes in a token"` Bearer bool `hcl:"bearer" description:"Use bearer token for authorization"` }
func (Config) Description ¶
Description returns the description of the service
type Token ¶
type Token struct { Name string `json:"name,omitempty"` // Name of the token Value string `json:"token,omitempty"` // Token value Expire time.Time `json:"expire_time,omitempty" writer:",width:29"` // Time of expiration for the token Time time.Time `json:"access_time,omitempty" writer:",width:29"` // Time of last access Scope []string `json:"scopes,omitempty" writer:",wrap"` // Authentication scopes // contains filtered or unexported fields }
func NewToken ¶
Create a token of the specified number of bytes, with the specified duration and scope. If the duration is zero, the token will not expire.
func (Token) MarshalJSON ¶
type TokenCreate ¶
type TokenCreate struct { Name string `json:"name,omitempty"` // Name of the token Duration duration `json:"duration,omitempty"` // Duration of the token, or zero for no expiration Scope []string `json:"scopes,omitempty"` // Authentication scopes }
func NewCreateToken ¶ added in v1.4.7
func NewCreateToken(name string, expires_in time.Duration, scope ...string) TokenCreate
Create a new create token request
type TokenJar ¶
type TokenJar interface { server.Task // Return all tokens Tokens() []Token // Return a token from the jar by value, or an invalid token // if the token is not found. The method should update the access // time of the token. GetWithValue(string) Token // Return a token from the jar by name, or nil if the token // is not found. The method should not update the access time // of the token. GetWithName(string) Token // Put a token into the jar, assuming it does not yet exist. Create(Token) error // Update an existing token in the jar, assuming it already exists. Update(Token) error // Remove a token from the jar, based on key. Delete(string) error }
Source Files
¶
Click to show internal directories.
Click to hide internal directories.