gobears

package module
v0.0.0-...-99319b4 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2019 License: MIT Imports: 11 Imported by: 0

README

gobears

Bearer token authentication handler for Go

This is a prototype/work in progress of a http handler that will inspect a Bearer token from the header, verify against specified scopes, and verify the signature by fetching and using the auth provider's signing key.

Documentation

Index

Constants

View Source
const ClaimsKey = "claims"

ClaimsKey is the key into the http context for retrieving claims

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth struct {
	Issuer          string
	RequiredScopes  []string
	CustomValidator func(*Claims) error
	// contains filtered or unexported fields
}

Auth implements http middleware for parsing and verifying oauth2 bearer tokens

func New

func New(issuer string, requiredScopes []string, signingKeyCacheLifeSpan time.Duration) *Auth

New create a new Auth with the provided parameters

func (*Auth) WithBearerToken

func (j *Auth) WithBearerToken(next http.HandlerFunc) http.HandlerFunc

WithBearerToken is a middleware implementation that will look for a bearer token, parsie it, and verify it. If sussessful, the resulting Claims will be dropped into the request context as "claims"

type Claims

type Claims struct {
	jwt.StandardClaims
	Scopes []string `json:"scope,omitempty"`
}

Claims are an extension fo the jwt.StandardClaims

type ClaimsType

type ClaimsType string

ClaimsType is a wrapper type for storing values in the http.Request context

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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