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
- Variables
- func AddApplicationToContext(ctx *gin.Context, application string)
- func AddPrincipalToContext(ctx *gin.Context, principal *Principal)
- func Argon2Decode(encodedPassword string) (*string, *int, *int, *int, *int, []byte, []byte, error)
- func Argon2Encode(rawPassword string, salt []byte, iterations int, memory int, threads int, ...) (*string, error)
- func ErrAuthenticationFailed(errs ...error) error
- func ErrAuthorizationFailed(errs ...error) error
- func ErrPasswordEncodingFailed(errs ...error) error
- func ErrPasswordMatchingFailed(errs ...error) error
- func ErrPasswordUpgradeEncodingValidationFailed(errs ...error) error
- func ErrPasswordValidationFailed(errs ...error) error
- func ErrTokenGenerationFailed(errs ...error) error
- func ErrTokenValidationFailed(errs ...error) error
- func GenerateSalt(saltSize int) ([]byte, error)
- func GetApplicationFromContext(ctx *gin.Context) (string, bool)
- func Pbkdf2Decode(encodedPassword string) (*string, *int, []byte, []byte, error)
- func Pbkdf2Encode(rawPassword string, salt []byte, iterations int, keyLength int, fn HashFunc) (*string, error)
- func ScryptDecode(encodedPassword string) (*string, *int, *int, *int, []byte, []byte, error)
- func ScryptEncode(rawPassword string, salt []byte, N int, r int, p int, keyLen int) (*string, error)
- type Argon2PasswordEncoder
- type Argon2PasswordEncoderOption
- func WithArgon2Iterations(iterations int) Argon2PasswordEncoderOption
- func WithArgon2KeyLength(keyLength int) Argon2PasswordEncoderOption
- func WithArgon2Memory(memory int) Argon2PasswordEncoderOption
- func WithArgon2SaltLength(saltLength int) Argon2PasswordEncoderOption
- func WithArgon2Threads(threads int) Argon2PasswordEncoderOption
- type AuthenticationEndpoint
- type AuthenticationService
- type AuthorizationFilter
- type AuthorizationService
- type BcryptPasswordEncoder
- type BcryptPasswordEncoderOption
- type DefaultAuthenticationEndpoint
- type DefaultAuthenticationService
- type DefaultAuthorizationFilter
- type DefaultAuthorizationService
- type DefaultClaims
- type DefaultPasswordGenerator
- type DefaultPasswordGeneratorOption
- type DefaultPasswordManager
- func (manager *DefaultPasswordManager) Encode(rawPassword string) (*string, error)
- func (manager *DefaultPasswordManager) Generate() string
- func (manager *DefaultPasswordManager) Matches(encodedPassword string, rawPassword string) (*bool, error)
- func (manager *DefaultPasswordManager) UpgradeEncoding(encodedPassword string) (*bool, error)
- func (manager *DefaultPasswordManager) Validate(rawPassword string) error
- type DelegatingPasswordEncoder
- type DelegatingPasswordEncoderOption
- type HashFunc
- type InMemoryPrincipalManager
- func (manager *InMemoryPrincipalManager) ChangePassword(ctx context.Context, username string, password string) error
- func (manager *InMemoryPrincipalManager) Create(ctx context.Context, principal *Principal) error
- func (manager *InMemoryPrincipalManager) Delete(_ context.Context, username string) error
- func (manager *InMemoryPrincipalManager) Exists(_ context.Context, username string) error
- func (manager *InMemoryPrincipalManager) Find(_ context.Context, username string) (*Principal, error)
- func (manager *InMemoryPrincipalManager) Update(ctx context.Context, principal *Principal) error
- func (manager *InMemoryPrincipalManager) VerifyResource(ctx context.Context, username string, resource string) error
- type JwtTokenManager
- type JwtTokenManagerOption
- func WithIssuer(issuer string) JwtTokenManagerOption
- func WithSigningKey(signingKey any) JwtTokenManagerOption
- func WithSigningMethod(signingMethod jwt.SigningMethod) JwtTokenManagerOption
- func WithTimeout(timeout time.Duration) JwtTokenManagerOption
- func WithVerifyingKey(verifyingKey any) JwtTokenManagerOption
- type MockAuthenticationEndpoint
- type MockAuthenticationEndpointMockRecorder
- type MockAuthenticationService
- type MockAuthenticationServiceMockRecorder
- type MockAuthorizationFilter
- type MockAuthorizationFilterMockRecorder
- type MockAuthorizationService
- type MockAuthorizationServiceMockRecorder
- type MockPasswordEncoder
- func (m *MockPasswordEncoder) EXPECT() *MockPasswordEncoderMockRecorder
- func (m *MockPasswordEncoder) Encode(rawPassword string) (*string, error)
- func (m *MockPasswordEncoder) Matches(encodedPassword, rawPassword string) (*bool, error)
- func (m *MockPasswordEncoder) UpgradeEncoding(encodedPassword string) (*bool, error)
- type MockPasswordEncoderMockRecorder
- type MockPasswordGenerator
- type MockPasswordGeneratorMockRecorder
- type MockPasswordManager
- func (m *MockPasswordManager) EXPECT() *MockPasswordManagerMockRecorder
- func (m *MockPasswordManager) Encode(rawPassword string) (*string, error)
- func (m *MockPasswordManager) Generate() string
- func (m *MockPasswordManager) Matches(encodedPassword, rawPassword string) (*bool, error)
- func (m *MockPasswordManager) UpgradeEncoding(encodedPassword string) (*bool, error)
- func (m *MockPasswordManager) Validate(rawPassword string) error
- type MockPasswordManagerMockRecorder
- func (mr *MockPasswordManagerMockRecorder) Encode(rawPassword any) *gomock.Call
- func (mr *MockPasswordManagerMockRecorder) Generate() *gomock.Call
- func (mr *MockPasswordManagerMockRecorder) Matches(encodedPassword, rawPassword any) *gomock.Call
- func (mr *MockPasswordManagerMockRecorder) UpgradeEncoding(encodedPassword any) *gomock.Call
- func (mr *MockPasswordManagerMockRecorder) Validate(rawPassword any) *gomock.Call
- type MockPrincipalManager
- func (m *MockPrincipalManager) ChangePassword(ctx context.Context, username, password string) error
- func (m *MockPrincipalManager) Create(ctx context.Context, principal *Principal) error
- func (m *MockPrincipalManager) Delete(ctx context.Context, username string) error
- func (m *MockPrincipalManager) EXPECT() *MockPrincipalManagerMockRecorder
- func (m *MockPrincipalManager) Exists(ctx context.Context, username string) error
- func (m *MockPrincipalManager) Find(ctx context.Context, username string) (*Principal, error)
- func (m *MockPrincipalManager) Update(ctx context.Context, principal *Principal) error
- func (m *MockPrincipalManager) VerifyResource(ctx context.Context, username, resource string) error
- type MockPrincipalManagerMockRecorder
- func (mr *MockPrincipalManagerMockRecorder) ChangePassword(ctx, username, password any) *gomock.Call
- func (mr *MockPrincipalManagerMockRecorder) Create(ctx, principal any) *gomock.Call
- func (mr *MockPrincipalManagerMockRecorder) Delete(ctx, username any) *gomock.Call
- func (mr *MockPrincipalManagerMockRecorder) Exists(ctx, username any) *gomock.Call
- func (mr *MockPrincipalManagerMockRecorder) Find(ctx, username any) *gomock.Call
- func (mr *MockPrincipalManagerMockRecorder) Update(ctx, principal any) *gomock.Call
- func (mr *MockPrincipalManagerMockRecorder) VerifyResource(ctx, username, resource any) *gomock.Call
- type MockTokenManager
- type MockTokenManagerMockRecorder
- type PasswordEncoder
- type PasswordGenerator
- type PasswordManager
- type Pbkdf2PasswordEncoder
- type Pbkdf2PasswordEncoderOption
- type Principal
- type PrincipalManager
- type ResourceCtxKey
- type ScryptPasswordEncoder
- type ScryptPasswordEncoderOption
- type TokenManager
Constants ¶
const ( ApplicationCtxKey = "application" PrincipalCtxKey = "principal" )
const ( Argon2PrefixKey = "{argon2}" BcryptPrefixKey = "{bcrypt}" Pbkdf2PrefixKey = "{pbkdf2}" ScryptPrefixKey = "{scrypt}" )
Variables ¶
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") )
var SupportedDecoders = map[string]PasswordEncoder{ Argon2PrefixKey: NewArgon2PasswordEncoder(), BcryptPrefixKey: NewBcryptPasswordEncoder(), Pbkdf2PrefixKey: NewPbkdf2PasswordEncoder(), ScryptPrefixKey: NewScryptPasswordEncoder(), }
Functions ¶
func AddApplicationToContext ¶ added in v0.70.0
func AddPrincipalToContext ¶ added in v0.70.0
func Argon2Decode ¶
func Argon2Encode ¶
func ErrAuthenticationFailed ¶ added in v0.5.0
func ErrAuthorizationFailed ¶ added in v0.5.0
func ErrPasswordEncodingFailed ¶ added in v0.5.0
func ErrPasswordMatchingFailed ¶ added in v0.5.0
func ErrPasswordUpgradeEncodingValidationFailed ¶ added in v0.5.0
func ErrPasswordValidationFailed ¶ added in v0.5.0
func ErrTokenGenerationFailed ¶ added in v0.5.0
func ErrTokenValidationFailed ¶ added in v0.5.0
func GenerateSalt ¶
func GetApplicationFromContext ¶ added in v0.70.0
func Pbkdf2Decode ¶
func Pbkdf2Encode ¶
func ScryptDecode ¶
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 AuthenticationService ¶
type AuthorizationFilter ¶
type AuthorizationService ¶
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
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 NewDelegatingPasswordEncoder ¶
func NewDelegatingPasswordEncoder(encoder PasswordEncoder, options ...DelegatingPasswordEncoderOption) *DelegatingPasswordEncoder
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 InMemoryPrincipalManager ¶
type InMemoryPrincipalManager struct {
// contains filtered or unexported fields
}
func NewInMemoryPrincipalManager ¶
func NewInMemoryPrincipalManager(passwordManager PasswordManager) *InMemoryPrincipalManager
func (*InMemoryPrincipalManager) ChangePassword ¶
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) Update ¶
func (manager *InMemoryPrincipalManager) Update(ctx context.Context, principal *Principal) error
func (*InMemoryPrincipalManager) VerifyResource ¶
type JwtTokenManager ¶
type JwtTokenManager struct {
// contains filtered or unexported fields
}
func NewJwtTokenManager ¶
func NewJwtTokenManager(options ...JwtTokenManagerOption) *JwtTokenManager
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 ¶
func (m *MockAuthenticationEndpoint) EXPECT() *MockAuthenticationEndpointMockRecorder
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 ¶
func (m *MockAuthenticationService) EXPECT() *MockAuthenticationServiceMockRecorder
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.
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 ¶
func (m *MockAuthorizationFilter) EXPECT() *MockAuthorizationFilterMockRecorder
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.
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 ¶
func (m *MockAuthorizationService) EXPECT() *MockAuthorizationServiceMockRecorder
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.
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 ¶
func (m *MockPasswordEncoder) EXPECT() *MockPasswordEncoderMockRecorder
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 ¶
func (m *MockPasswordGenerator) EXPECT() *MockPasswordGeneratorMockRecorder
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 ¶
func (mr *MockPasswordGeneratorMockRecorder) Generate() *gomock.Call
Generate indicates an expected call of Generate.
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 ¶
func (m *MockPasswordManager) EXPECT() *MockPasswordManagerMockRecorder
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 ¶
func (mr *MockPasswordManagerMockRecorder) Generate() *gomock.Call
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.
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 ¶
func (m *MockPrincipalManager) EXPECT() *MockPrincipalManagerMockRecorder
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) 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 ¶
func (m *MockTokenManager) EXPECT() *MockTokenManagerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockTokenManagerMockRecorder ¶
type MockTokenManagerMockRecorder struct {
// contains filtered or unexported fields
}
MockTokenManagerMockRecorder is the mock recorder for MockTokenManager.
type PasswordEncoder ¶
type PasswordGenerator ¶
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"` }
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
Source Files
¶
- authentication_endpoint_default.go
- authentication_service_default.go
- authorization_filter_default.go
- authorization_service_default.go
- errors.go
- functions.go
- mocks.go
- password_encoder_argon2.go
- password_encoder_bcrypt.go
- password_encoder_delegating.go
- password_encoder_pbkdf2.go
- password_encoder_scrypt.go
- password_functions.go
- password_generator_default.go
- password_manager_default.go
- principal_manager_inmemory.go
- token_manager_jwt.go
- types.go