token

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2024 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StringType map[string]Type = map[string]Type{
	"server_cert":        TokenServerCert,
	"client_cert":        TokenClientCert,
	"client_server_cert": TokenClientServerCert,
	"parent":             TokenParent,
}
View Source
var TypePrefix map[Type]string = map[Type]string{
	TokenRoot:             "ro",
	TokenParent:           "pa",
	TokenServerCert:       "sc",
	TokenClientCert:       "cc",
	TokenClientServerCert: "cs",
}
View Source
var TypeString map[Type]string = map[Type]string{
	TokenRoot:             "root",
	TokenParent:           "Parent",
	TokenServerCert:       "server_cert",
	TokenClientCert:       "client_cert",
	TokenClientServerCert: "client_server_cert",
}

Functions

This section is empty.

Types

type CreateStruct

type CreateStruct struct {
	Type      string            `json:"type" example:"client_cert"`
	Policies  []string          `json:"Policies" example:"policy1,policy2"`
	Meta      map[string]string `json:"meta" example:"key1:value1,key2:value2"`
	TTL       string            `json:"ttl" example:"1000h"`
	MaxTTL    string            `json:"maxttl" example:"3h"`
	Renewable bool              `json:"renewable" example:"false"`
}

type Manager

type Manager struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewManager

func NewManager(store Store, xor uint64, tokenMaxTTL time.Duration, certMaxTTL time.Duration, parentMaxTTL time.Duration, rndSize int) *Manager

func (*Manager) Create

func (m *Manager) Create(parent string, options *CreateStruct) (string, error)

func (*Manager) Delete

func (m *Manager) Delete(name string) error

func (*Manager) Get

func (m *Manager) Get(name string) (*Token, error)

type Store

type Store interface {
	io.Closer
	Get(ctx context.Context, tokenID string) ([]byte, error)
	Put(ctx context.Context, tokenID string, token []byte, ttl time.Duration) error
	Delete(ctx context.Context, tokenID string) error
}

type Token

type Token struct {
	T          Type
	Expiration time.Time
	Policies   []string
	Parent     string
	Metadata   map[string]string
	MaxTTL     time.Duration
}

func NewToken

func NewToken(t Type, expiration time.Time, maxTTL time.Duration, policies []string, meta map[string]string) *Token

func (*Token) GetExpiration

func (t *Token) GetExpiration() time.Time

func (*Token) GetMetadata

func (t *Token) GetMetadata() map[string]string

func (*Token) GetParent

func (t *Token) GetParent() string

func (*Token) GetPolicies

func (t *Token) GetPolicies() []string

func (*Token) GetType

func (t *Token) GetType() Type

func (*Token) MarshalBinary

func (t *Token) MarshalBinary() ([]byte, error)

func (*Token) UnmarshalBinary

func (t *Token) UnmarshalBinary(data []byte) error

type Type

type Type uint16
const (
	TokenRoot Type = iota
	TokenParent
	TokenServerCert
	TokenClientCert
	TokenClientServerCert
)

Jump to

Keyboard shortcuts

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