Documentation ¶
Overview ¶
Package authn is a generated GoMock package.
Package authn is a generated GoMock package.
Index ¶
Constants ¶
const (
UserKey = "user"
)
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(auths ...AuthenticationProvider) gin.HandlerFunc
Types ¶
type AuthenticationProvider ¶
type AuthenticationProvider interface { // Authenticate tries to build a TokenPrincipal from the HTTP request. // Returns a TokenPrincipal with user.IsAuthenticated()=true if the request contains valid user information, // otherwise return nil or TokenPrincipal with user.IsAuthenticated()=false. // If an error is returned, the authentication handler abort the request immediately write the error to the gin.Context. Authenticate(req *http.Request) (user TokenPrincipal, err error) }
AuthenticationProvider provides a method to authenticate a request
func NewJwtProvider ¶
func NewJwtProvider(validator JwtValidator) AuthenticationProvider
type JwtValidator ¶
func NewValidator ¶
func NewValidator(issuerUrl string, audience string) (JwtValidator, error)
type MockAuthenticationProvider ¶
type MockAuthenticationProvider struct {
// contains filtered or unexported fields
}
MockAuthenticationProvider is a mock of AuthenticationProvider interface.
func NewMockAuthenticationProvider ¶
func NewMockAuthenticationProvider(ctrl *gomock.Controller) *MockAuthenticationProvider
NewMockAuthenticationProvider creates a new mock instance.
func (*MockAuthenticationProvider) Authenticate ¶
func (m *MockAuthenticationProvider) Authenticate(req *http.Request) (TokenPrincipal, error)
Authenticate mocks base method.
func (*MockAuthenticationProvider) EXPECT ¶
func (m *MockAuthenticationProvider) EXPECT() *MockAuthenticationProviderMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockAuthenticationProviderMockRecorder ¶
type MockAuthenticationProviderMockRecorder struct {
// contains filtered or unexported fields
}
MockAuthenticationProviderMockRecorder is the mock recorder for MockAuthenticationProvider.
func (*MockAuthenticationProviderMockRecorder) Authenticate ¶
func (mr *MockAuthenticationProviderMockRecorder) Authenticate(req interface{}) *gomock.Call
Authenticate indicates an expected call of Authenticate.
type MockJwtValidator ¶
type MockJwtValidator struct {
// contains filtered or unexported fields
}
MockJwtValidator is a mock of JwtValidator interface.
func NewMockJwtValidator ¶
func NewMockJwtValidator(ctrl *gomock.Controller) *MockJwtValidator
NewMockJwtValidator creates a new mock instance.
func (*MockJwtValidator) EXPECT ¶
func (m *MockJwtValidator) EXPECT() *MockJwtValidatorMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockJwtValidatorMockRecorder ¶
type MockJwtValidatorMockRecorder struct {
// contains filtered or unexported fields
}
MockJwtValidatorMockRecorder is the mock recorder for MockJwtValidator.
func (*MockJwtValidatorMockRecorder) Validate ¶
func (mr *MockJwtValidatorMockRecorder) Validate(ctx, token interface{}) *gomock.Call
Validate indicates an expected call of Validate.