tok

package
v1.3.25 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package tok provides AuthN token (structure and methods) for validation by AIS gateways

  • Copyright (c) 2018-2022, NVIDIA CORPORATION. All rights reserved.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoPermissions = errors.New("insufficient permissions")
	ErrInvalidToken  = errors.New("invalid token")
	ErrNoToken       = errors.New("token required")
	ErrNoBearerToken = errors.New("invalid token: no bearer")
	ErrTokenExpired  = errors.New("token expired")
	ErrTokenRevoked  = errors.New("token revoked")
)

Functions

func AdminJWT added in v1.3.24

func AdminJWT(expires time.Time, userID, secret string) (string, error)

func ExtractToken

func ExtractToken(hdr http.Header) (string, error)

Header format: 'Authorization: Bearer <token>'

func JWT added in v1.3.24

func JWT(expires time.Time, userID string, bucketACLs []*authn.BckACL, clusterACLs []*authn.CluACL,
	secret string) (string, error)

Types

type Token

type Token struct {
	UserID      string          `json:"username"`
	Expires     time.Time       `json:"expires"`
	Token       string          `json:"token"`
	ClusterACLs []*authn.CluACL `json:"clusters"`
	BucketACLs  []*authn.BckACL `json:"buckets,omitempty"`
	IsAdmin     bool            `json:"admin"`
}

func DecryptToken

func DecryptToken(tokenStr, secret string) (*Token, error)

func (*Token) CheckPermissions

func (tk *Token) CheckPermissions(clusterID string, bck *cmn.Bck, perms apc.AccessAttrs) error

func (*Token) String

func (tk *Token) String() string

Jump to

Keyboard shortcuts

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