Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthEntity ¶
type AuthEntity struct { NKey // JWT is the JWT for the entity, signed with the KeyPair. JWT string `json:"jwt"` SigningKey *NKey `json:"signing_key,omitempty"` }
AuthEntity is an entity that can be authenticated by the NATS server using JWT.
func (*AuthEntity) LoadNKey ¶
func (a *AuthEntity) LoadNKey() error
type NKey ¶
type NKey struct { // Seed contains the public and private key in base32. // The KeyPair can be extracted from the seed, and used to sign JWTs. // Warning: keep this secure!! Seed string `json:"seed"` KeyPair nkeys.KeyPair `json:"-"` // PublicKey is used to identify the entity. // It acts like an ID in NATS. PublicKey string `json:"public_key"` }
func NewAccountNKey ¶
func NewOperatorNKey ¶
func NewUserNKey ¶
type Server ¶
type Server struct { NS *server.Server Auth ServerJWTAuth }
func NewServer ¶
func NewServer(opts ...ServerOption) (Server, error)
func (Server) PublishRootNamespace ¶
PublishRootNamespace publishes the root account JWT to the server. This is required to be able to connect to the server with the root account and therefore needs to happen once the server has been started.
func (Server) RootUserConn ¶
RootUserConn uses the root user JWT to connect to the server.
func (Server) StartUntilReady ¶
type ServerConfig ¶
type ServerJWTAuth ¶
type ServerJWTAuth struct { // AccountServerURL is the configured `account_server_url` for the operator AccountServerURL string `json:"account_server_url"` Operator AuthEntity `json:"operator"` // SysAccount is the NATS system account. // It should not be needed outside of bootstrapping. SysAccount AuthEntity `json:"sys_account"` // SysUser is a user that has access to the the NATS system account. // It should not be needed outside of bootstrapping. SysUser AuthEntity `json:"sys_user"` // RootAccount is the Horizon root account. // The root account is where all the data is stored. RootAccount AuthEntity `json:"root_account"` // RootUser is a user that has access to the the Horizon root account. // It should not be needed outside of bootstrapping. RootUser AuthEntity `json:"root_user"` }
func BootstrapServerJWTAuth ¶
func BootstrapServerJWTAuth() (ServerJWTAuth, error)
func LoadServerJWTAuth ¶
func LoadServerJWTAuth(file string) (ServerJWTAuth, error)
LoadServerJWTAuth loads the ServerJWTAuth from the given file. This method is intended to use for testing controllers/actors or other services with a local running instance of the horizon server.
For other use cases, you should create nats credentials via the horizon server and provide those to the services you need to connect to NATS/Horizon.
func (*ServerJWTAuth) LoadKeyPairs ¶
func (s *ServerJWTAuth) LoadKeyPairs() error
type ServerOption ¶
type ServerOption func(*serverOption)
func WithConfigureLogger ¶
func WithConfigureLogger(logger bool) ServerOption
func WithDir ¶
func WithDir(dir string) ServerOption
func WithFindAvailablePort ¶
func WithFindAvailablePort(enabled bool) ServerOption
func WithJWTAuth ¶
func WithJWTAuth(jwtAuth ServerJWTAuth) ServerOption
func WithPort ¶
func WithPort(port int) ServerOption