authen

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 12, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BadCredentials = exception.New(http.StatusUnauthorized, "Bad credentials")

Functions

This section is empty.

Types

type Authentication

type Authentication interface {

	// Principal The identity of the principal being authenticated.
	// This might be a user id or username
	Principal() interface{}

	// Details Stores additional details about the authentication request.
	// These might contain username, a device id etc.
	Details() user.Details

	// Credentials The credentials that prove the principal is correct.
	// This is usually a password, token, api key or null if not used
	Credentials() interface{}

	// Authorities Indicates the authorities that the
	// principal has been granted
	Authorities() []authority.GrantedAuthority

	// Authenticated Indicates the request has been authenticated or not?
	// If not, we need to authenticate in the next step.
	Authenticated() bool
}

type AuthenticationManager

type AuthenticationManager interface {

	// Authenticate Attempts to authenticate the passed Authentication object,
	// returning a fully populated Authentication object (including granted authorities)if successful.
	Authenticate(authentication Authentication) (Authentication, error)
}

AuthenticationManager Processes an Authentication request.

type AuthenticationProvider

type AuthenticationProvider interface {
	AuthenticationManager

	// Supports Returns true if this AuthenticationProvider supports the
	// indicated Authentication object.
	Supports(authentication Authentication) bool
}

type BaseAuthentication

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

func NewBaseAuthentication

func NewBaseAuthentication(authorities []authority.GrantedAuthority) *BaseAuthentication

func (BaseAuthentication) Authenticated

func (b BaseAuthentication) Authenticated() bool

func (BaseAuthentication) Authorities

func (b BaseAuthentication) Authorities() []authority.GrantedAuthority

func (BaseAuthentication) Details

func (b BaseAuthentication) Details() user.Details

func (*BaseAuthentication) SetAuthenticated

func (b *BaseAuthentication) SetAuthenticated(authenticated bool)

func (*BaseAuthentication) SetUserDetails

func (b *BaseAuthentication) SetUserDetails(userDetails user.Details)

type CredentialsContainer

type CredentialsContainer interface {

	// EraseCredentials For safety, implementing object might
	// want to erase credentials
	EraseCredentials()
}

CredentialsContainer Indicates that the implementing object contains credentials

type JwtAuthProvider

type JwtAuthProvider struct {
}

func NewJwtAuthProvider

func NewJwtAuthProvider() *JwtAuthProvider

func (JwtAuthProvider) Authenticate

func (j JwtAuthProvider) Authenticate(authentication Authentication) (Authentication, error)

func (JwtAuthProvider) Supports

func (j JwtAuthProvider) Supports(authentication Authentication) bool

type JwtTokenAuthentication

type JwtTokenAuthentication struct {
	*BaseAuthentication
	// contains filtered or unexported fields
}

func NewJwtTokenAuthentication

func NewJwtTokenAuthentication(
	userDetails user.Details,
	authorities []authority.GrantedAuthority,
	claims jwt.MapClaims,
) *JwtTokenAuthentication

func (JwtTokenAuthentication) Claims

func (j JwtTokenAuthentication) Claims() jwt.MapClaims

func (*JwtTokenAuthentication) Credentials

func (j *JwtTokenAuthentication) Credentials() interface{}

func (*JwtTokenAuthentication) Principal

func (j *JwtTokenAuthentication) Principal() interface{}

type ProviderManager

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

func NewProviderManager

func NewProviderManager(providers ...AuthenticationProvider) *ProviderManager

func (*ProviderManager) AddProvider

func (p *ProviderManager) AddProvider(provider AuthenticationProvider)

func (*ProviderManager) Authenticate

func (p *ProviderManager) Authenticate(authentication Authentication) (result Authentication, err error)

type UsernamePasswordAuthProvider

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

func NewUsernamePasswordAuthProvider

func NewUsernamePasswordAuthProvider(
	userService user.Service,
	passwordEncoder crypto.PasswordEncoder,
) *UsernamePasswordAuthProvider

func (UsernamePasswordAuthProvider) Authenticate

func (j UsernamePasswordAuthProvider) Authenticate(authentication Authentication) (Authentication, error)

func (UsernamePasswordAuthProvider) Supports

func (j UsernamePasswordAuthProvider) Supports(authentication Authentication) bool

type UsernamePasswordAuthentication

type UsernamePasswordAuthentication struct {
	*BaseAuthentication
	// contains filtered or unexported fields
}

func NewUsernamePasswordAuthentication

func NewUsernamePasswordAuthentication(
	principal interface{},
	credentials interface{},
	authorities []authority.GrantedAuthority,
) *UsernamePasswordAuthentication

func (*UsernamePasswordAuthentication) Credentials

func (u *UsernamePasswordAuthentication) Credentials() interface{}

func (*UsernamePasswordAuthentication) EraseCredentials

func (u *UsernamePasswordAuthentication) EraseCredentials()

func (*UsernamePasswordAuthentication) Principal

func (u *UsernamePasswordAuthentication) Principal() interface{}

Jump to

Keyboard shortcuts

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