Documentation
¶
Index ¶
- Constants
- func InitSubModule() error
- func PrincipalKindFromClaims(claims jwt.Claims) corectx.PrincipalKind
- func UserTypeClaims(userType string) map[string]any
- type AuthTokenService
- type AuthTokenServiceImpl
- type CreateJwtParam
- type CreateJwtResult
- type JwtPurpose
- type NewAuthTokenServiceImplParam
- type VerifyJwtParam
- type VerifyJwtResult
Constants ¶
View Source
const ( JwtAlgoHs256 = "HS256" JwtAlgoRs256 = "RS256" JwtEdDsa = "EdDSA" JwtTimeToleranceMins = 3 JwtAccessTokenExpiryMax = 60 * 24 // 1 day JwtRefreshTokenExpiryMax = 60 * 24 * 7 // 7 days JwtRefreshTokenExpiryMin = 15 // 15 minutes )
View Source
const ( JwtPurposeAccessToken = JwtPurpose("access_token") JwtPurposeRefreshToken = JwtPurpose("refresh_token") )
View Source
const JwtClaimUserType = "usrtype"
JwtClaimUserType carries the IAM user type (`user` | `service`) of the token's subject in the access and refresh tokens. Its values are the principal kinds they map to.
Variables ¶
This section is empty.
Functions ¶
func InitSubModule ¶
func InitSubModule() error
func PrincipalKindFromClaims ¶
func PrincipalKindFromClaims(claims jwt.Claims) corectx.PrincipalKind
PrincipalKindFromClaims maps the user type claim to the principal kind of the request. A token without the claim predates it and was issued to a person, so it answers user, which keeps every token issued before the claim existed working exactly as it did.
func UserTypeClaims ¶
UserTypeClaims is the custom-claim set CreateJwt needs to carry userType.
Types ¶
type AuthTokenService ¶
type AuthTokenService interface {
CreateJwt(ctx corectx.Context, param CreateJwtParam) (*CreateJwtResult, error)
VerifyJwt(ctx corectx.Context, param VerifyJwtParam) (*VerifyJwtResult, error)
}
func NewAuthTokenServiceImpl ¶
func NewAuthTokenServiceImpl(param NewAuthTokenServiceImplParam) AuthTokenService
type AuthTokenServiceImpl ¶
type AuthTokenServiceImpl struct {
// contains filtered or unexported fields
}
func (*AuthTokenServiceImpl) CreateJwt ¶
func (this *AuthTokenServiceImpl) CreateJwt(ctx corectx.Context, param CreateJwtParam) (*CreateJwtResult, error)
func (*AuthTokenServiceImpl) VerifyJwt ¶
func (this *AuthTokenServiceImpl) VerifyJwt(ctx corectx.Context, param VerifyJwtParam) (*VerifyJwtResult, error)
type CreateJwtParam ¶
type CreateJwtParam struct {
// Custom claims other than the registered claims.
// Any claims collision with the registered claims will be overridden.
CustomClaims map[string]any
Purpose JwtPurpose
// Value of the "jti" claim.
Jti *string
// Value of the "sub" claim.
Sub string
}
type CreateJwtResult ¶
type JwtPurpose ¶
type JwtPurpose string
type NewAuthTokenServiceImplParam ¶
type NewAuthTokenServiceImplParam struct {
dig.In
Logger logging.LoggerService
ConfigSvc config.ConfigService
}
type VerifyJwtParam ¶
type VerifyJwtParam struct {
Token string
}
Click to show internal directories.
Click to hide internal directories.