auth

package
v0.6.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthContextKey contextKey = "auth_context"
)

Variables

This section is empty.

Functions

func RequireAuth

func RequireAuth(next http.Handler) http.Handler

Types

type AuthContext

type AuthContext struct {
	SessionState *session.State
	ClientType   ClientType
	IsValid      bool
}

func GetAuthContext

func GetAuthContext(ctx context.Context) *AuthContext

type AuthHandler

type AuthHandler struct {
	// contains filtered or unexported fields
}

func NewAuthHandler

func NewAuthHandler(oidc OIDCProvider, jwtService *JWTService, cookieSigningKey, cookieEncryptionKey []byte) *AuthHandler

func (*AuthHandler) HandleAuthorize

func (ah *AuthHandler) HandleAuthorize(w http.ResponseWriter, r *http.Request)

func (*AuthHandler) HandleCallback

func (ah *AuthHandler) HandleCallback(w http.ResponseWriter, r *http.Request)

type AuthHandlerInterface

type AuthHandlerInterface interface {
	HandleAuthorize(w http.ResponseWriter, r *http.Request)
	HandleCallback(w http.ResponseWriter, r *http.Request)
}

type AuthMiddleware

type AuthMiddleware struct {
	// contains filtered or unexported fields
}

func NewAuthMiddleware

func NewAuthMiddleware(jwtService *JWTService, cookieSigningKey, cookieEncryptionKey []byte) *AuthMiddleware

func (*AuthMiddleware) AuthenticateRequest

func (am *AuthMiddleware) AuthenticateRequest(next http.Handler) http.Handler

type AuthResponse

type AuthResponse struct {
	Success bool                   `json:"success"`
	Data    interface{}            `json:"data,omitempty"`
	Error   string                 `json:"error,omitempty"`
	Message string                 `json:"message,omitempty"`
	Meta    map[string]interface{} `json:"meta,omitempty"`
}

type AuthorizeRequest

type AuthorizeRequest struct {
	RedirectURL           string     `json:"redirect_url" form:"redirect_url"`
	ClientSideRedirectURL string     `json:"client_side_redirect_url" form:"client_side_redirect_url"`
	SessionID             string     `json:"session_id" form:"session_id"`
	ClusterID             string     `json:"cluster_id" form:"cluster_id"`
	ClientType            ClientType `json:"client_type" form:"client_type"`
}

type CallbackRequest

type CallbackRequest struct {
	Code             string `json:"code" form:"code"`
	State            string `json:"state" form:"state"`
	Error            string `json:"error,omitempty" form:"error"`
	ErrorDescription string `json:"error_description,omitempty" form:"error_description"`
}

type Claims

type Claims struct {
	Subject     string `json:"sub"`
	Issuer      string `json:"iss"`
	SessionID   string `json:"sid"`
	ClusterID   string `json:"cid"`
	RedirectURL string `json:"red,omitempty"`
	jwt.RegisteredClaims
}

type ClientType

type ClientType string
const (
	ClientTypeUI  ClientType = "ui"
	ClientTypeCLI ClientType = "cli"
)

type JWTService

type JWTService struct {
	// contains filtered or unexported fields
}

func NewJWTService

func NewJWTService(issuer string) (*JWTService, error)

func (*JWTService) GenerateToken

func (js *JWTService) GenerateToken(subject, oidcIssuer, sessionID, clusterID, redirectURL string, expiration time.Duration) (string, error)

func (*JWTService) GetPublicKey

func (js *JWTService) GetPublicKey() *rsa.PublicKey

func (*JWTService) ValidateToken

func (js *JWTService) ValidateToken(tokenString string) (*Claims, error)

type OIDCProvider

type OIDCProvider interface {
	GetOIDCProvider(ctx context.Context) (*OIDCServiceProvider, error)
}

type OIDCServiceProvider

type OIDCServiceProvider struct {
	// contains filtered or unexported fields
}

func NewOIDCServiceProvider

func NewOIDCServiceProvider(ctx context.Context, clientID, clientSecret, redirectURI, issuerURL string) (*OIDCServiceProvider, error)

func NewOIDCServiceProviderWithTLS

func NewOIDCServiceProviderWithTLS(
	ctx context.Context,
	clientID, clientSecret, redirectURI, issuerURL string,
	tlsConfig *tls.Config,
) (*OIDCServiceProvider, error)

func (*OIDCServiceProvider) GetTLSConfig

func (o *OIDCServiceProvider) GetTLSConfig() *tls.Config

func (*OIDCServiceProvider) OIDCProviderConfig

func (o *OIDCServiceProvider) OIDCProviderConfig(scopes []string) *oauth2.Config

type TokenResponse

type TokenResponse struct {
	AccessToken  string    `json:"access_token"`
	TokenType    string    `json:"token_type"`
	ExpiresIn    int64     `json:"expires_in"`
	ExpiresAt    time.Time `json:"expires_at"`
	Scope        string    `json:"scope,omitempty"`
	RefreshToken string    `json:"refresh_token,omitempty"`

	ClusterID string `json:"cluster_id,omitempty"`
}

Jump to

Keyboard shortcuts

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