verifier

package module
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2024 License: MIT Imports: 7 Imported by: 0

README

okta-jwt-verifier

Test GoDoc Go Report

Alternative implementation to the official okta-jwt-verifier that includes support for telemetry (ie. OpenTelemetry), minimizing verification latency, and testability.

Examples

Access Token Validation
import (
    "context"
    verifier "github.com/sovietaced/okta-jwt-verifier"
)

func main() {
    ctx := context.Background()
    issuer := "https://test.okta.com"
    clientId := "test"
    v, err := verifier.NewVerifier(issuer)
	

    idToken := "..."
    token, err := v.VerifyIdToken(ctx, idToken)
	
	accessToken := "..."
	token, err = v.VerifyAccessToken(ctx, accessToken)
}

Documentation

Index

Constants

View Source
const (
	DefaultLeeway = 0 // Default leeway that is configured for JWT validation
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Jwt added in v0.3.0

type Jwt struct {
	Claims map[string]any
}

Jwt is an implementation independent representation of a JWT that is returned to consumers of our APIs.

type Option

type Option func(*Options)

Option for the Verifier

func WithKeyfuncProvider

func WithKeyfuncProvider(keyfuncProvider keyfunc.Provider) Option

WithKeyfuncProvider allows for a configurable keyfunc.Provider, which may be useful if you want to customize the behavior of how metadata or JWK sets are fetched.

func WithLeeway added in v0.4.0

func WithLeeway(leeway time.Duration) Option

WithLeeway adds leeway to all time related validations.

type Options

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

Options are configurable options for the Verifier.

type Verifier

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

Verifier is the implementation of the Okta JWT verification logic.

func NewVerifier

func NewVerifier(issuer string, options ...Option) (*Verifier, error)

NewVerifier creates a new Verifier for the specified issuer.

func (*Verifier) VerifyAccessToken added in v0.1.1

func (v *Verifier) VerifyAccessToken(ctx context.Context, accessToken string) (*Jwt, error)

VerifyAccessToken verifies an Okta access token.

func (*Verifier) VerifyIdToken

func (v *Verifier) VerifyIdToken(ctx context.Context, idToken string) (*Jwt, error)

VerifyIdToken verifies an Okta ID token.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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