Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrSecretNotFound = errors.New("secret not found") ErrSecretExists = errors.New("secret already exists") ErrSecretNameConflict = errors.New("secret with such name already exists") )
var ( ErrInvalidCredentials = errors.New("invalid username or security key") ErrUserExists = errors.New("user already exists") )
Functions ¶
This section is empty.
Types ¶
type AccessToken ¶
type AccessToken string
AccessToken is JWT token used for authentication.
func NewAccessToken ¶
func NewAccessToken(user User, secret creds.Password) (AccessToken, error)
NewAccessToken issues new access token valid for limited period of time.
func TokenFromString ¶
func TokenFromString(src string) AccessToken
TokenFromString create new AccessToken from provided string. Supports strings in form of "Bearer xxx" or raw tokens.
func (AccessToken) Decode ¶
func (t AccessToken) Decode(secret creds.Password) (*Claims, error)
Decode decodes token, verifies it's signature and return claims if the token is valid.
func (AccessToken) String ¶
func (t AccessToken) String() string
String converts AccessToken to string.
type Claims ¶
type Claims struct { jwt.RegisteredClaims Username string }
Claims contain token's payload with various info about token itself and authentciated user.
type Secret ¶
type Secret struct { ID uuid.UUID `db:"secret_id"` Name string Kind goph.DataKind Metadata []byte Data []byte }
Secret represents full secret info stored in the service.
type User ¶
User represents basic user of the system.
func UserFromContext ¶
UserFromContext extracts User object from context. Returns nil, if there is no info regarding user in the context.