auth

package
v0.52.2 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2021 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 added in v0.50.0

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

External represents external authentication mechanism (PLAIN).

func NewExternal added in v0.50.0

func NewExternal(address string, isSecure bool) *External

NewExternal returns a new external authenticator.

func (*External) Authenticated added in v0.50.0

func (e *External) Authenticated() bool

Authenticated returns whether or not user has been authenticated.

func (*External) Mechanism added in v0.50.0

func (e *External) Mechanism() string

Mechanism returns authenticator mechanism name.

func (*External) ProcessElement added in v0.50.0

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

ProcessElement process an incoming authenticator element.

func (*External) Reset added in v0.50.0

func (e *External) Reset()

Reset resets scram internal state.

func (*External) Start added in v0.50.0

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

Start dials external authenticator gRPC connection.

func (*External) Stop added in v0.50.0

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

Stop closes underlying gRPC connection.

func (*External) Username added in v0.50.0

func (e *External) Username() string

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

func (*External) UsesChannelBinding added in v0.50.0

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 added in v0.50.0

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 added in v0.50.0

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