36 lines
732 B
Go
36 lines
732 B
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/golang-jwt/jwt/v5"
|
|
)
|
|
|
|
type AuthorizationRequest struct {
|
|
UserID string `json:"user_id"`
|
|
Resource string `json:"resource"`
|
|
Action string `json:"action"`
|
|
}
|
|
|
|
type AuthorizationResponse struct {
|
|
Allowed bool `json:"allowed"`
|
|
Reason string `json:"reason,omitempty"`
|
|
}
|
|
|
|
type Claims struct {
|
|
UserID string `json:"user_id"`
|
|
Username string `json:"username"`
|
|
EmailAddress string `json:"email_address"`
|
|
RoleID string `json:"role_id"`
|
|
jwt.RegisteredClaims
|
|
}
|
|
|
|
// ContextKey is a custom type for context keys to avoid collisions
|
|
type ContextKey string
|
|
|
|
// CacheEntry represents a token cache entry
|
|
type CacheEntry struct {
|
|
Claims *Claims
|
|
ExpiresAt time.Time
|
|
}
|