accounts

package
v0.0.0-...-c966403 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ObjectKind    = "Account"
	ObjectGroup   = "hz-internal"
	ObjectVersion = "v1"
)

Variables

View Source
var ErrAccountNotFound = errors.New("account not found")

Functions

func AccountClaimsLookup

func AccountClaimsLookup(
	ctx context.Context,
	nc *nats.Conn,
	accountPublicKey string,
) (*jwt.AccountClaims, error)

func AccountClaimsUpdate

func AccountClaimsUpdate(
	ctx context.Context,
	nc *nats.Conn,
	operatorKeyPair nkeys.KeyPair,
	accountJWT string,
) (string, error)

func AccountJWTUpdate

func AccountJWTUpdate(
	ctx context.Context,
	nc *nats.Conn,
	accJWT string,
) (string, error)

Types

type Account

type Account struct {
	hz.ObjectMeta `json:"metadata,omitempty" cue:""`

	Spec   *AccountSpec   `json:"spec,omitempty"`
	Status *AccountStatus `json:"status,omitempty"`
}

func (Account) ObjectGroup

func (a Account) ObjectGroup() string

func (Account) ObjectKind

func (a Account) ObjectKind() string

func (Account) ObjectVersion

func (a Account) ObjectVersion() string

type AccountReconciler

type AccountReconciler struct {
	hz.Client
	Conn *nats.Conn

	OpKeyPair         nkeys.KeyPair
	RootAccountPubKey string
}

func (*AccountReconciler) CreateAccount

func (r *AccountReconciler) CreateAccount(
	name string,
) (*AccountStatus, error)

func (*AccountReconciler) Reconcile

func (r *AccountReconciler) Reconcile(
	ctx context.Context,
	req hz.Request,
) (hz.Result, error)

Reconcile implements hz.Reconciler.

type AccountSpec

type AccountSpec struct{}

type AccountStatus

type AccountStatus struct {
	Ready bool `json:"ready"`
	// ID of the account, which for NATS is the public key of the account
	// and the subject of the account's JWT.
	ID string `json:"id,omitempty"`
	// Seed of the account.
	// The "seed" can be converted into the account public
	// and private keys.
	Seed string `json:"seed,omitempty"`
	// SigningKeySeed is the seed of the account signing key.
	// The account signing key should be used for signing all the user JWTs
	// (credentials) for the account.
	SigningKeySeed string `json:"signing_key_seed,omitempty"`
	JWT            string `json:"jwt,omitempty" cue:",opt"`
}

type GroupRef

type GroupRef struct {
	Name *string `json:"name,omitempty" cue:""`
}

type Member

type Member struct {
	hz.ObjectMeta `json:"metadata,omitempty"`

	Spec MemberSpec `json:"spec,omitempty" cue:""`
}

func (Member) ObjectGroup

func (Member) ObjectGroup() string

func (Member) ObjectKind

func (Member) ObjectKind() string

func (Member) ObjectVersion

func (Member) ObjectVersion() string

type MemberSpec

type MemberSpec struct {
	GroupRef *GroupRef `json:"groupRef,omitempty" cue:""`
	UserRef  *UserRef  `json:"userRef,omitempty" cue:""`
}

type User

type User struct {
	hz.ObjectMeta `json:"metadata"`

	Spec   UserSpec   `json:"spec"`
	Status UserStatus `json:"status"`
}

User represents a NATS user.

func (User) ObjectGroup

func (u User) ObjectGroup() string

func (User) ObjectKind

func (u User) ObjectKind() string

func (User) ObjectVersion

func (u User) ObjectVersion() string

type UserClaims

type UserClaims struct {
	Sub     *string  `json:"sub,omitempty" cue:""`
	Iss     *string  `json:"iss,omitempty" cue:""`
	Name    *string  `json:"name,omitempty" cue:""`
	Email   *string  `json:"email,omitempty" cue:""`
	Groups  []string `json:"groups,omitempty"`
	Picture *string  `json:"picture,omitempty"`
}

type UserCreateAction

type UserCreateAction struct {
	hz.Client
}

func (*UserCreateAction) Action

func (a *UserCreateAction) Action() string

Action implements hz.Action.

func (*UserCreateAction) Do

func (a *UserCreateAction) Do(ctx context.Context, user User) (User, error)

Do implements hz.Action.

type UserRef

type UserRef struct {
	Name *string `json:"name,omitempty" cue:""`
}

type UserSpec

type UserSpec struct {
	Claims *UserClaims `json:"claims,omitempty" cue:""`
}

type UserStatus

type UserStatus struct {
	// ID of the user, which for NATS is the public key.
	ID string `json:"id"`
	// Seed of the user.
	// The Seed (or "seed") can be converted into the user public
	// and private keys. The public key must match the user ID.
	Seed string `json:"nkey"`
	// JWT of the user.
	// The JWT contains the user claims (i.e. name, config, limits, etc.)
	// and is signed using an account NKey.
	JWT string `json:"jwt"`
}

Jump to

Keyboard shortcuts

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