auth

package
v0.2.36 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServiceTokenType = "service_token"
)

Variables

View Source
var ErrInvalidToken = errors.New("invalid token")

Functions

This section is empty.

Types

type CreateServiceTokenRequest added in v0.2.26

type CreateServiceTokenRequest struct {
	Req           *configurationv1.CreateServiceTokenRequest
	CurrentUserID int32
}

type GenerateTokenRequest added in v0.2.26

type GenerateTokenRequest struct {
	TTL       time.Duration
	TokenType string
	User      *database.User
}

type JwtClaims

type JwtClaims struct {
	*jwt.RegisteredClaims
	UserID    int32  `json:"user_id"`
	TokenType string `json:"token_type"`
}

type JwtSvc added in v0.2.26

type JwtSvc interface {
	CreateServiceToken(
		_ context.Context,
		req *GenerateTokenRequest,
	) (*JwtClaims, string, error)

	RevokeServiceToken(
		ctx context.Context,
		jti string,
		originalExpiresAt time.Time,
	) error
}

type KeyGenerator

type KeyGenerator struct {
}

func NewKeyGenerator

func NewKeyGenerator() *KeyGenerator

func (*KeyGenerator) Generate

func (k *KeyGenerator) Generate() *rsa.PrivateKey

func (*KeyGenerator) Save

func (k *KeyGenerator) Save(key *rsa.PrivateKey, name string) error

func (*KeyGenerator) Serialize

func (k *KeyGenerator) Serialize(key *rsa.PrivateKey) []byte

type Service

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

func NewService

func NewService(
	secretKey string,
	ttl time.Duration,
) (*Service, error)

func (*Service) CheckClaims

func (j *Service) CheckClaims(
	token *jwt2.Token,
) (*JwtClaims, error)

func (*Service) CreateServiceToken added in v0.2.26

func (j *Service) CreateServiceToken(
	_ context.Context,
	req *GenerateTokenRequest,
) (*JwtClaims, string, error)

func (*Service) GenerateToken

func (j *Service) GenerateToken(
	_ context.Context,
	user *database.User,
) (string, error)

func (*Service) RevokeServiceToken added in v0.2.26

func (j *Service) RevokeServiceToken(
	ctx context.Context,
	jti string,
	originalExpiryTime time.Time,
) error

func (*Service) ValidateToken

func (j *Service) ValidateToken(
	_ context.Context,
	tokenString string,
) (*JwtClaims, error)

type ServiceTokenMapper added in v0.2.26

type ServiceTokenMapper interface {
	MapServiceToken(ctx context.Context, token *database.ServiceToken) *gomoneypbv1.ServiceToken
}

type ServiceTokenService added in v0.2.26

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

func NewServiceTokenService added in v0.2.26

func NewServiceTokenService(
	jwtSvc JwtSvc,
	mapper ServiceTokenMapper,
) *ServiceTokenService

func (*ServiceTokenService) CreateServiceToken added in v0.2.26

func (*ServiceTokenService) GetServiceTokens added in v0.2.26

func (*ServiceTokenService) RevokeServiceToken added in v0.2.26

Jump to

Keyboard shortcuts

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