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
- type File
- type Result
- func NKey(ctx context.Context, fs avfs.VFS, dir string, namespace string, ...) (Result, error)
- func Operator(ctx context.Context, fs avfs.VFS, dir string, namespace string, ...) (Result, error)
- func Password(ctx context.Context, fs avfs.VFS, dir string, namespace string, ...) (Result, error)
- func UpdateOperator(ctx context.Context, fs avfs.VFS, dir string, namespace string, ...) (Result, error)
Constants ¶
const AccountPubFile = "account.pub"
AccountPubFile is the file of the account's public key (A...), beside the signing keys, that Operator writes.
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 Result ¶
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.