role

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package role represents the processing logic of role token.

Index

Constants

View Source
const (
	CONFIRM_METHOD_MEMBER = "x5t#S256"
)

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 BaseClaim added in v2.2.0

type BaseClaim struct {
	jwt.StandardClaims
}

func (*BaseClaim) Valid added in v2.2.0

func (c *BaseClaim) Valid() error

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

type Option

type Option func(*rtp) error

Option represents a functional options pattern interface

func WithClientCertificateGoBackSeconds added in v2.2.0

func WithClientCertificateGoBackSeconds(t string) Option

WithClientCertificateGoBackSeconds represents set clientCertificateGoBackSeconds functional option

func WithClientCertificateOffsetSeconds added in v2.2.0

func WithClientCertificateOffsetSeconds(t string) Option

WithClientCertificateOffsetSeconds represents set clientCertificateOffsetSeconds functional option

func WithEnableMTLSCertificateBoundAccessToken added in v2.2.0

func WithEnableMTLSCertificateBoundAccessToken(b bool) Option

WithEnableMTLSCertificateBoundAccessToken represents set enableMTLSCertificateBoundAccessToken functional option

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) (*RoleJWTClaim, error)
	ParseAndValidateZTSAccessToken(cred string, cert *x509.Certificate) (*ZTSAccessTokenClaim, error)
}

Processor represents the role token parser interface.

func New

func New(opts ...Option) (Processor, error)

New returns the Role instance.

type RoleJWTClaim added in v2.2.0

type RoleJWTClaim 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"`
	BaseClaim
}

RoleJWTClaim represents role jwt claim data.

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.

type ZTSAccessTokenClaim added in v2.2.0

type ZTSAccessTokenClaim struct {
	AuthTime       int64             `json:"auth_time"`
	Version        int               `json:"ver"`
	ClientID       string            `json:"client_id"`
	UserID         string            `json:"uid"`
	ProxyPrincipal string            `json:"proxy,omitempty"`
	Scope          []string          `json:"scp"`
	Confirm        map[string]string `json:"cnf"`
	BaseClaim
}

ZTSAccessTokenClaim represents access token claim data. based on https://github.com/yahoo/athenz/blob/0e7335dbfa9d41eef0b049c07e7f846bff0f3169/libs/java/auth_core/src/main/java/com/yahoo/athenz/auth/token/AccessToken.java#L382

Jump to

Keyboard shortcuts

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