Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidKey = fmt.Errorf("user token key is invalid") ErrInvalidToken = fmt.Errorf("user token is invalid") )
Functions ¶
func ContextWithClaims ¶
ContextWithClaims stores the user, the subscription and the raw token. The user is stored under bootstrapify's authorization user key, so its Authorize middleware sees it. Nil claims leave ctx unchanged and a nil user is not stored, because Authorize would call GetID on it.
Types ¶
type Claims ¶
type Claims struct {
jwt.RegisteredClaims
User *User `json:"User"`
Subscription *Subscription `json:"subscription,omitempty"`
}
Claims' JSON keys are the wire contract of the user token and must match the claims auth-api signs.
type Subscription ¶
func SubscriptionFromContext ¶
func SubscriptionFromContext(ctx context.Context) (*Subscription, bool)
type User ¶
type User struct {
ID uuid.UUID `json:"id"`
Username string `json:"username,omitempty"`
Roles []string `json:"roles,omitempty"`
}
User is the identity carried in the user token.
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator validates HS256-signed user tokens. The key is immutable after construction, so a Validator is safe for concurrent use.
func NewValidator ¶
NewValidator decodes the base64-encoded HS256 key. Like auth-api, it uses the first 32 bytes of the decoded key.
Click to show internal directories.
Click to hide internal directories.