connection

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2023 License: CC0-1.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Subject

func Subject(id string) string

Subject hashes the ID, so that it can be used as the `sub` field.

Types

type Connection

type Connection interface {
	Authenticate(serverName string, reader io.Reader) (UserContext, error)
}

Connection is the interface that must be implemented by every concrete connection types.

type Mock

type Mock struct {
	Backend *raft.Backend
}

Mock is an insecure connection type that is only helpful for testing purposes. It is not meant to be used in production.

func (Mock) Authenticate

func (m Mock) Authenticate(serverName string, payload io.Reader) (UserContext, error)

Authenticate implements the connection interface.

type Unmarshaler

type Unmarshaler[T any] struct {
	// contains filtered or unexported fields
}

Unmarshaler is a generic type to unmarshal an io.Reader.

func NewUnmarshaler

func NewUnmarshaler[T any](reader io.Reader) *Unmarshaler[T]

NewUnmarshaler instantiates a new Unmarshaler.

func (*Unmarshaler[T]) Unmarshal

func (u *Unmarshaler[T]) Unmarshal() (T, error)

Unmarshal takes care of unmarshalling the data into the given type T.

type UserContext

type UserContext struct {
	ServerName     string
	ConnectionName string
	Subject        string
	Authenticated  bool
	// contains filtered or unexported fields
}

UserContext is the context of the user.

func (UserContext) AuthTime

func (u UserContext) AuthTime() time.Time

AuthTime returns the time at which the user was authenticated.

func (UserContext) IsAuthenticated

func (u UserContext) IsAuthenticated() bool

IsAuthenticated returns true if the user is authenticated.

type UserPass

type UserPass struct {
	Server  string
	Backend *raft.Backend
}

UserPass is the connection that allows us to store a user in the Raft/Badger internal database.

func (UserPass) Authenticate

func (u UserPass) Authenticate(serverName string, payload io.Reader) (UserContext, error)

Authenticate implements the Connection interface.

type UserPassPayload

type UserPassPayload struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

Jump to

Keyboard shortcuts

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