perms

package
v0.20.4-test4 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: Apache-2.0 Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultPerms   = []auth.Permission{"public"}
	ReadPerms      = []auth.Permission{"public", "read"}
	ReadWritePerms = []auth.Permission{"public", "read", "write"}
	AllPerms       = []auth.Permission{"public", "read", "write", "admin"}
)
View Source
var AuthKey = "Authorization"

Functions

func NewTokenWithPerms

func NewTokenWithPerms(signer jwt.Signer, perms []auth.Permission) ([]byte, error)

NewTokenWithPerms generates and signs a new JWT token with the given secret and given permissions.

func NewTokenWithTTL added in v0.20.4

func NewTokenWithTTL(signer jwt.Signer, perms []auth.Permission, ttl time.Duration) ([]byte, error)

NewTokenWithTTL generates and signs a new JWT token with the given secret and given permissions and TTL.

Types

type JWTPayload

type JWTPayload struct {
	Allow     []auth.Permission
	Nonce     []byte
	ExpiresAt time.Time
}

JWTPayload is a utility struct for marshaling/unmarshalling permissions into for token signing/verifying.

func (*JWTPayload) MarshalBinary

func (j *JWTPayload) MarshalBinary() (data []byte, err error)

Jump to

Keyboard shortcuts

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