auth

package
v0.0.0-...-90b39c7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 26, 2018 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package auth handles the creation of an Auth Provider and its routes.

Index

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

type TokenProvider struct {
	Name       string
	SigningKey []byte
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL