auth

package
v0.0.0-...-48a15a0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2022 License: 0BSD Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParsePasswordAuthenticationData

func ParsePasswordAuthenticationData(buf []byte) (*passwordAuthenticationData, error)

Types

type ClientAuthenticationChannels

type ClientAuthenticationChannels struct {
	Data           chan []byte
	FirstAuthReply chan *message.AuthenticationReply
	FinalAuthReply chan *message.AuthenticationReply
	Error          chan error
}

func NewClientAuthenticationChannels

func NewClientAuthenticationChannels() *ClientAuthenticationChannels

type ClientAuthenticationMethod

type ClientAuthenticationMethod interface {
	Authenticate(
		ctx context.Context,
		conn net.Conn,
		cac ClientAuthenticationChannels,
	)
	ID() byte
}

type DefaultServerAuthenticator

type DefaultServerAuthenticator struct {
	Methods map[byte]ServerAuthenticationMethod

	DisableSession bool
	DisableToken   bool
	// contains filtered or unexported fields
}

func NewServerAuthenticator

func NewServerAuthenticator() *DefaultServerAuthenticator

func (*DefaultServerAuthenticator) AddMethod

func (*DefaultServerAuthenticator) Authenticate

func (*DefaultServerAuthenticator) ContinueAuthenticate

func (*DefaultServerAuthenticator) SessionConnClose

func (d *DefaultServerAuthenticator) SessionConnClose(id []byte)

type NoneClientAuthenticationMethod

type NoneClientAuthenticationMethod struct{}

func (NoneClientAuthenticationMethod) Authenticate

func (NoneClientAuthenticationMethod) ID

type NoneServerAuthenticationMethod

type NoneServerAuthenticationMethod struct{}

NoneServerAuthenticationMethod is IANA method 0, require no authn at all.

func (NoneServerAuthenticationMethod) Authenticate

func (n NoneServerAuthenticationMethod) Authenticate(
	ctx context.Context,
	conn net.Conn,
	data []byte,
	sac *ServerAuthenticationChannels,
)

func (NoneServerAuthenticationMethod) ID

type PasswordClientAuthenticationMethod

type PasswordClientAuthenticationMethod struct {
	Username string
	Password string
}

func (PasswordClientAuthenticationMethod) Authenticate

func (PasswordClientAuthenticationMethod) ID

type PasswordServerAuthenticationMethod

type PasswordServerAuthenticationMethod struct {
	// Passwords is client password table, key is user name
	Passwords map[string]string
}

PasswordServerAuthenticationMethod is IANA method 2, check for plaintext user name and password.

func (PasswordServerAuthenticationMethod) Authenticate

func (p PasswordServerAuthenticationMethod) Authenticate(
	ctx context.Context,
	conn net.Conn,
	data []byte,
	sac *ServerAuthenticationChannels,
)

func (PasswordServerAuthenticationMethod) ID

type ServerAuthenticationChannels

type ServerAuthenticationChannels struct {
	// Result is where authenticate method write it's result
	Result chan ServerAuthenticationResult
	// Continue is used by server process to signal auth step 1 result has been written to client
	Continue chan bool
	// Err used by authn method to report error
	Err chan error
}

ServerAuthenticationChannels are three channels used to control auth step 2.

func NewServerAuthenticationChannels

func NewServerAuthenticationChannels() *ServerAuthenticationChannels

type ServerAuthenticationMethod

type ServerAuthenticationMethod interface {
	Authenticate(
		ctx context.Context,
		conn net.Conn,
		data []byte,
		sac *ServerAuthenticationChannels,
	)
	ID() byte
}

type ServerAuthenticationResult

type ServerAuthenticationResult struct {
	Success        bool
	SelectedMethod byte
	Continue       bool

	SessionID         []byte
	MethodData        []byte
	AdditionalOptions []message.Option

	ClientName string
}

type ServerAuthenticator

type ServerAuthenticator interface {
	Authenticate(
		ctx context.Context,
		conn net.Conn,
		req message.Request,
	) (
		*ServerAuthenticationResult,
		*ServerAuthenticationChannels,
	)
	ContinueAuthenticate(sac *ServerAuthenticationChannels, req message.Request) (*ServerAuthenticationResult, error)
	SessionConnClose(id []byte)
}

Jump to

Keyboard shortcuts

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