security

package
v0.70.0 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: Apache-2.0 Imports: 28 Imported by: 7

Documentation

Overview

Code generated by MockGen. DO NOT EDIT. Source: ../pkg/security/types.go

Generated by this command:

mockgen -package=security -source ../pkg/security/types.go -destination ../pkg/security/mocks.go

Package security is a generated GoMock package.

Index

Constants

View Source
const (
	ApplicationCtxKey = "application"
	PrincipalCtxKey   = "principal"
)
View Source
const (
	Argon2PrefixKey = "{argon2}"
	BcryptPrefixKey = "{bcrypt}"
	Pbkdf2PrefixKey = "{pbkdf2}"
	ScryptPrefixKey = "{scrypt}"
)

Variables

View Source
var (
	ErrAccountExistingUsername    = errors.New("principal username already exists")
	ErrAccountInvalidUsername     = errors.New("principal username is invalid")
	ErrAccountEmptyRole           = errors.New("principal role is empty")
	ErrAccountInvalidRole         = errors.New("principal role is invalid")
	ErrAccountEmptyPassword       = errors.New("principal password is empty")
	ErrAccountInvalidPassword     = errors.New("principal password is invalid")
	ErrAccountEmptyPassphrase     = errors.New("principal passphrase is empty")
	ErrAccountInvalidPassphrase   = errors.New("principal passphrase is invalid")
	ErrAccountDisabled            = errors.New("principal is disabled")
	ErrAccountLocked              = errors.New("principal is locked")
	ErrAccountExpired             = errors.New("principal has expired")
	ErrAccountExpiredPassword     = errors.New("principal password has expired")
	ErrAccountEmptyAuthorities    = errors.New("principal authorities are empty")
	ErrAccountInvalidAuthorities  = errors.New("principal authorities are invalid")
	ErrAccountEmptyResource       = errors.New("principal resource is empty")
	ErrTokenFailedParsing         = errors.New("token failed to parse")
	ErrTokenInvalid               = errors.New("token is invalid")
	ErrTokenEmptyClaims           = errors.New("token claims is empty")
	ErrTokenEmptyUsernameClaim    = errors.New("token username claim is empty")
	ErrTokenInvalidUsernameClaim  = errors.New("token username claim is invalid")
	ErrTokenEmptyRoleClaim        = errors.New("token role claim is empty")
	ErrTokenInvalidRoleClaim      = errors.New("token role claim is invalid")
	ErrTokenEmptyResourcesClaim   = errors.New("token resources claim is empty")
	ErrTokenInvalidResourcesClaim = errors.New("token resources claim is invalid")
	ErrPasswordEncoderNotFound    = errors.New("password encoder not found")
	ErrPasswordLength             = errors.New("password length is too short")
	ErrPasswordSpecialChars       = errors.New("password must contain at least 2 special characters")
	ErrPasswordNumbers            = errors.New("password must contain at least 2 numbers")
	ErrPasswordUppercaseChars     = errors.New("password must contain at least 2 uppercase characters")
	ErrRawPasswordIsEmpty         = errors.New("rawPassword cannot be empty")
	ErrSaltIsNil                  = errors.New("salt cannot be nil")
	ErrSaltIsEmpty                = errors.New("salt cannot be empty")
	ErrHashFuncIsNil              = errors.New("hashFunc cannot be nil")
	ErrEncodedPasswordIsEmpty     = errors.New("encodedPassword cannot be empty")
	ErrEncodedPasswordNotAllowed  = errors.New("encodedPassword format not allowed")
	ErrBcryptCostNotAllowed       = errors.New("bcryptCost not allowed")
)
View Source
var SupportedDecoders = map[string]PasswordEncoder{
	Argon2PrefixKey: NewArgon2PasswordEncoder(),
	BcryptPrefixKey: NewBcryptPasswordEncoder(),
	Pbkdf2PrefixKey: NewPbkdf2PasswordEncoder(),
	ScryptPrefixKey: NewScryptPasswordEncoder(),
}

Functions

func AddApplicationToContext added in v0.70.0

func AddApplicationToContext(ctx *gin.Context, application string)

func AddPrincipalToContext added in v0.70.0

func AddPrincipalToContext(ctx *gin.Context, principal *Principal)

func Argon2Decode

func Argon2Decode(encodedPassword string) (*string, *int, *int, *int, *int, []byte, []byte, error)

func Argon2Encode

func Argon2Encode(rawPassword string, salt []byte, iterations int, memory int, threads int, keyLen int) (*string, error)

func ErrAuthenticationFailed added in v0.5.0

func ErrAuthenticationFailed(errs ...error) error

func ErrAuthorizationFailed added in v0.5.0

func ErrAuthorizationFailed(errs ...error) error

func ErrPasswordEncodingFailed added in v0.5.0

func ErrPasswordEncodingFailed(errs ...error) error

func ErrPasswordMatchingFailed added in v0.5.0

func ErrPasswordMatchingFailed(errs ...error) error

func ErrPasswordUpgradeEncodingValidationFailed added in v0.5.0

func ErrPasswordUpgradeEncodingValidationFailed(errs ...error) error

func ErrPasswordValidationFailed added in v0.5.0

func ErrPasswordValidationFailed(errs ...error) error

func ErrTokenGenerationFailed added in v0.5.0

func ErrTokenGenerationFailed(errs ...error) error

func ErrTokenValidationFailed added in v0.5.0

func ErrTokenValidationFailed(errs ...error) error

func GenerateSalt

func GenerateSalt(saltSize int) ([]byte, error)

func GetApplicationFromContext added in v0.70.0

func GetApplicationFromContext(ctx *gin.Context) (string, bool)

func Pbkdf2Decode

func Pbkdf2Decode(encodedPassword string) (*string, *int, []byte, []byte, error)

func Pbkdf2Encode

func Pbkdf2Encode(rawPassword string, salt []byte, iterations int, keyLength int, fn HashFunc) (*string, error)

func ScryptDecode

func ScryptDecode(encodedPassword string) (*string, *int, *int, *int, []byte, []byte, error)

func ScryptEncode

func ScryptEncode(rawPassword string, salt []byte, N int, r int, p int, keyLen int) (*string, error)

Types

type Argon2PasswordEncoder

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

func NewArgon2PasswordEncoder

func NewArgon2PasswordEncoder(options ...Argon2PasswordEncoderOption) *Argon2PasswordEncoder

func (*Argon2PasswordEncoder) Encode

func (encoder *Argon2PasswordEncoder) Encode(rawPassword string) (*string, error)

func (*Argon2PasswordEncoder) Matches

func (encoder *Argon2PasswordEncoder) Matches(encodedPassword string, rawPassword string) (*bool, error)

func (*Argon2PasswordEncoder) UpgradeEncoding

func (encoder *Argon2PasswordEncoder) UpgradeEncoding(encodedPassword string) (*bool, error)

type Argon2PasswordEncoderOption

type Argon2PasswordEncoderOption func(encoder *Argon2PasswordEncoder)

func WithArgon2Iterations

func WithArgon2Iterations(iterations int) Argon2PasswordEncoderOption

func WithArgon2KeyLength

func WithArgon2KeyLength(keyLength int) Argon2PasswordEncoderOption

func WithArgon2Memory

func WithArgon2Memory(memory int) Argon2PasswordEncoderOption

func WithArgon2SaltLength

func WithArgon2SaltLength(saltLength int) Argon2PasswordEncoderOption

func WithArgon2Threads

func WithArgon2Threads(threads int) Argon2PasswordEncoderOption

type AuthenticationEndpoint

type AuthenticationEndpoint interface {
	Authenticate(ctx *gin.Context)
}

type AuthenticationService

type AuthenticationService interface {
	Authenticate(ctx context.Context, principal *Principal) error
	Validate(principal *Principal) []error
}

type AuthorizationFilter

type AuthorizationFilter interface {
	Authorize(ctx *gin.Context)
}

type AuthorizationService

type AuthorizationService interface {
	Authorize(ctx context.Context, tokenString string) (*Principal, error)
}

type BcryptPasswordEncoder

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

func NewBcryptPasswordEncoder

func NewBcryptPasswordEncoder(options ...BcryptPasswordEncoderOption) *BcryptPasswordEncoder

func (*BcryptPasswordEncoder) Encode

func (encoder *BcryptPasswordEncoder) Encode(rawPassword string) (*string, error)

func (*BcryptPasswordEncoder) Matches

func (encoder *BcryptPasswordEncoder) Matches(encodedPassword string, rawPassword string) (*bool, error)

func (*BcryptPasswordEncoder) UpgradeEncoding

func (encoder *BcryptPasswordEncoder) UpgradeEncoding(encodedPassword string) (*bool, error)

type BcryptPasswordEncoderOption

type BcryptPasswordEncoderOption func(encoder *BcryptPasswordEncoder)

func WithBcryptCost

func WithBcryptCost(cost int) BcryptPasswordEncoderOption

type DefaultAuthenticationEndpoint

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

func NewDefaultAuthenticationEndpoint

func NewDefaultAuthenticationEndpoint(authenticationService AuthenticationService) *DefaultAuthenticationEndpoint

func (*DefaultAuthenticationEndpoint) Authenticate

func (endpoint *DefaultAuthenticationEndpoint) Authenticate(ctx *gin.Context)

type DefaultAuthenticationService

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

func NewDefaultAuthenticationService

func NewDefaultAuthenticationService(passwordEncoder PasswordEncoder, principalManager PrincipalManager, tokenManager TokenManager) *DefaultAuthenticationService

func (*DefaultAuthenticationService) Authenticate

func (service *DefaultAuthenticationService) Authenticate(ctx context.Context, principal *Principal) error

func (*DefaultAuthenticationService) Validate added in v0.70.0

func (service *DefaultAuthenticationService) Validate(principal *Principal) []error

type DefaultAuthorizationFilter

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

func NewDefaultAuthorizationFilter

func NewDefaultAuthorizationFilter(authorizationService AuthorizationService) *DefaultAuthorizationFilter

func (*DefaultAuthorizationFilter) Authorize

func (filter *DefaultAuthorizationFilter) Authorize(ctx *gin.Context)

type DefaultAuthorizationService

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

func NewDefaultAuthorizationService

func NewDefaultAuthorizationService(tokenManager TokenManager, principalManager PrincipalManager) *DefaultAuthorizationService

func (*DefaultAuthorizationService) Authorize

func (service *DefaultAuthorizationService) Authorize(ctx context.Context, tokenString string) (*Principal, error)

type DefaultClaims

type DefaultClaims struct {
	jwt.RegisteredClaims
	Principal
}

type DefaultPasswordGenerator

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

func NewDefaultPasswordGenerator

func NewDefaultPasswordGenerator(options ...DefaultPasswordGeneratorOption) *DefaultPasswordGenerator

func (*DefaultPasswordGenerator) Generate

func (generator *DefaultPasswordGenerator) Generate() string

func (*DefaultPasswordGenerator) Validate

func (generator *DefaultPasswordGenerator) Validate(rawPassword string) error

type DefaultPasswordGeneratorOption

type DefaultPasswordGeneratorOption func(generator *DefaultPasswordGenerator)

func WithMinNum

func WithMinNum(minNum int) DefaultPasswordGeneratorOption

func WithMinSpecialChar

func WithMinSpecialChar(minSpecialChar int) DefaultPasswordGeneratorOption

func WithMinUpperCase

func WithMinUpperCase(minUpperCase int) DefaultPasswordGeneratorOption

func WithPasswordLength

func WithPasswordLength(length int) DefaultPasswordGeneratorOption

type DefaultPasswordManager

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

func NewDefaultPasswordManager

func NewDefaultPasswordManager(passwordEncoder PasswordEncoder, passwordGenerator PasswordGenerator) *DefaultPasswordManager

func (*DefaultPasswordManager) Encode

func (manager *DefaultPasswordManager) Encode(rawPassword string) (*string, error)

func (*DefaultPasswordManager) Generate

func (manager *DefaultPasswordManager) Generate() string

func (*DefaultPasswordManager) Matches

func (manager *DefaultPasswordManager) Matches(encodedPassword string, rawPassword string) (*bool, error)

func (*DefaultPasswordManager) UpgradeEncoding

func (manager *DefaultPasswordManager) UpgradeEncoding(encodedPassword string) (*bool, error)

func (*DefaultPasswordManager) Validate

func (manager *DefaultPasswordManager) Validate(rawPassword string) error

type DelegatingPasswordEncoder

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

func (*DelegatingPasswordEncoder) Encode

func (delegate *DelegatingPasswordEncoder) Encode(rawPassword string) (*string, error)

func (*DelegatingPasswordEncoder) Matches

func (delegate *DelegatingPasswordEncoder) Matches(encodedPassword string, rawPassword string) (*bool, error)

func (*DelegatingPasswordEncoder) UpgradeEncoding

func (delegate *DelegatingPasswordEncoder) UpgradeEncoding(encodedPassword string) (*bool, error)

type DelegatingPasswordEncoderOption

type DelegatingPasswordEncoderOption func(encoder *DelegatingPasswordEncoder)

func WithSupportedDecoders

func WithSupportedDecoders(decoders map[string]PasswordEncoder) DelegatingPasswordEncoderOption

type HashFunc

type HashFunc func() hash.Hash

type InMemoryPrincipalManager

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

func NewInMemoryPrincipalManager

func NewInMemoryPrincipalManager(passwordManager PasswordManager) *InMemoryPrincipalManager

func (*InMemoryPrincipalManager) ChangePassword

func (manager *InMemoryPrincipalManager) ChangePassword(ctx context.Context, username string, password string) error

func (*InMemoryPrincipalManager) Create

func (manager *InMemoryPrincipalManager) Create(ctx context.Context, principal *Principal) error

func (*InMemoryPrincipalManager) Delete

func (manager *InMemoryPrincipalManager) Delete(_ context.Context, username string) error

func (*InMemoryPrincipalManager) Exists

func (manager *InMemoryPrincipalManager) Exists(_ context.Context, username string) error

func (*InMemoryPrincipalManager) Find

func (manager *InMemoryPrincipalManager) Find(_ context.Context, username string) (*Principal, error)

func (*InMemoryPrincipalManager) Update

func (manager *InMemoryPrincipalManager) Update(ctx context.Context, principal *Principal) error

func (*InMemoryPrincipalManager) VerifyResource

func (manager *InMemoryPrincipalManager) VerifyResource(ctx context.Context, username string, resource string) error

type JwtTokenManager

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

func NewJwtTokenManager

func NewJwtTokenManager(options ...JwtTokenManagerOption) *JwtTokenManager

func (*JwtTokenManager) Generate

func (manager *JwtTokenManager) Generate(principal *Principal) (*string, error)

func (*JwtTokenManager) Validate

func (manager *JwtTokenManager) Validate(tokenString string) (*Principal, error)

type JwtTokenManagerOption

type JwtTokenManagerOption func(tokenManager *JwtTokenManager)

func WithIssuer

func WithIssuer(issuer string) JwtTokenManagerOption

func WithSigningKey added in v0.70.0

func WithSigningKey(signingKey any) JwtTokenManagerOption

func WithSigningMethod

func WithSigningMethod(signingMethod jwt.SigningMethod) JwtTokenManagerOption

func WithTimeout

func WithTimeout(timeout time.Duration) JwtTokenManagerOption

func WithVerifyingKey added in v0.70.0

func WithVerifyingKey(verifyingKey any) JwtTokenManagerOption

type MockAuthenticationEndpoint

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

MockAuthenticationEndpoint is a mock of AuthenticationEndpoint interface.

func NewMockAuthenticationEndpoint

func NewMockAuthenticationEndpoint(ctrl *gomock.Controller) *MockAuthenticationEndpoint

NewMockAuthenticationEndpoint creates a new mock instance.

func (*MockAuthenticationEndpoint) Authenticate

func (m *MockAuthenticationEndpoint) Authenticate(ctx *gin.Context)

Authenticate mocks base method.

func (*MockAuthenticationEndpoint) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

type MockAuthenticationEndpointMockRecorder

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

MockAuthenticationEndpointMockRecorder is the mock recorder for MockAuthenticationEndpoint.

func (*MockAuthenticationEndpointMockRecorder) Authenticate

func (mr *MockAuthenticationEndpointMockRecorder) Authenticate(ctx any) *gomock.Call

Authenticate indicates an expected call of Authenticate.

type MockAuthenticationService

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

MockAuthenticationService is a mock of AuthenticationService interface.

func NewMockAuthenticationService

func NewMockAuthenticationService(ctrl *gomock.Controller) *MockAuthenticationService

NewMockAuthenticationService creates a new mock instance.

func (*MockAuthenticationService) Authenticate

func (m *MockAuthenticationService) Authenticate(ctx context.Context, principal *Principal) error

Authenticate mocks base method.

func (*MockAuthenticationService) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockAuthenticationService) Validate added in v0.70.0

func (m *MockAuthenticationService) Validate(principal *Principal) []error

Validate mocks base method.

type MockAuthenticationServiceMockRecorder

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

MockAuthenticationServiceMockRecorder is the mock recorder for MockAuthenticationService.

func (*MockAuthenticationServiceMockRecorder) Authenticate

func (mr *MockAuthenticationServiceMockRecorder) Authenticate(ctx, principal any) *gomock.Call

Authenticate indicates an expected call of Authenticate.

func (*MockAuthenticationServiceMockRecorder) Validate added in v0.70.0

func (mr *MockAuthenticationServiceMockRecorder) Validate(principal any) *gomock.Call

Validate indicates an expected call of Validate.

type MockAuthorizationFilter

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

MockAuthorizationFilter is a mock of AuthorizationFilter interface.

func NewMockAuthorizationFilter

func NewMockAuthorizationFilter(ctrl *gomock.Controller) *MockAuthorizationFilter

NewMockAuthorizationFilter creates a new mock instance.

func (*MockAuthorizationFilter) Authorize

func (m *MockAuthorizationFilter) Authorize(ctx *gin.Context)

Authorize mocks base method.

func (*MockAuthorizationFilter) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

type MockAuthorizationFilterMockRecorder

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

MockAuthorizationFilterMockRecorder is the mock recorder for MockAuthorizationFilter.

func (*MockAuthorizationFilterMockRecorder) Authorize

func (mr *MockAuthorizationFilterMockRecorder) Authorize(ctx any) *gomock.Call

Authorize indicates an expected call of Authorize.

type MockAuthorizationService

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

MockAuthorizationService is a mock of AuthorizationService interface.

func NewMockAuthorizationService

func NewMockAuthorizationService(ctrl *gomock.Controller) *MockAuthorizationService

NewMockAuthorizationService creates a new mock instance.

func (*MockAuthorizationService) Authorize

func (m *MockAuthorizationService) Authorize(ctx context.Context, tokenString string) (*Principal, error)

Authorize mocks base method.

func (*MockAuthorizationService) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

type MockAuthorizationServiceMockRecorder

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

MockAuthorizationServiceMockRecorder is the mock recorder for MockAuthorizationService.

func (*MockAuthorizationServiceMockRecorder) Authorize

func (mr *MockAuthorizationServiceMockRecorder) Authorize(ctx, tokenString any) *gomock.Call

Authorize indicates an expected call of Authorize.

type MockPasswordEncoder

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

MockPasswordEncoder is a mock of PasswordEncoder interface.

func NewMockPasswordEncoder

func NewMockPasswordEncoder(ctrl *gomock.Controller) *MockPasswordEncoder

NewMockPasswordEncoder creates a new mock instance.

func (*MockPasswordEncoder) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockPasswordEncoder) Encode

func (m *MockPasswordEncoder) Encode(rawPassword string) (*string, error)

Encode mocks base method.

func (*MockPasswordEncoder) Matches

func (m *MockPasswordEncoder) Matches(encodedPassword, rawPassword string) (*bool, error)

Matches mocks base method.

func (*MockPasswordEncoder) UpgradeEncoding

func (m *MockPasswordEncoder) UpgradeEncoding(encodedPassword string) (*bool, error)

UpgradeEncoding mocks base method.

type MockPasswordEncoderMockRecorder

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

MockPasswordEncoderMockRecorder is the mock recorder for MockPasswordEncoder.

func (*MockPasswordEncoderMockRecorder) Encode

func (mr *MockPasswordEncoderMockRecorder) Encode(rawPassword any) *gomock.Call

Encode indicates an expected call of Encode.

func (*MockPasswordEncoderMockRecorder) Matches

func (mr *MockPasswordEncoderMockRecorder) Matches(encodedPassword, rawPassword any) *gomock.Call

Matches indicates an expected call of Matches.

func (*MockPasswordEncoderMockRecorder) UpgradeEncoding

func (mr *MockPasswordEncoderMockRecorder) UpgradeEncoding(encodedPassword any) *gomock.Call

UpgradeEncoding indicates an expected call of UpgradeEncoding.

type MockPasswordGenerator

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

MockPasswordGenerator is a mock of PasswordGenerator interface.

func NewMockPasswordGenerator

func NewMockPasswordGenerator(ctrl *gomock.Controller) *MockPasswordGenerator

NewMockPasswordGenerator creates a new mock instance.

func (*MockPasswordGenerator) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockPasswordGenerator) Generate

func (m *MockPasswordGenerator) Generate() string

Generate mocks base method.

func (*MockPasswordGenerator) Validate

func (m *MockPasswordGenerator) Validate(rawPassword string) error

Validate mocks base method.

type MockPasswordGeneratorMockRecorder

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

MockPasswordGeneratorMockRecorder is the mock recorder for MockPasswordGenerator.

func (*MockPasswordGeneratorMockRecorder) Generate

Generate indicates an expected call of Generate.

func (*MockPasswordGeneratorMockRecorder) Validate

func (mr *MockPasswordGeneratorMockRecorder) Validate(rawPassword any) *gomock.Call

Validate indicates an expected call of Validate.

type MockPasswordManager

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

MockPasswordManager is a mock of PasswordManager interface.

func NewMockPasswordManager

func NewMockPasswordManager(ctrl *gomock.Controller) *MockPasswordManager

NewMockPasswordManager creates a new mock instance.

func (*MockPasswordManager) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockPasswordManager) Encode

func (m *MockPasswordManager) Encode(rawPassword string) (*string, error)

Encode mocks base method.

func (*MockPasswordManager) Generate

func (m *MockPasswordManager) Generate() string

Generate mocks base method.

func (*MockPasswordManager) Matches

func (m *MockPasswordManager) Matches(encodedPassword, rawPassword string) (*bool, error)

Matches mocks base method.

func (*MockPasswordManager) UpgradeEncoding

func (m *MockPasswordManager) UpgradeEncoding(encodedPassword string) (*bool, error)

UpgradeEncoding mocks base method.

func (*MockPasswordManager) Validate

func (m *MockPasswordManager) Validate(rawPassword string) error

Validate mocks base method.

type MockPasswordManagerMockRecorder

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

MockPasswordManagerMockRecorder is the mock recorder for MockPasswordManager.

func (*MockPasswordManagerMockRecorder) Encode

func (mr *MockPasswordManagerMockRecorder) Encode(rawPassword any) *gomock.Call

Encode indicates an expected call of Encode.

func (*MockPasswordManagerMockRecorder) Generate

Generate indicates an expected call of Generate.

func (*MockPasswordManagerMockRecorder) Matches

func (mr *MockPasswordManagerMockRecorder) Matches(encodedPassword, rawPassword any) *gomock.Call

Matches indicates an expected call of Matches.

func (*MockPasswordManagerMockRecorder) UpgradeEncoding

func (mr *MockPasswordManagerMockRecorder) UpgradeEncoding(encodedPassword any) *gomock.Call

UpgradeEncoding indicates an expected call of UpgradeEncoding.

func (*MockPasswordManagerMockRecorder) Validate

func (mr *MockPasswordManagerMockRecorder) Validate(rawPassword any) *gomock.Call

Validate indicates an expected call of Validate.

type MockPrincipalManager

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

MockPrincipalManager is a mock of PrincipalManager interface.

func NewMockPrincipalManager

func NewMockPrincipalManager(ctrl *gomock.Controller) *MockPrincipalManager

NewMockPrincipalManager creates a new mock instance.

func (*MockPrincipalManager) ChangePassword

func (m *MockPrincipalManager) ChangePassword(ctx context.Context, username, password string) error

ChangePassword mocks base method.

func (*MockPrincipalManager) Create

func (m *MockPrincipalManager) Create(ctx context.Context, principal *Principal) error

Create mocks base method.

func (*MockPrincipalManager) Delete

func (m *MockPrincipalManager) Delete(ctx context.Context, username string) error

Delete mocks base method.

func (*MockPrincipalManager) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockPrincipalManager) Exists

func (m *MockPrincipalManager) Exists(ctx context.Context, username string) error

Exists mocks base method.

func (*MockPrincipalManager) Find

func (m *MockPrincipalManager) Find(ctx context.Context, username string) (*Principal, error)

Find mocks base method.

func (*MockPrincipalManager) Update

func (m *MockPrincipalManager) Update(ctx context.Context, principal *Principal) error

Update mocks base method.

func (*MockPrincipalManager) VerifyResource

func (m *MockPrincipalManager) VerifyResource(ctx context.Context, username, resource string) error

VerifyResource mocks base method.

type MockPrincipalManagerMockRecorder

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

MockPrincipalManagerMockRecorder is the mock recorder for MockPrincipalManager.

func (*MockPrincipalManagerMockRecorder) ChangePassword

func (mr *MockPrincipalManagerMockRecorder) ChangePassword(ctx, username, password any) *gomock.Call

ChangePassword indicates an expected call of ChangePassword.

func (*MockPrincipalManagerMockRecorder) Create

func (mr *MockPrincipalManagerMockRecorder) Create(ctx, principal any) *gomock.Call

Create indicates an expected call of Create.

func (*MockPrincipalManagerMockRecorder) Delete

func (mr *MockPrincipalManagerMockRecorder) Delete(ctx, username any) *gomock.Call

Delete indicates an expected call of Delete.

func (*MockPrincipalManagerMockRecorder) Exists

func (mr *MockPrincipalManagerMockRecorder) Exists(ctx, username any) *gomock.Call

Exists indicates an expected call of Exists.

func (*MockPrincipalManagerMockRecorder) Find

func (mr *MockPrincipalManagerMockRecorder) Find(ctx, username any) *gomock.Call

Find indicates an expected call of Find.

func (*MockPrincipalManagerMockRecorder) Update

func (mr *MockPrincipalManagerMockRecorder) Update(ctx, principal any) *gomock.Call

Update indicates an expected call of Update.

func (*MockPrincipalManagerMockRecorder) VerifyResource

func (mr *MockPrincipalManagerMockRecorder) VerifyResource(ctx, username, resource any) *gomock.Call

VerifyResource indicates an expected call of VerifyResource.

type MockTokenManager

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

MockTokenManager is a mock of TokenManager interface.

func NewMockTokenManager

func NewMockTokenManager(ctrl *gomock.Controller) *MockTokenManager

NewMockTokenManager creates a new mock instance.

func (*MockTokenManager) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockTokenManager) Generate

func (m *MockTokenManager) Generate(principal *Principal) (*string, error)

Generate mocks base method.

func (*MockTokenManager) Validate

func (m *MockTokenManager) Validate(tokenString string) (*Principal, error)

Validate mocks base method.

type MockTokenManagerMockRecorder

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

MockTokenManagerMockRecorder is the mock recorder for MockTokenManager.

func (*MockTokenManagerMockRecorder) Generate

func (mr *MockTokenManagerMockRecorder) Generate(principal any) *gomock.Call

Generate indicates an expected call of Generate.

func (*MockTokenManagerMockRecorder) Validate

func (mr *MockTokenManagerMockRecorder) Validate(tokenString any) *gomock.Call

Validate indicates an expected call of Validate.

type PasswordEncoder

type PasswordEncoder interface {
	Encode(rawPassword string) (*string, error)
	Matches(encodedPassword string, rawPassword string) (*bool, error)
	UpgradeEncoding(encodedPassword string) (*bool, error)
}

type PasswordGenerator

type PasswordGenerator interface {
	Generate() string
	Validate(rawPassword string) error
}

type PasswordManager

type PasswordManager interface {
	PasswordEncoder
	PasswordGenerator
}

type Pbkdf2PasswordEncoder

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

func NewPbkdf2PasswordEncoder

func NewPbkdf2PasswordEncoder(options ...Pbkdf2PasswordEncoderOption) *Pbkdf2PasswordEncoder

func (*Pbkdf2PasswordEncoder) Encode

func (encoder *Pbkdf2PasswordEncoder) Encode(rawPassword string) (*string, error)

func (*Pbkdf2PasswordEncoder) Matches

func (encoder *Pbkdf2PasswordEncoder) Matches(encodedPassword string, rawPassword string) (*bool, error)

func (*Pbkdf2PasswordEncoder) UpgradeEncoding

func (encoder *Pbkdf2PasswordEncoder) UpgradeEncoding(encodedPassword string) (*bool, error)

type Pbkdf2PasswordEncoderOption

type Pbkdf2PasswordEncoderOption func(encoder *Pbkdf2PasswordEncoder)

func WithHashFunc

func WithHashFunc(hashFunc HashFunc) Pbkdf2PasswordEncoderOption

func WithPbkdf2Iterations

func WithPbkdf2Iterations(iterations int) Pbkdf2PasswordEncoderOption

func WithPbkdf2KeyLength

func WithPbkdf2KeyLength(keyLength int) Pbkdf2PasswordEncoderOption

func WithPbkdf2SaltLength

func WithPbkdf2SaltLength(saltLength int) Pbkdf2PasswordEncoderOption

type Principal

type Principal struct {
	Username           *string  `json:"username,omitempty" binding:"required"`
	Role               *string  `json:"role,omitempty"`
	Password           *string  `json:"password,omitempty" binding:"required"`
	Passphrase         *string  `json:"passphrase,omitempty" `
	Enabled            *bool    `json:"enabled,omitempty"`
	NonLocked          *bool    `json:"non_locked,omitempty"`
	NonExpired         *bool    `json:"non_expired,omitempty"`
	PasswordNonExpired *bool    `json:"password_non_expired,omitempty"`
	SignUpDone         *bool    `json:"signup_done,omitempty"`
	Resources          []string `json:"resources,omitempty"`
	Token              *string  `json:"token,omitempty"`
}

func GetPrincipalFromContext added in v0.70.0

func GetPrincipalFromContext(ctx *gin.Context) (*Principal, bool)

type PrincipalManager

type PrincipalManager interface {
	Create(ctx context.Context, principal *Principal) error
	Update(ctx context.Context, principal *Principal) error
	Delete(ctx context.Context, username string) error
	Find(ctx context.Context, username string) (*Principal, error)
	Exists(ctx context.Context, username string) error

	ChangePassword(ctx context.Context, username string, password string) error
	VerifyResource(ctx context.Context, username string, resource string) error
}

type ResourceCtxKey

type ResourceCtxKey struct{}

type ScryptPasswordEncoder

type ScryptPasswordEncoder struct {
	N int
	// contains filtered or unexported fields
}

func NewScryptPasswordEncoder

func NewScryptPasswordEncoder(options ...ScryptPasswordEncoderOption) *ScryptPasswordEncoder

func (*ScryptPasswordEncoder) Encode

func (encoder *ScryptPasswordEncoder) Encode(rawPassword string) (*string, error)

func (*ScryptPasswordEncoder) Matches

func (encoder *ScryptPasswordEncoder) Matches(encodedPassword string, rawPassword string) (*bool, error)

func (*ScryptPasswordEncoder) UpgradeEncoding

func (encoder *ScryptPasswordEncoder) UpgradeEncoding(encodedPassword string) (*bool, error)

type ScryptPasswordEncoderOption

type ScryptPasswordEncoderOption func(encoder *ScryptPasswordEncoder)

func WithScryptKeyLength

func WithScryptKeyLength(keyLength int) ScryptPasswordEncoderOption

func WithScryptN

func WithScryptN(N int) ScryptPasswordEncoderOption

func WithScryptP

func WithScryptP(p int) ScryptPasswordEncoderOption

func WithScryptR

func WithScryptR(r int) ScryptPasswordEncoderOption

func WithScryptSaltLength

func WithScryptSaltLength(saltLength int) ScryptPasswordEncoderOption

type TokenManager

type TokenManager interface {
	Generate(principal *Principal) (*string, error)
	Validate(tokenString string) (*Principal, error)
}

Jump to

Keyboard shortcuts

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