auth

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package auth is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMissingKID is returned when the token format is invalid and the kid field is missing in the token header.
	ErrMissingKID = errors.Unauthorized(reasonUnauthorized, "Invalid token format: missing kid field in header")
	// ErrSecretDisabled is returned when the SecretID is disabled.
	ErrSecretDisabled = errors.Unauthorized(reasonUnauthorized, "SecretID is disabled")
)
View Source
var AuthnProviderSet = wire.NewSet(NewAuthn, wire.Bind(new(AuthnInterface), new(*authnImpl)))

AuthnProviderSet is authn providers.

View Source
var AuthzProviderSet = wire.NewSet(NewAuthz, wire.Bind(new(AuthzInterface), new(*authzImpl)), LoggerProviderSet)

AuthzProviderSet defines a wire set for authorization.

View Source
var LoggerProviderSet = wire.NewSet(NewLogger, wire.Bind(new(clog.Logger), new(*kafkaLogger)))

LoggerProviderSet defines a wire set for creating a kafkaLogger instance to implement log.Logger interface.

ProviderSet is a Wire provider set that creates a new instance of auth.

Functions

func NewAuth

func NewAuth(authn AuthnInterface, authz AuthzInterface) *auth

NewAuth is a constructor function that creates a new instance of auth struct.

func NewAuthn

func NewAuthn(setter TemporarySecretSetter) (*authnImpl, error)

NewAuthn returns a new instance of authn.

func NewAuthz

func NewAuthz(db *gorm.DB, redisOpts *genericoptions.RedisOptions, logger clog.Logger) (*authzImpl, error)

NewAuthz creates a new authorization instance using the provided database, Redis options, and logger.

func NewLogger

func NewLogger(kafkaOpts *genericoptions.KafkaOptions) (*kafkaLogger, error)

NewLogger creates a new kafkaLogger instance.

Types

type AuditMessage

type AuditMessage struct {
	Matcher   string     `protobuf:"bytes,1,opt,name=matcher,proto3" json:"matcher,omitempty"`
	Request   []any      `protobuf:"bytes,2,opt,name=request,proto3" json:"request,omitempty"`
	Result    bool       `protobuf:"bytes,3,opt,name=result,proto3" json:"result,omitempty"`
	Explains  [][]string `protobuf:"bytes,4,opt,name=explains,proto3" json:"explains,omitempty"`
	Timestamp int64      `protobuf:"bytes,5,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
}

AuditMessage is the message structure for log messages.

type AuthProvider

type AuthProvider interface {
	AuthnInterface
	AuthzInterface
}

AuthProvider is an interface that combines both the AuthnInterface and AuthzInterface interfaces.

type AuthnInterface

type AuthnInterface interface {
	// Sign is used to generate a access token. userID is the jwt identity key.
	Sign(ctx context.Context, userID string) (authn.IToken, error)
	// Verify is used to verify a access token. If the verification
	// is successful, userID will be returned.
	Verify(accessToken string) (string, error)
}

AuthnInterface defines the interface for authentication.

type AuthzInterface

type AuthzInterface interface {
	Authorize(rvals ...any) (bool, error)
}

AuthzInterface defines the interface for authorization.

type MockAuthProvider

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

MockAuthProvider is a mock of AuthProvider interface.

func NewMockAuthProvider

func NewMockAuthProvider(ctrl *gomock.Controller) *MockAuthProvider

NewMockAuthProvider creates a new mock instance.

func (*MockAuthProvider) Authorize

func (m *MockAuthProvider) Authorize(arg0 ...any) (bool, error)

Authorize mocks base method.

func (*MockAuthProvider) EXPECT

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

func (*MockAuthProvider) Sign

func (m *MockAuthProvider) Sign(arg0 context.Context, arg1 string) (authn.IToken, error)

Sign mocks base method.

func (*MockAuthProvider) Verify

func (m *MockAuthProvider) Verify(arg0 string) (string, error)

Verify mocks base method.

type MockAuthProviderMockRecorder

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

MockAuthProviderMockRecorder is the mock recorder for MockAuthProvider.

func (*MockAuthProviderMockRecorder) Authorize

func (mr *MockAuthProviderMockRecorder) Authorize(arg0 ...any) *gomock.Call

Authorize indicates an expected call of Authorize.

func (*MockAuthProviderMockRecorder) Sign

func (mr *MockAuthProviderMockRecorder) Sign(arg0, arg1 any) *gomock.Call

Sign indicates an expected call of Sign.

func (*MockAuthProviderMockRecorder) Verify

func (mr *MockAuthProviderMockRecorder) Verify(arg0 any) *gomock.Call

Verify indicates an expected call of Verify.

type MockAuthnInterface

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

MockAuthnInterface is a mock of AuthnInterface interface.

func NewMockAuthnInterface

func NewMockAuthnInterface(ctrl *gomock.Controller) *MockAuthnInterface

NewMockAuthnInterface creates a new mock instance.

func (*MockAuthnInterface) EXPECT

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

func (*MockAuthnInterface) Sign

func (m *MockAuthnInterface) Sign(arg0 context.Context, arg1 string) (authn.IToken, error)

Sign mocks base method.

func (*MockAuthnInterface) Verify

func (m *MockAuthnInterface) Verify(arg0 string) (string, error)

Verify mocks base method.

type MockAuthnInterfaceMockRecorder

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

MockAuthnInterfaceMockRecorder is the mock recorder for MockAuthnInterface.

func (*MockAuthnInterfaceMockRecorder) Sign

func (mr *MockAuthnInterfaceMockRecorder) Sign(arg0, arg1 any) *gomock.Call

Sign indicates an expected call of Sign.

func (*MockAuthnInterfaceMockRecorder) Verify

func (mr *MockAuthnInterfaceMockRecorder) Verify(arg0 any) *gomock.Call

Verify indicates an expected call of Verify.

type MockAuthzInterface

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

MockAuthzInterface is a mock of AuthzInterface interface.

func NewMockAuthzInterface

func NewMockAuthzInterface(ctrl *gomock.Controller) *MockAuthzInterface

NewMockAuthzInterface creates a new mock instance.

func (*MockAuthzInterface) Authorize

func (m *MockAuthzInterface) Authorize(arg0 ...any) (bool, error)

Authorize mocks base method.

func (*MockAuthzInterface) EXPECT

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

type MockAuthzInterfaceMockRecorder

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

MockAuthzInterfaceMockRecorder is the mock recorder for MockAuthzInterface.

func (*MockAuthzInterfaceMockRecorder) Authorize

func (mr *MockAuthzInterfaceMockRecorder) Authorize(arg0 ...any) *gomock.Call

Authorize indicates an expected call of Authorize.

type TemporarySecretSetter

type TemporarySecretSetter interface {
	Get(ctx context.Context, secretID string) (*model.SecretM, error)
	Set(ctx context.Context, userID string, expires int64) (*model.SecretM, error)
}

SecretSetter is used to set or get a temporary secret key pairs.

Jump to

Keyboard shortcuts

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