Documentation ¶
Index ¶
- Constants
- Variables
- func ES256() (public, private jwk.Key)
- func ParseCookie(r *http.Request, key jwk.Key, cookieName string) (jwt.Token, error)
- func ParseRefreshTokenClaims(token string) (jwt.Token, error)
- func ParseRefreshTokenWithValidate(key *jwk.Key, token string) (jwt.Token, error)
- func ParseRequest(r *http.Request, key jwk.Key) (jwt.Token, error)
- func RS256() (public, private jwk.Key)
- func Sign(key jwk.Key, o *TokenOption) ([]byte, error)
- type Client
- func (c *Client) BlackListClientID(ctx context.Context, cid, email string) error
- func (c *Client) BlackListRefreshToken(ctx context.Context, token string) error
- func (c *Client) ValidateClientID(ctx context.Context, cid string) error
- func (c *Client) ValidateRefreshToken(ctx context.Context, token string) error
- type TokenOption
Constants ¶
View Source
const ( // RefreshTokenCookieName = "RMX_REFRESH_TOKEN" RefreshTokenExpiry = time.Hour * 24 * 7 AccessTokenExpiry = time.Minute * 5 EmailKey = authCtxKey("rmx-email") )
Variables ¶
View Source
var ( ErrNotImplemented = errors.New("not implemented") ErrGenerateKey = errors.New("failed to generate new ecdsa key pair") ErrSignTokens = errors.New("failed to generate signed tokens") ErrRTValidate = errors.New("failed to validate refresh token") )
View Source
var DefaultClient = &Client{
rtdb: redis.NewClient(&redis.Options{Addr: defaultAddr, Password: defaultPassword, DB: 0}),
cidb: redis.NewClient(&redis.Options{Addr: defaultAddr, Password: defaultPassword, DB: 1}),
}
Functions ¶
func ParseCookie ¶
func ParseRequest ¶
ParseRequest searches a http.Request object for a JWT token.
Specifying WithHeaderKey() will tell it to search under a specific header key. Specifying WithFormKey() will tell it to search under a specific form field.
By default, "Authorization" header will be searched.
If WithHeaderKey() is used, you must explicitly re-enable searching for "Authorization" header.
# searches for "Authorization" jwt.ParseRequest(req) # searches for "x-my-token" ONLY. jwt.ParseRequest(req, jwt.WithHeaderKey("x-my-token")) # searches for "Authorization" AND "x-my-token" jwt.ParseRequest(req, jwt.WithHeaderKey("Authorization"), jwt.WithHeaderKey("x-my-token"))
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) BlackListClientID ¶
func (*Client) BlackListRefreshToken ¶
func (*Client) ValidateClientID ¶
Click to show internal directories.
Click to hide internal directories.