add client secret option
This commit is contained in:
parent
b025bffc9d
commit
bc1ca95aea
4 changed files with 62 additions and 2 deletions
|
|
@ -141,6 +141,10 @@ const App = () => {
|
||||||
return localStorage.getItem("lastOauthScope") || "";
|
return localStorage.getItem("lastOauthScope") || "";
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const [oauthClientSecret, setOauthClientSecret] = useState<string>(() => {
|
||||||
|
return localStorage.getItem("lastOauthClientSecret") || "";
|
||||||
|
});
|
||||||
|
|
||||||
// Custom headers state with migration from legacy auth
|
// Custom headers state with migration from legacy auth
|
||||||
const [customHeaders, setCustomHeaders] = useState<CustomHeaders>(() => {
|
const [customHeaders, setCustomHeaders] = useState<CustomHeaders>(() => {
|
||||||
const savedHeaders = localStorage.getItem("lastCustomHeaders");
|
const savedHeaders = localStorage.getItem("lastCustomHeaders");
|
||||||
|
|
@ -262,6 +266,7 @@ const App = () => {
|
||||||
env,
|
env,
|
||||||
customHeaders,
|
customHeaders,
|
||||||
oauthClientId,
|
oauthClientId,
|
||||||
|
oauthClientSecret,
|
||||||
oauthScope,
|
oauthScope,
|
||||||
config,
|
config,
|
||||||
connectionType,
|
connectionType,
|
||||||
|
|
@ -394,6 +399,10 @@ const App = () => {
|
||||||
localStorage.setItem("lastOauthScope", oauthScope);
|
localStorage.setItem("lastOauthScope", oauthScope);
|
||||||
}, [oauthScope]);
|
}, [oauthScope]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
localStorage.setItem("lastOauthClientSecret", oauthClientSecret);
|
||||||
|
}, [oauthClientSecret]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
saveInspectorConfig(CONFIG_LOCAL_STORAGE_KEY, config);
|
saveInspectorConfig(CONFIG_LOCAL_STORAGE_KEY, config);
|
||||||
}, [config]);
|
}, [config]);
|
||||||
|
|
@ -900,6 +909,8 @@ const App = () => {
|
||||||
setCustomHeaders={setCustomHeaders}
|
setCustomHeaders={setCustomHeaders}
|
||||||
oauthClientId={oauthClientId}
|
oauthClientId={oauthClientId}
|
||||||
setOauthClientId={setOauthClientId}
|
setOauthClientId={setOauthClientId}
|
||||||
|
oauthClientSecret={oauthClientSecret}
|
||||||
|
setOauthClientSecret={setOauthClientSecret}
|
||||||
oauthScope={oauthScope}
|
oauthScope={oauthScope}
|
||||||
setOauthScope={setOauthScope}
|
setOauthScope={setOauthScope}
|
||||||
onConnect={connectMcpServer}
|
onConnect={connectMcpServer}
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,8 @@ interface SidebarProps {
|
||||||
setCustomHeaders: (headers: CustomHeadersType) => void;
|
setCustomHeaders: (headers: CustomHeadersType) => void;
|
||||||
oauthClientId: string;
|
oauthClientId: string;
|
||||||
setOauthClientId: (id: string) => void;
|
setOauthClientId: (id: string) => void;
|
||||||
|
oauthClientSecret: string;
|
||||||
|
setOauthClientSecret: (secret: string) => void;
|
||||||
oauthScope: string;
|
oauthScope: string;
|
||||||
setOauthScope: (scope: string) => void;
|
setOauthScope: (scope: string) => void;
|
||||||
onConnect: () => void;
|
onConnect: () => void;
|
||||||
|
|
@ -87,6 +89,8 @@ const Sidebar = ({
|
||||||
setCustomHeaders,
|
setCustomHeaders,
|
||||||
oauthClientId,
|
oauthClientId,
|
||||||
setOauthClientId,
|
setOauthClientId,
|
||||||
|
oauthClientSecret,
|
||||||
|
setOauthClientSecret,
|
||||||
oauthScope,
|
oauthScope,
|
||||||
setOauthScope,
|
setOauthScope,
|
||||||
onConnect,
|
onConnect,
|
||||||
|
|
@ -104,6 +108,7 @@ const Sidebar = ({
|
||||||
const [showAuthConfig, setShowAuthConfig] = useState(false);
|
const [showAuthConfig, setShowAuthConfig] = useState(false);
|
||||||
const [showConfig, setShowConfig] = useState(false);
|
const [showConfig, setShowConfig] = useState(false);
|
||||||
const [shownEnvVars, setShownEnvVars] = useState<Set<string>>(new Set());
|
const [shownEnvVars, setShownEnvVars] = useState<Set<string>>(new Set());
|
||||||
|
const [showClientSecret, setShowClientSecret] = useState(false);
|
||||||
const [copiedServerEntry, setCopiedServerEntry] = useState(false);
|
const [copiedServerEntry, setCopiedServerEntry] = useState(false);
|
||||||
const [copiedServerFile, setCopiedServerFile] = useState(false);
|
const [copiedServerFile, setCopiedServerFile] = useState(false);
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
|
|
@ -555,6 +560,38 @@ const Sidebar = ({
|
||||||
data-testid="oauth-client-id-input"
|
data-testid="oauth-client-id-input"
|
||||||
className="font-mono"
|
className="font-mono"
|
||||||
/>
|
/>
|
||||||
|
<label className="text-sm font-medium">
|
||||||
|
Client Secret
|
||||||
|
</label>
|
||||||
|
<div className="flex gap-2">
|
||||||
|
<Input
|
||||||
|
type={showClientSecret ? "text" : "password"}
|
||||||
|
placeholder="Client Secret (optional)"
|
||||||
|
onChange={(e) => setOauthClientSecret(e.target.value)}
|
||||||
|
value={oauthClientSecret}
|
||||||
|
data-testid="oauth-client-secret-input"
|
||||||
|
className="font-mono"
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="icon"
|
||||||
|
className="h-9 w-9 p-0 shrink-0"
|
||||||
|
onClick={() => setShowClientSecret(!showClientSecret)}
|
||||||
|
aria-label={
|
||||||
|
showClientSecret ? "Hide secret" : "Show secret"
|
||||||
|
}
|
||||||
|
aria-pressed={showClientSecret}
|
||||||
|
title={
|
||||||
|
showClientSecret ? "Hide secret" : "Show secret"
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{showClientSecret ? (
|
||||||
|
<Eye className="h-4 w-4" aria-hidden="true" />
|
||||||
|
) : (
|
||||||
|
<EyeOff className="h-4 w-4" aria-hidden="true" />
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
<label className="text-sm font-medium">
|
<label className="text-sm font-medium">
|
||||||
Redirect URL
|
Redirect URL
|
||||||
</label>
|
</label>
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,8 @@ describe("Sidebar", () => {
|
||||||
setSseUrl: jest.fn(),
|
setSseUrl: jest.fn(),
|
||||||
oauthClientId: "",
|
oauthClientId: "",
|
||||||
setOauthClientId: jest.fn(),
|
setOauthClientId: jest.fn(),
|
||||||
|
oauthClientSecret: "",
|
||||||
|
setOauthClientSecret: jest.fn(),
|
||||||
oauthScope: "",
|
oauthScope: "",
|
||||||
setOauthScope: jest.fn(),
|
setOauthScope: jest.fn(),
|
||||||
env: {},
|
env: {},
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,7 @@ interface UseConnectionOptions {
|
||||||
// Custom headers support
|
// Custom headers support
|
||||||
customHeaders?: CustomHeaders;
|
customHeaders?: CustomHeaders;
|
||||||
oauthClientId?: string;
|
oauthClientId?: string;
|
||||||
|
oauthClientSecret?: string;
|
||||||
oauthScope?: string;
|
oauthScope?: string;
|
||||||
config: InspectorConfig;
|
config: InspectorConfig;
|
||||||
connectionType?: "direct" | "proxy";
|
connectionType?: "direct" | "proxy";
|
||||||
|
|
@ -89,6 +90,7 @@ export function useConnection({
|
||||||
env,
|
env,
|
||||||
customHeaders,
|
customHeaders,
|
||||||
oauthClientId,
|
oauthClientId,
|
||||||
|
oauthClientSecret,
|
||||||
oauthScope,
|
oauthScope,
|
||||||
config,
|
config,
|
||||||
connectionType = "proxy",
|
connectionType = "proxy",
|
||||||
|
|
@ -125,12 +127,20 @@ export function useConnection({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const clientInformation: { client_id: string; client_secret?: string } = {
|
||||||
|
client_id: oauthClientId,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (oauthClientSecret) {
|
||||||
|
clientInformation.client_secret = oauthClientSecret;
|
||||||
|
}
|
||||||
|
|
||||||
saveClientInformationToSessionStorage({
|
saveClientInformationToSessionStorage({
|
||||||
serverUrl: sseUrl,
|
serverUrl: sseUrl,
|
||||||
clientInformation: { client_id: oauthClientId },
|
clientInformation,
|
||||||
isPreregistered: true,
|
isPreregistered: true,
|
||||||
});
|
});
|
||||||
}, [oauthClientId, sseUrl]);
|
}, [oauthClientId, oauthClientSecret, sseUrl]);
|
||||||
|
|
||||||
const pushHistory = (request: object, response?: object) => {
|
const pushHistory = (request: object, response?: object) => {
|
||||||
setRequestHistory((prev) => [
|
setRequestHistory((prev) => [
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue