Documentation ¶
Index ¶
Constants ¶
View Source
const ( // UserKey is temporary User key received on successful login. UserKey uint32 = iota // RecoveryKey represents a key for resetting password. RecoveryKey // APIKey enables the one to act on behalf of the user. APIKey )
Variables ¶
View Source
var ( // ErrInvalidKeyIssuedAt indicates that the Key is being used before it's issued. ErrInvalidKeyIssuedAt = errors.New("invalid issue time") // ErrKeyExpired indicates that the Key is expired. ErrKeyExpired = errors.New("use of expired key") // ErrAPIKeyExpired indicates that the Key is expired // and that the key type is API key. ErrAPIKeyExpired = errors.New("use of expired API key") )
View Source
var ( errors.New("unauthorized access") // ErrMalformedEntity indicates malformed entity specification (e.g. // invalid owner or ID). ErrMalformedEntity = errors.New("malformed entity specification") // ErrNotFound indicates a non-existing entity request. ErrNotFound = errors.New("entity not found") // ErrConflict indicates that entity already exists. ErrConflict = errors.New("entity already exists") )ErrUnauthorizedAccess =
Functions ¶
This section is empty.
Types ¶
type Key ¶
type Key struct { ID string Type uint32 IssuerID string Subject string IssuedAt time.Time ExpiresAt time.Time }
Key represents API key.
type KeyRepository ¶
type KeyRepository interface { // Save persists the Key. A non-nil errors is returned to indicate // operation failure Save(context.Context, Key) (string, error) // Retrieve retrieves Key by its unique identifier. Retrieve(context.Context, string, string) (Key, error) // Remove removes Key with provided ID. Remove(context.Context, string, string) error }
KeyRepository specifies Key persistence API.
type Service ¶
type Service interface { // Issue issues a new authn.Key, returning its token value alongside. Issue(ctx context.Context, token string, key Key) (Key, string, error) // Revoke removes the authn.Key with the provided id that is // issued by the user identified by the provided key. Revoke(ctx context.Context, token, id string) error // Retrieve retrieves data for the authn.Key identified by the provided // ID, that is issued by the user identified by the provided key. Retrieve(ctx context.Context, token, id string) (Key, error) // Identify validates token token. If token is valid, content // is returned. If token is invalid, or invocation failed for some // other reason, non-nil errors value is returned in response. Identify(ctx context.Context, token string) (Identity, error) }
Service describes the service.
func New ¶
func New(keys KeyRepository, provider igrid.UUIDProvider, tokenizer Tokenizer) Service
New instantiates the auth service implementation.
Click to show internal directories.
Click to hide internal directories.