Documentation ¶
Index ¶
- Constants
- func NewService(options ...ConfigOption) auth.TokenService
- func WithOTPAddress(address string) auth.TokenOption
- func WithOTPDeliveryMethod(method auth.DeliveryMethod) auth.TokenOption
- func WithRefreshableToken(token *auth.Token) auth.TokenOption
- type ConfigOption
- func WithCookieDomain(domain string) ConfigOption
- func WithCookieMaxAge(age int) ConfigOption
- func WithDB(db rediser) ConfigOption
- func WithIssuer(issuer string) ConfigOption
- func WithLogger(l log.Logger) ConfigOption
- func WithOTP(o auth.OTPService) ConfigOption
- func WithRefreshTokenExpiry(expiresIn time.Duration) ConfigOption
- func WithRepoManager(repoMngr auth.RepositoryManager) ConfigOption
- func WithSecret(secret string) ConfigOption
- func WithTokenExpiry(expiresIn time.Duration) ConfigOption
- type RefreshToken
- type Response
Constants ¶
const ( // ClientIDCookie is the cookie name used to set the token's // ClientID value on a client. ClientIDCookie = "CLIENTID" // RefreshTokenCookie is the cookie name used to set the refresh // token value on a client. RefreshTokenCookie = "REFRESHTOKEN" )
Variables ¶
This section is empty.
Functions ¶
func NewService ¶
func NewService(options ...ConfigOption) auth.TokenService
NewService returns a new TokenService.
func WithOTPAddress ¶ added in v0.2.0
func WithOTPAddress(address string) auth.TokenOption
WithOTPAddress sets an address to receive a randomly generated OTP code. If a delivery method is configured on the token without a corresponding address, we will deliver the OTP code to the user's default sending address.
func WithOTPDeliveryMethod ¶ added in v0.2.0
func WithOTPDeliveryMethod(method auth.DeliveryMethod) auth.TokenOption
WithOTPDeliveryMethod sets a delivery method (e.g. email, phone) to be used as a channel for sending OTP codes related to a JWT token.
func WithRefreshableToken ¶ added in v0.2.0
func WithRefreshableToken(token *auth.Token) auth.TokenOption
WithRefreshableToken uses an older JWT token as a basis for creating a new token. ClientID hashes and the token ID will be carried over to the new token with an updated expiry time.
Types ¶
type ConfigOption ¶
type ConfigOption func(*service)
ConfigOption configures the service.
func WithCookieDomain ¶
func WithCookieDomain(domain string) ConfigOption
WithCookieDomain configures the service with the domain for a secure cookie.
func WithCookieMaxAge ¶
func WithCookieMaxAge(age int) ConfigOption
WithCookieMaxAge sets the max age for an HTTP cookie. Defaults to 7 days.
func WithIssuer ¶
func WithIssuer(issuer string) ConfigOption
WithIssuer is the issuer identity for the JWT token.
func WithLogger ¶
func WithLogger(l log.Logger) ConfigOption
WithLogger configures the service with a logger.
func WithOTP ¶
func WithOTP(o auth.OTPService) ConfigOption
WithOTP configures the service with an OTP management service.
func WithRefreshTokenExpiry ¶ added in v0.2.0
func WithRefreshTokenExpiry(expiresIn time.Duration) ConfigOption
WithRefreshTokenExpiry defines how long a refresh token is valid for. The default value is 15 days.
func WithRepoManager ¶ added in v0.2.0
func WithRepoManager(repoMngr auth.RepositoryManager) ConfigOption
WithRepoManager configures the service with a new RepositoryManager.
func WithSecret ¶
func WithSecret(secret string) ConfigOption
WithSecret configures the service with a secret value for signing functions.
func WithTokenExpiry ¶
func WithTokenExpiry(expiresIn time.Duration) ConfigOption
WithTokenExpiry defines how long tokens are valid for. The default value is 20 minutes.
type RefreshToken ¶ added in v0.2.0
RefreshToken is a token capable of refreshing an expired JWT token.