auth

package
v0.64.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2023 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authenticator

type Authenticator interface {

	// Mechanism returns authenticator mechanism name.
	Mechanism() string

	// Username returns authenticated username in case authentication process has been completed.
	Username() string

	// Authenticated returns whether or not user has been authenticated.
	Authenticated() bool

	// UsesChannelBinding returns whether or not this authenticator requires channel binding bytes.
	UsesChannelBinding() bool

	// ProcessElement process an incoming authenticator element.
	ProcessElement(context.Context, stravaganza.Element) (stravaganza.Element, *SASLError)

	// Reset resets authenticator internal state.
	Reset()
}

Authenticator defines a generic authenticator state machine.

type External

type External struct {
	// contains filtered or unexported fields
}

External represents external authentication mechanism (PLAIN).

func NewExternal

func NewExternal(address string, isSecure bool) *External

NewExternal returns a new external authenticator.

func (*External) Authenticated

func (e *External) Authenticated() bool

Authenticated returns whether or not user has been authenticated.

func (*External) Mechanism

func (e *External) Mechanism() string

Mechanism returns authenticator mechanism name.

func (*External) ProcessElement

func (e *External) ProcessElement(ctx context.Context, elem stravaganza.Element) (stravaganza.Element, *SASLError)

ProcessElement process an incoming authenticator element.

func (*External) Reset

func (e *External) Reset()

Reset resets scram internal state.

func (*External) Start

func (e *External) Start(ctx context.Context) error

Start dials external authenticator gRPC connection.

func (*External) Stop

func (e *External) Stop(_ context.Context) error

Stop closes underlying gRPC connection.

func (*External) Username

func (e *External) Username() string

Username returns authenticated username in case authentication process has been completed.

func (*External) UsesChannelBinding

func (e *External) UsesChannelBinding() bool

UsesChannelBinding returns whether or not this authenticator requires channel binding bytes.

type SASLError

type SASLError struct {
	Reason SASLErrorReason
	Err    error
}

SASLError represents specific SASL error type.

func (*SASLError) Element

func (se *SASLError) Element() stravaganza.Element

Element returs sasl error XML representation.

func (*SASLError) Error

func (se *SASLError) Error() string

Error satisfies error interface.

type SASLErrorReason

type SASLErrorReason uint8

SASLErrorReason defines the SASL error reason.

const (
	// IncorrectEncoding represents a 'incorrect-encoding' authentication error.
	IncorrectEncoding SASLErrorReason = iota

	// MalformedRequest represents a 'malformed-request' authentication error.
	MalformedRequest

	// NotAuthorized represents a 'not-authorized' authentication error.
	NotAuthorized

	// TemporaryAuthFailure represents a 'temporary-auth-failure' authentication error.
	TemporaryAuthFailure
)

func (SASLErrorReason) String

func (r SASLErrorReason) String() string

String returns SASLErrorReason string representation.

type Scram

type Scram struct {
	// contains filtered or unexported fields
}

Scram represents a SCRAM authenticator.

func NewScram

func NewScram(
	tr transport.Transport,
	scramType ScramType,
	usesChannelBinding bool,
	rep repository.User,
	peppers *pepper.Keys,
) *Scram

NewScram returns a new scram authenticator instance.

func (*Scram) Authenticated

func (s *Scram) Authenticated() bool

Authenticated returns whether or not user has been authenticated.

func (*Scram) Mechanism

func (s *Scram) Mechanism() string

Mechanism returns authenticator mechanism name.

func (*Scram) ProcessElement

func (s *Scram) ProcessElement(ctx context.Context, elem stravaganza.Element) (stravaganza.Element, *SASLError)

ProcessElement process an incoming authenticator element.

func (*Scram) Reset

func (s *Scram) Reset()

Reset resets scram internal state.

func (*Scram) Username

func (s *Scram) Username() string

Username returns authenticated username in case authentication process has been completed.

func (*Scram) UsesChannelBinding

func (s *Scram) UsesChannelBinding() bool

UsesChannelBinding returns whether or not scram authenticator requires channel binding bytes.

type ScramType

type ScramType int

ScramType represents a scram autheticator class

const (
	// ScramSHA1 represents SCRAM-SHA-1 authentication method.
	ScramSHA1 ScramType = iota

	// ScramSHA256 represents SCRAM-SHA-256 authentication method.
	ScramSHA256

	// ScramSHA512 represents SCRAM-SHA-512 authentication method.
	ScramSHA512

	// ScramSHA3512 represents SCRAM-SHA3-512 authentication method.
	ScramSHA3512
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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