token

package
v0.0.0-...-284eadf Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2017 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package token is used to manage the creation and validation of the credentials used for authenthication.

Index

Constants

View Source
const (
	ServiceAccountID = "8f558668-4db7-4280-8e65-408bcb95f9d9"
)

Variables

This section is empty.

Functions

func CheckClaims

func CheckClaims(claims *TokenClaims) error

CheckClaims checks if all the required claims are present in the access token

func EncodeToken

func EncodeToken(ctx context.Context, referrer *url.URL, outhToken *oauth2.Token) error

EncodeToken encodes token

func NumberToInt

func NumberToInt(number interface{}) (int64, error)

NumberToInt convert interface{} to int64

func ReadManagerFromContext

func ReadManagerFromContext(ctx context.Context) (*tokenManager, error)

ReadManagerFromContext extracts the token manager

Types

type AuthorizationPayload

type AuthorizationPayload struct {
	Permissions []Permissions `json:"permissions"`
}

AuthorizationPayload represents an authz payload in the rpt token

type JsonKeys

type JsonKeys struct {
	Keys []interface{} `json:"keys"`
}

type Manager

type Manager interface {
	Locate(ctx context.Context) (uuid.UUID, error)
	ParseToken(ctx context.Context, tokenString string) (*TokenClaims, error)
	ParseTokenWithMapClaims(ctx context.Context, tokenString string) (jwt.MapClaims, error)
	PublicKey(keyID string) *rsa.PublicKey
	PublicKeys() []*rsa.PublicKey
	JsonWebKeys() JsonKeys
	PemKeys() JsonKeys
	ServiceAccountToken(req *goa.RequestData) (string, error)
}

Manager generate and find auth token information

func NewManager

func NewManager(config configuration) (Manager, error)

NewManager returns a new token Manager for handling tokens

func NewManagerWithPublicKey

func NewManagerWithPublicKey(id string, key *rsa.PublicKey) Manager

NewManagerWithPublicKey returns a new token Manager for handling tokens with the only public key

type Permissions

type Permissions struct {
	ResourceSetName *string `json:"resource_set_name"`
	ResourceSetID   *string `json:"resource_set_id"`
}

Permissions represents a "permissions" in the AuthorizationPayload

type PrivateKey

type PrivateKey struct {
	KeyID string
	Key   *rsa.PrivateKey
}

PrivateKey represents an RSA private key with a Key ID

type PublicKey

type PublicKey struct {
	KeyID string
	Key   *rsa.PublicKey
}

func FetchKeys

func FetchKeys(keysEndpointURL string) ([]*PublicKey, error)

FetchKeys fetches public JSON WEB Keys from a remote service

type TokenClaims

type TokenClaims struct {
	Name          string                `json:"name"`
	Username      string                `json:"preferred_username"`
	GivenName     string                `json:"given_name"`
	FamilyName    string                `json:"family_name"`
	Email         string                `json:"email"`
	Company       string                `json:"company"`
	SessionState  string                `json:"session_state"`
	Approved      bool                  `json:"approved"`
	Authorization *AuthorizationPayload `json:"authorization"`
	jwt.StandardClaims
}

TokenClaims represents access token claims

Jump to

Keyboard shortcuts

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