natsjwt

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package natsjwt mints the NATS user JWTs of osapi in operator mode: the bootstrap user of a join token, and the user of an agent that joined. It signs them with an account signing key that the NATS administrator gives the controller.

Index

Constants

This section is empty.

Variables

View Source
var ErrSigningKey = errors.New("the signing key file holds no account seed (SA...)")

ErrSigningKey is a signing key file that holds no account seed.

Functions

func Creds

func Creds(
	userJWT string,
	seed []byte,
) ([]byte, error)

Creds is the credentials file of a user: its JWT and its seed.

func NewUser

func NewUser() (seed []byte, public string, err error)

NewUser is a new user nkey: its seed, which stays with its owner, and its public key, which a JWT names.

Types

type Signer

type Signer struct {
	// contains filtered or unexported fields
}

Signer mints user JWTs for one account with one of its signing keys.

func Load

func Load(
	file string,
	account string,
) (*Signer, error)

Load is the signer of the account signing key seed in file, for the account with public key account. The key can be the account's own key or one of its signing keys.

func NewSigner

func NewSigner(
	key nkeys.KeyPair,
	account string,
) *Signer

NewSigner is the signer of key, a signing key of the account with public key account.

func (*Signer) Mint

func (s *Signer) Mint(
	userKey string,
	name string,
	p bus.Permissions,
	expires time.Time,
) (string, error)

Mint is a user JWT for the user nkey userKey, named name, with the permissions p, that expires at expires, or never when it is zero.

func (*Signer) NewCreds

func (s *Signer) NewCreds(
	name string,
	p bus.Permissions,
	expires time.Time,
) ([]byte, error)

NewCreds are the credentials of a new user, named name, with the permissions p, that expire at expires: its JWT and its seed, for a user whose seed osapi hands over, such as the bootstrap user of a join token.

Jump to

Keyboard shortcuts

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