Documentation ¶
Overview ¶
Package auth handles the creation of an Auth Provider and its routes.
Index ¶
- func IntrospectToken(tp TokenProvider, store datastore.Store) http.HandlerFunc
- func IssueToken(tp TokenProvider, store AuthStore) http.HandlerFunc
- func NewRouter(ds AuthStore, tp TokenProvider) http.Handler
- func RenderJSON(w http.ResponseWriter, status int, headers map[string]string, ...)
- type AuthStore
- type TokenProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IntrospectToken ¶
func IntrospectToken(tp TokenProvider, store datastore.Store) http.HandlerFunc
IntrospectToken verifies the validity of a token and writes its claims.
func IssueToken ¶
func IssueToken(tp TokenProvider, store AuthStore) http.HandlerFunc
IssueToken is a HTTP endpoint that handles authentication and issuing of JWT tokens.
func NewRouter ¶
func NewRouter(ds AuthStore, tp TokenProvider) http.Handler
NewRouter creates and configures all routes for the parameter authentication provider.
func RenderJSON ¶
func RenderJSON(w http.ResponseWriter, status int, headers map[string]string, payload interface{})
Types ¶
type AuthStore ¶
type AuthStore interface { model.UserStorer model.ProjectClientStorer Ping() error Close() error }
AuthStore is the interface that an Auth Provider implementation requires to retrieve and validate credentials in order to issue a token.
type TokenProvider ¶
TokenProvider holds the Auth Provider's name and Signing Key.
func (*TokenProvider) CreateToken ¶
func (p *TokenProvider) CreateToken(claims jwt.Claims) (string, error)
CreateToken creates a new token with the provided claims and signs it.
func (*TokenProvider) ParseAndExtractClaims ¶
func (p *TokenProvider) ParseAndExtractClaims(tokenString string) (jwt.MapClaims, error)
ParseAndExtractClaims parses the claims of the token and its signature without validating the claims. It returns the claims or an error.
func (*TokenProvider) ParseAndVerifyToken ¶
func (p *TokenProvider) ParseAndVerifyToken(tokenString string) (jwt.MapClaims, error)
ParseAndVerifyToken parses, verifies and validates the claims of the token. It returns the claims or an error if the token is not valid or if something went wrong.