Documentation
¶
Index ¶
- Constants
- Variables
- type CreateServiceTokenRequest
- type GenerateTokenRequest
- type JwtClaims
- type JwtSvc
- type KeyGenerator
- type Service
- func (j *Service) CheckClaims(token *jwt2.Token) (*JwtClaims, error)
- func (j *Service) CreateServiceToken(_ context.Context, req *GenerateTokenRequest) (*JwtClaims, string, error)
- func (j *Service) GenerateToken(_ context.Context, user *database.User) (string, error)
- func (j *Service) RevokeServiceToken(ctx context.Context, jti string, originalExpiryTime time.Time) error
- func (j *Service) ValidateToken(_ context.Context, tokenString string) (*JwtClaims, error)
- type ServiceTokenMapper
- type ServiceTokenService
- func (s *ServiceTokenService) CreateServiceToken(ctx context.Context, req *CreateServiceTokenRequest) (*configurationv1.CreateServiceTokenResponse, error)
- func (s *ServiceTokenService) GetServiceTokens(ctx context.Context, req *configurationv1.GetServiceTokensRequest) (*configurationv1.GetServiceTokensResponse, error)
- func (s *ServiceTokenService) RevokeServiceToken(ctx context.Context, req *configurationv1.RevokeServiceTokenRequest) (*configurationv1.RevokeServiceTokenResponse, error)
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 JwtClaims ¶
type JwtClaims struct {
*jwt.RegisteredClaims
UserID int32 `json:"user_id"`
TokenType string `json:"token_type"`
}
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 (*Service) CheckClaims ¶
func (*Service) CreateServiceToken ¶ added in v0.2.26
func (*Service) GenerateToken ¶
func (*Service) RevokeServiceToken ¶ added in v0.2.26
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 (s *ServiceTokenService) CreateServiceToken( ctx context.Context, req *CreateServiceTokenRequest, ) (*configurationv1.CreateServiceTokenResponse, error)
func (*ServiceTokenService) GetServiceTokens ¶ added in v0.2.26
func (s *ServiceTokenService) GetServiceTokens( ctx context.Context, req *configurationv1.GetServiceTokensRequest, ) (*configurationv1.GetServiceTokensResponse, error)
func (*ServiceTokenService) RevokeServiceToken ¶ added in v0.2.26
func (s *ServiceTokenService) RevokeServiceToken( ctx context.Context, req *configurationv1.RevokeServiceTokenRequest, ) (*configurationv1.RevokeServiceTokenResponse, error)
Click to show internal directories.
Click to hide internal directories.