feat: add OAuth proxy support to eliminate CORS issues
Add server-side proxy endpoints for OAuth discovery, client registration, and token exchange to avoid CORS issues when using proxy connection mode. Server proxy endpoints: - GET /oauth/resource-metadata - proxies OAuth protected resource metadata - GET /oauth/metadata - proxies OAuth authorization server metadata - POST /oauth/register - proxies dynamic client registration - POST /oauth/token - proxies token exchange Client changes: - Construct correct RFC 9728/8414 path-aware well-known URLs client-side - Route all OAuth discovery through proxy when in proxy connection mode - Eliminate direct browser fetches that fail with CORS in proxy mode
This commit is contained in:
parent
7c8b031ffa
commit
b083d4e1a0
1 changed files with 990 additions and 44 deletions
|
|
@ -7,12 +7,15 @@ import { OAuthFlowProgress } from "./OAuthFlowProgress";
|
|||
import { OAuthStateMachine } from "../lib/oauth-state-machine";
|
||||
import { SESSION_KEYS } from "../lib/constants";
|
||||
import { validateRedirectUrl } from "@/utils/urlValidation";
|
||||
import { InspectorConfig } from "../lib/configurationTypes";
|
||||
|
||||
export interface AuthDebuggerProps {
|
||||
serverUrl: string;
|
||||
onBack: () => void;
|
||||
authState: AuthDebuggerState;
|
||||
updateAuthState: (updates: Partial<AuthDebuggerState>) => void;
|
||||
connectionType: "direct" | "proxy";
|
||||
config: InspectorConfig;
|
||||
}
|
||||
|
||||
interface StatusMessageProps {
|
||||
|
|
@ -60,6 +63,8 @@ const AuthDebugger = ({
|
|||
onBack,
|
||||
authState,
|
||||
updateAuthState,
|
||||
connectionType,
|
||||
config,
|
||||
}: AuthDebuggerProps) => {
|
||||
// Check for existing tokens on mount
|
||||
useEffect(() => {
|
||||
|
|
@ -103,8 +108,9 @@ const AuthDebugger = ({
|
|||
}, [serverUrl, updateAuthState]);
|
||||
|
||||
const stateMachine = useMemo(
|
||||
() => new OAuthStateMachine(serverUrl, updateAuthState),
|
||||
[serverUrl, updateAuthState],
|
||||
() =>
|
||||
new OAuthStateMachine(serverUrl, updateAuthState, connectionType, config),
|
||||
[serverUrl, updateAuthState, connectionType, config],
|
||||
);
|
||||
|
||||
const proceedToNextStep = useCallback(async () => {
|
||||
|
|
@ -150,11 +156,16 @@ const AuthDebugger = ({
|
|||
latestError: null,
|
||||
};
|
||||
|
||||
const oauthMachine = new OAuthStateMachine(serverUrl, (updates) => {
|
||||
// Update our temporary state during the process
|
||||
currentState = { ...currentState, ...updates };
|
||||
// But don't call updateAuthState yet
|
||||
});
|
||||
const oauthMachine = new OAuthStateMachine(
|
||||
serverUrl,
|
||||
(updates) => {
|
||||
// Update our temporary state during the process
|
||||
currentState = { ...currentState, ...updates };
|
||||
// But don't call updateAuthState yet
|
||||
},
|
||||
connectionType,
|
||||
config,
|
||||
);
|
||||
|
||||
// Manually step through each stage of the OAuth flow
|
||||
while (currentState.oauthStep !== "complete") {
|
||||
|
|
|
|||
Loading…
Reference in a new issue