Documentation
¶
Overview ¶
Package acronisext provides Acronis-specific extensions for the go-authkit library.
This package contains custom JWT claim structures and token introspection result definitions that are specifically designed for use within Acronis services and integrations.
Index ¶
- func ParseAccessPolicyURN(s string) (jwt.AccessPolicy, error)
- func RegisterScopeDecoder()
- func ScopeDecoder(raw json.RawMessage) (jwt.Scope, error)
- type JWTClaims
- type TokenIntrospectionResult
- func (ir *TokenIntrospectionResult) Clone() idptoken.IntrospectionResult
- func (ir *TokenIntrospectionResult) GetClaims() jwt.MutableClaims
- func (ir *TokenIntrospectionResult) GetTokenType() string
- func (ir *TokenIntrospectionResult) IsActive() bool
- func (ir *TokenIntrospectionResult) SetIsActive(active bool)
- func (ir *TokenIntrospectionResult) SetTokenType(tokenType string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseAccessPolicyURN ¶ added in v0.27.0
func ParseAccessPolicyURN(s string) (jwt.AccessPolicy, error)
ParseAccessPolicyURN parses an Acronis URN string into an AccessPolicy struct. Expected format: urn:acronis:resource_server:resource_namespace:resource:role where resource is a tenant ID and optionally a resource path, separated by '|'.
EXPERIMENTAL: This function is experimental and the format of the Acronis URN may be changed in the future. Use with caution in production code.
func RegisterScopeDecoder ¶ added in v0.27.0
func RegisterScopeDecoder()
RegisterScopeDecoder registers the Acronis scope decoder for JWT claims parsing. This function is idempotent and safe to call multiple times concurrently. Call this function to enable Acronis-specific scope format support.
func ScopeDecoder ¶ added in v0.27.0
func ScopeDecoder(raw json.RawMessage) (jwt.Scope, error)
ScopeDecoder is a custom decoder that handles Acronis URN format scopes. It supports both array of URN strings and single space-delimited URN string formats.
Types ¶
type JWTClaims ¶
type JWTClaims struct {
jwt.DefaultClaims
// Version is the version of the token claims structure.
Version int `json:"ver,omitempty"`
// UserID is a unique identifier for the user, valid only for user's access token.
// Contains empty string if the token was issued not for a regular user (e.g., for a service account).
UserID string `json:"uid,omitempty"`
// Represents client's origin, valid for Cyber Application connectors' clients.
OriginID string `json:"origin,omitempty"`
// TOTPTime is a timestamp when was the last time user did second factor authentication,
// valid only for user's access token.
TOTPTime int64 `json:"totp_time,omitempty"`
// LoginTOTPTime is a timestamp when the user logged in using TOTP, valid only for user's access token.
LoginTOTPTime int64 `json:"login_totp_time,omitempty"`
// SubType identifies the subject type if the token was issued for a service account.
SubType string `json:"sub_type,omitempty"`
// ClientID identifies the API client (e.g., service account) that requested the token.
// Contains empty string if the token was issued for a regular user.
ClientID string `json:"client_id,omitempty"`
// OwnerTenantUUID is the UUID of the tenant that own the API client that requested the token.
// Contains empty string if the token was issued for a regular user.
OwnerTenantUUID string `json:"owner_tuid,omitempty"`
// Narrowing contains scoping information to narrow down access.
Narrowing [][]string `json:"narrowing,omitempty"`
}
JWTClaims extends the jwt.DefaultClaims with Acronis-specific fields.
type TokenIntrospectionResult ¶
type TokenIntrospectionResult struct {
// Standard introspection fields.
Active bool `json:"active"`
TokenType string `json:"token_type,omitempty"`
// Acronis-specific JWT claims.
JWTClaims
}
TokenIntrospectionResult extends the basic token introspection response with Acronis-specific fields. It embeds JWTClaims to ensure consistency between JWT claims and introspection results.
func (*TokenIntrospectionResult) Clone ¶
func (ir *TokenIntrospectionResult) Clone() idptoken.IntrospectionResult
func (*TokenIntrospectionResult) GetClaims ¶
func (ir *TokenIntrospectionResult) GetClaims() jwt.MutableClaims
func (*TokenIntrospectionResult) GetTokenType ¶
func (ir *TokenIntrospectionResult) GetTokenType() string
func (*TokenIntrospectionResult) IsActive ¶
func (ir *TokenIntrospectionResult) IsActive() bool
func (*TokenIntrospectionResult) SetIsActive ¶
func (ir *TokenIntrospectionResult) SetIsActive(active bool)
func (*TokenIntrospectionResult) SetTokenType ¶
func (ir *TokenIntrospectionResult) SetTokenType(tokenType string)