Documentation
¶
Index ¶
- func AuthMiddleware(next http.Handler) http.Handler
- func AuthMiddlewareWithClient(authClient AuthClient) func(http.Handler) http.Handler
- func OptionalAuthMiddleware(next http.Handler) http.Handler
- type AuthClient
- type Config
- type SessionInfo
- type SupabaseAuthClient
- type UserClaims
- type UserContextKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuthMiddlewareWithClient ¶
func AuthMiddlewareWithClient(authClient AuthClient) func(http.Handler) http.Handler
Types ¶
type AuthClient ¶
type Config ¶
Config holds Supabase authentication configuration
func NewConfigFromEnv ¶
NewConfigFromEnv creates auth config from environment variables
type SessionInfo ¶
type SessionInfo struct {
IsValid bool `json:"is_valid"`
ExpiresAt int64 `json:"expires_at,omitempty"`
RefreshNeeded bool `json:"refresh_needed"`
UserID string `json:"user_id,omitempty"`
Email string `json:"email,omitempty"`
}
func ValidateSession ¶
func ValidateSession(tokenString string) *SessionInfo
type SupabaseAuthClient ¶
type SupabaseAuthClient struct{}
func NewSupabaseAuthClient ¶
func NewSupabaseAuthClient() *SupabaseAuthClient
func (*SupabaseAuthClient) ExtractTokenFromRequest ¶
func (s *SupabaseAuthClient) ExtractTokenFromRequest(r *http.Request) (string, error)
func (*SupabaseAuthClient) SetUserInContext ¶
func (s *SupabaseAuthClient) SetUserInContext(r *http.Request, user *UserClaims) *http.Request
func (*SupabaseAuthClient) ValidateToken ¶
func (s *SupabaseAuthClient) ValidateToken(ctx context.Context, token string) (*UserClaims, error)
type UserClaims ¶
type UserClaims struct {
jwt.RegisteredClaims
UserID string `json:"sub"`
Email string `json:"email"`
AppMetadata map[string]any `json:"app_metadata"`
UserMetadata map[string]any `json:"user_metadata"`
Role string `json:"role"`
}
func GetUserFromContext ¶
func GetUserFromContext(ctx context.Context) (*UserClaims, bool)
Click to show internal directories.
Click to hide internal directories.