Documentation ¶
Index ¶
- Constants
- func AuthCodeRefreshTokenExists(refreshToken string, invalidateIfFound bool) bool
- func CloseConn(conn redis.Conn)
- func ClosePool()
- func NewAuthCodeGrant(redirectURI string) string
- func NewConn() redis.Conn
- func ROPCRefreshTokenExists(refreshToken string, invalidateIfFound bool) bool
- func VerifyAuthCodeToken(token string) bool
- func VerifyClientCredsToken(token string) bool
- func VerifyImplicitToken(token string) bool
- func VerifyROPCToken(token string) bool
- type AuthCodeToken
- type ClientCredentialsToken
- type ImplicitToken
- type ROPCToken
Constants ¶
const (
// AuthCodeFlowID is prepended to a refresh token issued by the Authorization Code flow
AuthCodeFlowID = "AUTHCODE"
)
const (
// ClientCredsFlowID is prepended to access and refresh tokens issued by the Client Credentials flow
ClientCredsFlowID = "CLICREDS"
)
const (
// ImplicitFlowID is prepended to access tokens issued by the Implicit Grant flow
ImplicitFlowID = "IMPLICIT"
)
const (
// ROPCFlowID is prepended to access and refresh tokens issued by the ROPC flow
ROPCFlowID = "PASSCRED"
)
Variables ¶
This section is empty.
Functions ¶
func AuthCodeRefreshTokenExists ¶
AuthCodeRefreshTokenExists checks if the refresh token exists in the Redis cache and returns the appropriate boolean value. Params: refreshToken: the token to look for in the cache invalidateIfFound: if true, the token is invalidated if found
func ClosePool ¶
func ClosePool()
ClosePool closes the pool of Redis connections. Also captures the error, if any, and logs it.
func NewAuthCodeGrant ¶
NewAuthCodeGrant generates a new authorization grant and adds it to a Redis cache set. This function takes the redirect URI as an argument, since RFC 6749 requires the same URI to be used in the token request as was used in the authorization grant request, if any. Thus, we store it along with the authorization grant in order for us to verify it against the one sent in the token request. Refer: https://tools.ietf.org/html/rfc6749#section-4.1.3
func NewConn ¶
NewConn returns a Redis connection. It is the responsibility of the receiver to close the connection.
func ROPCRefreshTokenExists ¶
ROPCRefreshTokenExists checks if the refresh token exists in the Redis cache and returns the appropriate boolean value. Params: refreshToken: the token to look for in the cache invalidateIfFound: if true, the token is invalidated if found
func VerifyAuthCodeToken ¶
VerifyAuthCodeToken checks if the token exists in the Redis cache. Returns true if token found, false otherwise.
func VerifyClientCredsToken ¶
VerifyClientCredsToken checks if the token exists in the Redis cache. Returns true if token found, false otherwise.
func VerifyImplicitToken ¶
VerifyImplicitToken checks if the token exists in the Redis cache. Returns true if token found, false otherwise.
func VerifyROPCToken ¶
VerifyROPCToken checks if the token exists in the Redis cache. Returns true if token found, false otherwise.
Types ¶
type AuthCodeToken ¶
type AuthCodeToken struct { AccessToken string `json:"access_token"` RefreshToken string `json:"refresh_token"` ExpiresIn int `json:"expires_in"` }
AuthCodeToken represents a token issued by the Authorization Code flow https://tools.ietf.org/html/rfc6749#section-4.1.3
func NewAuthCodeRefreshToken ¶
func NewAuthCodeRefreshToken(refreshToken string) (*AuthCodeToken, error)
NewAuthCodeRefreshToken returns new token for the previously issued refresh token The refresh token is kept intact and can be used for future requests.
func NewAuthCodeToken ¶
func NewAuthCodeToken(code, refreshToken, redirectURI string) (*AuthCodeToken, error)
NewAuthCodeToken issues new access tokens for the Authorization Code flow. It searches for 'code' in the Redis cache and throws errors if not found. If found, it checks if it has crossed is expiry limit which is 10 minutes. If crossed, an error is thrown. Else a new token is generated and returned. Refer RFC 6749 Section 4.1.2 (https://tools.ietf.org/html/rfc6749#section-4.1.2)
type ClientCredentialsToken ¶
type ClientCredentialsToken struct { AccessToken string `json:"access_token"` ExpiresIn int `json:"expires_in"` }
ClientCredentialsToken represents a token issued by the Resource Owner Password Credentials flow https://tools.ietf.org/html/rfc6749#section-4.3.3
func NewClientCredsToken ¶
func NewClientCredsToken() (*ClientCredentialsToken, error)
NewClientCredsToken issues new access tokens for the Client Credentials flow. It generates and stores a token and stores it along with its meta data in the Redis cache.
type ImplicitToken ¶
type ImplicitToken struct { AccessToken string `json:"access_token"` ExpiresIn int `json:"expires_in"` }
ImplicitToken represents a token issued by the Implicit Grant flow https://tools.ietf.org/html/rfc6749#section-4.2.2
func NewImplicitToken ¶
func NewImplicitToken() (*ImplicitToken, error)
NewImplicitToken issues new access tokens for the Implicit Grant flow. It generates and stores a token and stores it along with its meta data in the Redis cache.
type ROPCToken ¶
type ROPCToken struct { AccessToken string `json:"access_token"` RefreshToken string `json:"refresh_token"` ExpiresIn int `json:"expires_in"` }
ROPCToken represents a token issued by the Resource Owner Password Credentials flow https://tools.ietf.org/html/rfc6749#section-4.3.3
func NewROPCRefreshToken ¶
NewROPCRefreshToken returns new token for the previously issued refresh token The refresh token is kept intact and can be used for future requests.
func NewROPCToken ¶
NewROPCToken issues new access and refresh tokens for the ROPC flow. It generates and stores a token and stores it along with its meta data in the Redis cache.