Versions in this module Expand all Collapse all v0 v0.1.0 Sep 13, 2021 Changes in this version + const AccessTokenContext + const ClaimsContext + const CredentialContext + const ScopeContext + const TokenTypeContext + func Authorize(secretKey string, formatter TokenSecureFormatter) func(next http.Handler) http.Handler + func CheckBasicAuthentication(username, password string, r *http.Request) error + func GetBasicAuthentication(r *http.Request) (username, password string, err error) + type AuthorizationCodeVerifier interface + ValidateCode func(clientID, clientSecret, code, redirectURI string, r *http.Request) (string, error) + type BearerAuthentication struct + func NewBearerAuthentication(secretKey string, formatter TokenSecureFormatter) *BearerAuthentication + func (ba *BearerAuthentication) Authorize(next http.Handler) http.Handler + type BearerServer struct + TokenTTL time.Duration + func NewBearerServer(secretKey string, ttl time.Duration, verifier CredentialsVerifier, ...) *BearerServer + func (bs *BearerServer) AuthorizationCode(w http.ResponseWriter, r *http.Request) + func (bs *BearerServer) ClientCredentials(w http.ResponseWriter, r *http.Request) + func (bs *BearerServer) UserCredentials(w http.ResponseWriter, r *http.Request) + type CredentialsVerifier interface + AddClaims func(tokenType TokenType, credential, tokenID, scope string, r *http.Request) (map[string]string, error) + AddProperties func(tokenType TokenType, credential, tokenID, scope string, r *http.Request) (map[string]string, error) + StoreTokenID func(tokenType TokenType, credential, tokenID, refreshTokenID string) error + ValidateClient func(clientID, clientSecret, scope string, r *http.Request) error + ValidateTokenID func(tokenType TokenType, credential, tokenID, refreshTokenID string) error + ValidateUser func(username, password, scope string, r *http.Request) error + type GrantType string + const AuthCodeGrant + const ClientCredentialsGrant + const PasswordGrant + const RefreshTokenGrant + type RC4TokenSecureFormatter struct + func NewRC4TokenSecurityProvider(key []byte) *RC4TokenSecureFormatter + func (sc *RC4TokenSecureFormatter) CryptToken(source []byte) ([]byte, error) + func (sc *RC4TokenSecureFormatter) DecryptToken(source []byte) ([]byte, error) + type RefreshToken struct + CreationDate time.Time + Credential string + RefreshTokenID string + Scope string + TokenID string + TokenType TokenType + type SHA256RC4TokenSecureFormatter struct + func NewSHA256RC4TokenSecurityProvider(key []byte) *SHA256RC4TokenSecureFormatter + func (sc *SHA256RC4TokenSecureFormatter) CryptToken(source []byte) ([]byte, error) + func (sc *SHA256RC4TokenSecureFormatter) DecryptToken(source []byte) ([]byte, error) + type Token struct + Claims map[string]string + CreationDate time.Time + Credential string + ExpiresIn time.Duration + ID string + Scope string + TokenType TokenType + type TokenProvider struct + func NewTokenProvider(formatter TokenSecureFormatter) *TokenProvider + func (tp *TokenProvider) CryptRefreshToken(t *RefreshToken) (token string, err error) + func (tp *TokenProvider) CryptToken(t *Token) (token string, err error) + func (tp *TokenProvider) DecryptRefreshTokens(refreshToken string) (refresh *RefreshToken, err error) + func (tp *TokenProvider) DecryptToken(token string) (t *Token, err error) + type TokenResponse struct + ExpiresIn int64 + Properties map[string]string + RefreshToken string + Token string + TokenType TokenType + type TokenSecureFormatter interface + CryptToken func(source []byte) ([]byte, error) + DecryptToken func(source []byte) ([]byte, error) + type TokenType string + const AuthToken + const BearerToken + const ClientToken + const UserToken