Documentation
¶
Index ¶
- Constants
- func ScopesFromPermissions(permissions []Permission) []string
- type Permission
- type ScopedTokenClaims
- type Signer
- func (s *Signer) Generate(subject string, duration time.Duration) (string, error)
- func (s *Signer) GenerateScopedToken(claims ScopedTokenClaims, duration time.Duration) (string, error)
- func (s *Signer) GenerateWithClaims(duration time.Duration, extraClaims map[string]string) (string, error)
- func (s *Signer) Validate(tokenString, subject string) error
- func (s *Signer) ValidateAndGetClaims(tokenString string) (jwt.MapClaims, error)
- func (s *Signer) ValidateScopedToken(tokenString string) (*ScopedTokenClaims, error)
Constants ¶
View Source
const ScopedTokenAudience = "superplane_api"
View Source
const ScopedTokenType = "scoped"
Variables ¶
This section is empty.
Functions ¶
func ScopesFromPermissions ¶ added in v0.14.0
func ScopesFromPermissions(permissions []Permission) []string
Types ¶
type Permission ¶ added in v0.14.0
type Permission struct {
ResourceType string `json:"resourceType"`
Action string `json:"action"`
Resources []string `json:"resources,omitempty"`
}
func PermissionsFromScopes ¶ added in v0.14.0
func PermissionsFromScopes(scopes []string) []Permission
type ScopedTokenClaims ¶ added in v0.14.0
type ScopedTokenClaims struct {
Subject string `json:"sub"`
Audience string `json:"aud"`
ExpiresAt *gojwt.NumericDate `json:"exp,omitempty"`
NotBefore *gojwt.NumericDate `json:"nbf,omitempty"`
IssuedAt *gojwt.NumericDate `json:"iat,omitempty"`
TokenType string `json:"token_type"`
OrgID string `json:"org_id"`
Purpose string `json:"purpose"`
Scopes []string `json:"scopes"`
}
func (ScopedTokenClaims) Valid ¶ added in v0.14.0
func (c ScopedTokenClaims) Valid() error
func (ScopedTokenClaims) VerifyAudience ¶ added in v0.14.0
func (c ScopedTokenClaims) VerifyAudience(cmp string, req bool) bool
type Signer ¶
type Signer struct {
Secret string
}
func (*Signer) GenerateScopedToken ¶ added in v0.14.0
func (*Signer) GenerateWithClaims ¶ added in v0.14.0
func (s *Signer) GenerateWithClaims(duration time.Duration, extraClaims map[string]string) (string, error)
GenerateWithClaims creates a JWT with the standard time claims plus any additional custom claims. Extra claims must not override the reserved time claims (iat, nbf, exp).
func (*Signer) ValidateAndGetClaims ¶
ValidateAndGetClaims validates a JWT token and returns the claims
func (*Signer) ValidateScopedToken ¶ added in v0.14.0
func (s *Signer) ValidateScopedToken(tokenString string) (*ScopedTokenClaims, error)
Click to show internal directories.
Click to hide internal directories.