- Deleted the OAuth interface and related types that were previously defined in the `interfaces.go` and `types.go` files, streamlining the codebase. - Updated the `oauth.go` file to integrate user and client providers directly, enhancing the service's functionality and reducing complexity. - Refactored the user information retrieval method to utilize the new user provider structure, ensuring compatibility with the updated architecture.
50 lines
2.1 KiB
Go
50 lines
2.1 KiB
Go
package oauth
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/yaoapp/yao/openapi/oauth/types"
|
|
)
|
|
|
|
// GenerateCodeChallenge generates a code challenge from a code verifier
|
|
// This is used for PKCE (Proof Key for Code Exchange) flow
|
|
func (s *Service) GenerateCodeChallenge(ctx context.Context, codeVerifier string, method string) (string, error) {
|
|
// TODO: Implement code challenge generation
|
|
return "", nil
|
|
}
|
|
|
|
// ValidateCodeChallenge validates a code verifier against a code challenge
|
|
// This verifies the PKCE code challenge during token exchange
|
|
func (s *Service) ValidateCodeChallenge(ctx context.Context, codeVerifier string, codeChallenge string, method string) error {
|
|
// TODO: Implement code challenge validation
|
|
return nil
|
|
}
|
|
|
|
// ValidateStateParameter validates OAuth state parameters
|
|
// This prevents CSRF attacks by verifying state parameters
|
|
func (s *Service) ValidateStateParameter(ctx context.Context, state string, clientID string) (*types.ValidationResult, error) {
|
|
// TODO: Implement state parameter validation
|
|
return nil, nil
|
|
}
|
|
|
|
// GenerateStateParameter generates a secure state parameter
|
|
// This creates cryptographically secure state values for CSRF protection
|
|
func (s *Service) GenerateStateParameter(ctx context.Context, clientID string) (*types.StateParameter, error) {
|
|
// TODO: Implement state parameter generation
|
|
return nil, nil
|
|
}
|
|
|
|
// ValidateRedirectURI validates redirect URIs against registered URIs
|
|
func (s *Service) ValidateRedirectURI(ctx context.Context, redirectURI string, registeredURIs []string) (*types.ValidationResult, error) {
|
|
// This method signature doesn't match our ClientProvider interface
|
|
// We need the clientID to validate, so let's assume we can extract it from context
|
|
// or we need to modify the interface
|
|
return &types.ValidationResult{Valid: true}, nil
|
|
}
|
|
|
|
// PushAuthorizationRequest processes a pushed authorization request
|
|
// This implements RFC 9126 for enhanced security
|
|
func (s *Service) PushAuthorizationRequest(ctx context.Context, request *types.PushedAuthorizationRequest) (*types.PushedAuthorizationResponse, error) {
|
|
// TODO: Implement pushed authorization request
|
|
return nil, nil
|
|
}
|