natsauth

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: 18 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 natsauth makes the authentication of a NATS setup for osapi: a credential for each osapi role, with the least permissions of the role, and the server's part. osapi makes each secret, and writes each one to a file of mode 0600. Nothing takes a secret on the command line.

Index

Constants

View Source
const AccountPubFile = "account.pub"

AccountPubFile is the file of the account's public key (A...), beside the signing keys, that Operator writes.

View Source
const OsapiConfig = "osapi-nats.yaml"

OsapiConfig is the file of the osapi config that a create writes: the part of the config that uses the credentials, to merge into osapi.yaml.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	Role string
	Path string
}

File is a file that a create wrote.

type Result

type Result struct {
	Files  []File
	Server string
}

Result is what a create wrote, and the server's part: the config that a NATS server that osapi does not run needs.

func NKey

func NKey(
	ctx context.Context,
	fs avfs.VFS,
	dir string,
	namespace string,
	cfg config.NATS,
) (Result, error)

NKey makes an nkey for each osapi role that keeps a credential: setup, controller and agent. It writes the seed of each, osapi-nats.yaml with the nkeys of the embedded server and their roles, and the authorization block of a NATS server that osapi does not run. The join's bootstrap user is not an nkey: a join string carries a password or a JWT.

func Operator

func Operator(
	ctx context.Context,
	fs avfs.VFS,
	dir string,
	namespace string,
	cfg config.NATS,
) (Result, error)

Operator makes an operator, its system account, and an account for osapi with JetStream and a signing key: the resolver file of the server, a credentials file for each osapi role, and the signing key that the controller mints the users of a join with.

func Password

func Password(
	ctx context.Context,
	fs avfs.VFS,
	dir string,
	namespace string,
	cfg config.NATS,
) (Result, error)

Password makes a user and a random password for each osapi role, with the join's bootstrap user: the users of osapi's embedded server, and the authorization block of a server that osapi does not run.

func UpdateOperator

func UpdateOperator(
	ctx context.Context,
	fs avfs.VFS,
	dir string,
	namespace string,
	cfg config.NATS,
) (Result, error)

UpdateOperator signs the account of osapi and the credentials of each osapi role again, in dir, with the permissions that each role has now and with the keys that Operator made there. A version of osapi that adds a permission to a role needs it: the account's JWT holds the agent's permissions as the template of its scoped signing key, and each credentials file holds the permissions of its role. The keys do not change, so each agent keeps its user and no agent joins again. The NATS server reads the new resolver file at its next start.

Jump to

Keyboard shortcuts

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