auth

package
v0.8.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth interface {
	OAuth2
	IsOAuth2Enabled() bool
	GetOAuth2CORS() *config.CORSConfig
}

Auth defines the authentication oauth interface

func NewAuth

func NewAuth(logger *zap.Logger, cfg config.AuthConfig) (Auth, error)

NewAuth creates a new auth oauth based on the configuration

type AuthorizationResponse

type AuthorizationResponse struct {
	Code  string
	State string
}

AuthorizationResponse represents the response from the authorization endpoint

type ClientRegistrationResponse

type ClientRegistrationResponse struct {
	ClientID                string   `json:"client_id"`
	ClientSecret            string   `json:"client_secret,omitempty"`
	RedirectURIs            []string `json:"redirect_uris"`
	GrantTypes              []string `json:"grant_types"`
	ResponseTypes           []string `json:"response_types"`
	TokenEndpointAuthMethod string   `json:"token_endpoint_auth_method"`
	Scope                   string   `json:"scope"`
}

ClientRegistrationResponse represents the response from the client registration endpoint

type OAuth2

type OAuth2 interface {
	// ServerMetadata returns the server metadata
	ServerMetadata(r *http.Request) map[string]interface{}

	// Authorize handles the authorization request
	Authorize(ctx context.Context, r *http.Request) (*AuthorizationResponse, error)

	// Token handles the token request
	Token(ctx context.Context, r *http.Request) (*TokenResponse, error)

	// Register handles client registration
	Register(ctx context.Context, r *http.Request) (*ClientRegistrationResponse, error)

	// Revoke handles token revocation
	Revoke(ctx context.Context, r *http.Request) error

	// ValidateToken validates an access token
	ValidateToken(ctx context.Context, token string) error
}

type RegisterRequest

type RegisterRequest struct {
	RedirectURIs    []string `json:"redirect_uris"`
	GrantTypes      []string `json:"grant_types"`
	ResponseTypes   []string `json:"response_types"`
	TokenAuthMethod string   `json:"token_endpoint_auth_method"`
	Scope           string   `json:"scope"`
}

type StorageType

type StorageType string
const (
	// StorageTypeMemory represents an in-memory store
	StorageTypeMemory StorageType = "memory"
	// StorageTypeRedis represents a Redis-based store
	StorageTypeRedis StorageType = "redis"
)

type TokenResponse

type TokenResponse struct {
	AccessToken  string `json:"access_token"`
	TokenType    string `json:"token_type"`
	ExpiresIn    int64  `json:"expires_in,omitempty"`
	RefreshToken string `json:"refresh_token,omitempty"`
	Scope        string `json:"scope,omitempty"`
}

TokenResponse represents the response from the token endpoint

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL