Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Claims ¶
type Claims struct { BuildID int64 `json:"build_id"` IsActive bool `json:"is_active"` IsAdmin bool `json:"is_admin"` Repo string `json:"repo"` TokenType string `json:"token_type"` jwt.RegisteredClaims }
Claims struct is an extension of the JWT standard claims. It includes information about the user.
type Manager ¶
type Manager struct { // PrivateKey key used to sign tokens PrivateKey string // SignMethod method to sign tokens SignMethod jwt.SigningMethod // UserAccessTokenDuration specifies the token duration to use for users UserAccessTokenDuration time.Duration // UserRefreshTokenDuration specifies the token duration for user refresh UserRefreshTokenDuration time.Duration // BuildTokenBufferDuration specifies the additional token duration of build tokens beyond repo timeout BuildTokenBufferDuration time.Duration // WorkerAuthTokenDuration specifies the token duration for worker auth (check in) WorkerAuthTokenDuration time.Duration // WorkerRegisterTokenDuration specifies the token duration for worker register WorkerRegisterTokenDuration time.Duration }
func (*Manager) Compose ¶
Compose generates a refresh and access token pair unique to the provided user and sets a secure cookie. It uses the user's hash to sign the token. to guarantee the signature is unique per token. The refresh token is returned to store with the user in the database.
func (*Manager) MintToken ¶
func (tm *Manager) MintToken(mto *MintTokenOpts) (string, error)
MintToken mints a Vela JWT Token given a set of options.
func (*Manager) ParseToken ¶
ParseToken scans the signed JWT token as a string and extracts the user login from the claims to be looked up in the database. This function will return an error for a few different reasons:
* the token signature doesn't match what is expected * the token signing method doesn't match what is expected * the token is invalid (potentially expired or improper).