{"modulePath":"github.com/mutablelogic/go-server","version":"v1.1.4","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package tokenauth\n\ntokenauth package implements authentication tokens for HTTP servers\n\n## Constants\n\n```go\nconst (\n\t// Scope for reading tokens\n\tScopeRead = \"github.com/mutablelogic/go-server/tokenauth:read\"\n\n\t// Scope for updating, deleting and creating tokens\n\tScopeWrite = \"github.com/mutablelogic/go-server/tokenauth:write\"\n)\n```\n\n```go\nconst (\n\tAdminToken = \"admin\"\n)\n```\n\n## Functions\n\n```go\nfunc NewWithPlugin(p Plugin, label string) (*tokenauth, error)\n```\nCreate a new logger task with provider of other tasks\n\n## Types\n\n```go\ntype EventType int\n```\n\n```go\nconst (\n\tEventTypeNone EventType = iota\n\tEventTypeWrite\n)\n```\n\n```go\nfunc (t EventType) String() string\n```\n\n```go\ntype Plugin struct {\n\ttask.Plugin\n\tPath_  string        `json:\"path,omitempty\"`\n\tFile_  string        `json:\"file,omitempty\"`\n\tDelta_ time.Duration `json:\"delta,omitempty\"`\n}\n```\nPlugin for tokenauth for storing tokens in a file\n\n```go\nfunc WithLabel(label string) Plugin\n```\n\n```go\nfunc (p Plugin) Delta() time.Duration\n```\n\n```go\nfunc (p Plugin) File() string\n```\n\n```go\nfunc (p Plugin) Name() string\n```\n\n```go\nfunc (p Plugin) New(parent context.Context, _ iface.Provider) (iface.Task, error)\n```\nCreate a new logger task with provider of other tasks\n\n```go\nfunc (p Plugin) Path() (string, error)\n```\n\n```go\nfunc (p Plugin) WithPath(path string) Plugin\n```\n\n```go\ntype Token struct {\n\tName   string    `json:\"name,omitempty\"`        // Name of the token\n\tValue  string    `json:\"token,omitempty\"`       // Token value\n\tExpire time.Time `json:\"expire_time,omitempty\"` // Time of expiration for the token\n\tTime   time.Time `json:\"access_time\"`           // Time of last access\n\tScope  []string  `json:\"scopes,omitempty\"`      // Authentication scopes\n}\n```\n\n```go\nfunc NewToken(length int, duration time.Duration, scope ...string) *Token\n```\n\n```go\nfunc (t *Token) IsScope(scopes ...string) bool\n```\nReturn true if the token has the specified scope, and is valid\n\n```go\nfunc (t *Token) IsValid() bool\n```\nReturn true if the token is valid (not expired)\n\n```go\nfunc (t *Token) MarshalJSON() ([]byte, error)\n```\n\n```go\nfunc (t *Token) String() string\n```\n\n```go\ntype TokenCreate struct {\n\tDuration time.Duration `json:\"duration,omitempty\"` // Duration of the token, or zero for no expiration\n\tScope    []string      `json:\"scopes,omitempty\"`   // Authentication scopes\n}\n```\n\n","path":"github.com/mutablelogic/go-server/pkg/httpserver/tokenauth","name":"tokenauth","synopsis":"tokenauth package implements authentication tokens for HTTP servers","isRedistributable":true}
