authn

package
v0.0.0-...-bc4752d Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package authn is a generated GoMock package.

Package authn is a generated GoMock package.

Index

Constants

View Source
const (
	UserKey = "user"
)

Variables

This section is empty.

Functions

func New

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

type JwtValidator interface {
	Validate(ctx context.Context, token string) error
}

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

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

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

func (*MockJwtValidator) Validate

func (m *MockJwtValidator) Validate(ctx context.Context, token string) error

Validate mocks base method.

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.

type TokenPrincipal

type TokenPrincipal interface {
	IsAuthenticated() bool
	Token() string
}

Jump to

Keyboard shortcuts

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