validator

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2017 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultMaxCacheMemory is the default amount of memory (in MB) to allocate to the cache
	DefaultMaxCacheMemory = 1024
	// DefaultCacheDuration is the default life of a cache entry
	DefaultCacheDuration = 1 * time.Hour
	// DefaultIssuerURL is the default URL for Okta
	DefaultIssuerURL = "https://example.oktapreview.com"
	// DefaultUsernameClaim is the default claim used to obtain the username
	DefaultUsernameClaim = "email"
	// DefaultGroupsClaim is the default claim used to obtain the groups
	DefaultGroupsClaim = "groups"
)

Variables

View Source
var (
	// ErrorClaimNotFound indicates the given key was not found in the claims
	ErrorClaimNotFound = fmt.Errorf("Claim not found")
	// ErrorInvalidToken means we were unable to validate a given token
	ErrorInvalidToken = fmt.Errorf("Invalid token")
)

Functions

This section is empty.

Types

type Option

type Option func(*Validator) error

Option represents an option for Validator. This returns an error in case we want to do more advanced option stuff in the future

func CacheExpiry

func CacheExpiry(expiry time.Duration) Option

CacheExpiry sets the max cache size

func CacheSize

func CacheSize(maxCacheSize int) Option

CacheSize sets the max cache size

func ClientID

func ClientID(clientID string) Option

ClientID sets the OIDC issuer URL

func GraphGetter

func GraphGetter(clientID, clientSecret, tenantName string) Option

GraphGetter takes a client ID and secret to log in to the MS Graph API for additional user information

func GroupsClaim

func GroupsClaim(group string) Option

GroupsClaim sets a group claim for a validator

func IssuerURL

func IssuerURL(issuerURL string) Option

IssuerURL sets the OIDC issuer URL

func UsernameClaim

func UsernameClaim(username string) Option

UsernameClaim sets a username claim for a validator

type Validator

type Validator struct {
	// contains filtered or unexported fields
}

Validator is used to validate an ID token and cache group responses

func New

func New(options ...Option) (*Validator, error)

New creates a new validator object

func (*Validator) Validate

Validate takes a TokenReview request with the Token field set and validates the token. It returns a fully populated TokenReview request with all user information or an error if there was a validation error. This also requires a context to be passed (generally that of the request)

Jump to

Keyboard shortcuts

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