Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrExpiry indicates that the token is expired. ErrExpiry = errors.New("token is expired") )
View Source
var ErrKeyExpired = errors.New("use of expired key")
ErrKeyExpired indicates that the Key is expired.
Functions ¶
func DecodeDomainUserID ¶
func EncodeDomainUserID ¶
func SwitchToPermission ¶
Switch the relative permission for the relation.
Types ¶
type Authn ¶
type Authn interface {
// Issue issues a new Key, returning its token value alongside.
Issue(ctx context.Context, token string, key Key) (Token, error)
// Revoke removes the Key with the provided id that is
// issued by the user identified by the provided key.
Revoke(ctx context.Context, token, id string) error
// RetrieveKey retrieves data for the Key identified by the provided
// ID, that is issued by the user identified by the provided key.
RetrieveKey(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 error value is returned in response.
Identify(ctx context.Context, token string) (Key, error)
}
Authn specifies an API that must be fulfilled by the domain service implementation, and all of its decorators (e.g. logging & metrics). Token is a string value of the actual Key and is used to authenticate an Auth service request.
type Authz ¶
type Authz interface {
// Authorize checks authorization of the given `subject`. Basically,
// Authorize verifies that Is `subject` allowed to `relation` on
// `object`. Authorize returns a non-nil error if the subject has
// no relation on the object (which simply means the operation is
// denied).
Authorize(ctx context.Context, pr policies.Policy) error
}
Authz represents a authorization service. It exposes functionalities through `auth` to perform authorization.
type Key ¶
type Key struct {
ID string `json:"id,omitempty"`
Type KeyType `json:"type,omitempty"`
Issuer string `json:"issuer,omitempty"`
Subject string `json:"subject,omitempty"` // user ID
User string `json:"user,omitempty"`
Domain string `json:"domain,omitempty"` // domain user ID
IssuedAt time.Time `json:"issued_at,omitempty"`
ExpiresAt time.Time `json:"expires_at,omitempty"`
}
Key represents API key.
type KeyRepository ¶
type KeyRepository interface {
// Save persists the Key. A non-nil error is returned to indicate
// operation failure
Save(ctx context.Context, key Key) (id string, err error)
// Retrieve retrieves Key by its unique identifier.
Retrieve(ctx context.Context, issuer string, id string) (key Key, err error)
// Remove removes Key with provided ID.
Remove(ctx context.Context, issuer string, id string) error
}
KeyRepository specifies Key persistence API.
type KeyType ¶
type KeyType uint32
const ( // AccessKey is temporary User key received on successful login. AccessKey KeyType = iota // RefreshKey is a temporary User key used to generate a new access key. RefreshKey // RecoveryKey represents a key for resseting password. RecoveryKey // APIKey enables the one to act on behalf of the user. APIKey // InvitationKey is a key for inviting new users. InvitationKey )
type Token ¶
type Token struct {
AccessToken string // AccessToken contains the security credentials for a login session and identifies the client.
RefreshToken string // RefreshToken is a credential artifact that OAuth can use to get a new access token without client interaction.
AccessType string // AccessType is the specific type of access token issued. It can be Bearer, Client or Basic.
}
type Tokenizer ¶
type Tokenizer interface {
// Issue converts API Key to its string representation.
Issue(key Key) (token string, err error)
// Parse extracts API Key data from string token.
Parse(token string) (key Key, err error)
}
Tokenizer specifies API for encoding and decoding between string and Key.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package api contains implementation of Auth service HTTP API.
|
Package api contains implementation of Auth service HTTP API. |
|
grpc/auth
Package auth contains implementation of Auth service gRPC API.
|
Package auth contains implementation of Auth service gRPC API. |
|
grpc/token
Package grpc contains implementation of Auth service gRPC API.
|
Package grpc contains implementation of Auth service gRPC API. |
|
Package postgres contains Key repository implementations using PostgreSQL as the underlying database.
|
Package postgres contains Key repository implementations using PostgreSQL as the underlying database. |
|
Package tracing provides tracing instrumentation for SuperMQ Users service.
|
Package tracing provides tracing instrumentation for SuperMQ Users service. |
Click to show internal directories.
Click to hide internal directories.