role

package
v2.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package role represents the processing logic of role token.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrRoleTokenInvalid "Access denied due to invalid RoleToken"
	ErrRoleTokenInvalid = errors.New("Access denied due to invalid RoleToken")

	// ErrRoleTokenExpired "Access denied due to expired RoleToken"
	ErrRoleTokenExpired = errors.New("Access denied due to expired RoleToken")
)

Functions

This section is empty.

Types

type Claim

type Claim struct {
	Domain   string `json:"d"`
	Email    string `json:"email"`
	KeyID    string `json:"k"`
	MFA      string `json:"mfa"`
	Role     string `json:"r"`
	Salt     string `json:"a"`
	UserID   string `json:"u"`
	UserName string `json:"n"`
	Version  string `json:"v"`
	jwt.StandardClaims
}

Claim represents role jwt claim data.

func (*Claim) Valid

func (c *Claim) Valid() error

Valid is copy from source code, and changed c.VerifyExpiresAt parameter.

type Option

type Option func(*rtp)

Option represents a functional options pattern interface

func WithJWKProvider

func WithJWKProvider(jwkp jwk.Provider) Option

WithJWKProvider represents set pubkey provider functional option

func WithPubkeyProvider

func WithPubkeyProvider(pkp pubkey.Provider) Option

WithPubkeyProvider represents set pubkey provider functional option

type Processor

type Processor interface {
	ParseAndValidateRoleToken(tok string) (*Token, error)
	ParseAndValidateRoleJWT(cred string) (*Claim, error)
}

Processor represents the role token parser interface.

func New

func New(opts ...Option) Processor

New returns the Role instance.

type Token

type Token struct {
	// Version    string   // required
	Domain string   // required
	Roles  []string // required
	// Principal  string   // required
	// Host       string
	// Salt       string    // required
	// TimeStamp  time.Time // required
	ExpiryTime time.Time // required
	KeyID      string    // required
	// IP         string
	// ProxyUser  string
	Signature string // required

	UnsignedToken string
}

Token represents role token data.

func (*Token) Expired

func (r *Token) Expired() bool

Expired returns if the role token is expired or not.

func (*Token) SetParams

func (r *Token) SetParams(key, value string) error

SetParams sets the value for corresponding key data.

Jump to

Keyboard shortcuts

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