Documentation
¶
Index ¶
- Variables
- func NewAuth(authn AuthnInterface, authz AuthzInterface) *auth
- func NewAuthn(setter TemporarySecretSetter) (*authnImpl, error)
- func NewAuthz(db *gorm.DB, redisOpts *genericoptions.RedisOptions, logger clog.Logger) (*authzImpl, error)
- func NewLogger(kafkaOpts *genericoptions.KafkaOptions) (*kafkaLogger, error)
- type AuditMessage
- type AuthProvider
- type AuthnInterface
- type AuthzInterface
- type TemporarySecretSetter
Constants ¶
This section is empty.
Variables ¶
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") )
var AuthnProviderSet = wire.NewSet(NewAuthn, wire.Bind(new(AuthnInterface), new(*authnImpl)))
AuthnProviderSet is authn providers.
var AuthzProviderSet = wire.NewSet(NewAuthz, wire.Bind(new(AuthzInterface), new(*authzImpl)), LoggerProviderSet)
AuthzProviderSet defines a wire set for authorization.
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.
var ProviderSet = wire.NewSet(NewAuth, wire.Bind(new(AuthProvider), new(*auth)), AuthnProviderSet, AuthzProviderSet)
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 ¶
AuthzInterface defines the interface for authorization.