Skip to content

Commit bc1ca95

Browse files
add client secret option
1 parent b025bff commit bc1ca95

File tree

4 files changed

+62
-2
lines changed

4 files changed

+62
-2
lines changed

client/src/App.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ const App = () => {
141141
return localStorage.getItem("lastOauthScope") || "";
142142
});
143143

144+
const [oauthClientSecret, setOauthClientSecret] = useState<string>(() => {
145+
return localStorage.getItem("lastOauthClientSecret") || "";
146+
});
147+
144148
// Custom headers state with migration from legacy auth
145149
const [customHeaders, setCustomHeaders] = useState<CustomHeaders>(() => {
146150
const savedHeaders = localStorage.getItem("lastCustomHeaders");
@@ -262,6 +266,7 @@ const App = () => {
262266
env,
263267
customHeaders,
264268
oauthClientId,
269+
oauthClientSecret,
265270
oauthScope,
266271
config,
267272
connectionType,
@@ -394,6 +399,10 @@ const App = () => {
394399
localStorage.setItem("lastOauthScope", oauthScope);
395400
}, [oauthScope]);
396401

402+
useEffect(() => {
403+
localStorage.setItem("lastOauthClientSecret", oauthClientSecret);
404+
}, [oauthClientSecret]);
405+
397406
useEffect(() => {
398407
saveInspectorConfig(CONFIG_LOCAL_STORAGE_KEY, config);
399408
}, [config]);
@@ -900,6 +909,8 @@ const App = () => {
900909
setCustomHeaders={setCustomHeaders}
901910
oauthClientId={oauthClientId}
902911
setOauthClientId={setOauthClientId}
912+
oauthClientSecret={oauthClientSecret}
913+
setOauthClientSecret={setOauthClientSecret}
903914
oauthScope={oauthScope}
904915
setOauthScope={setOauthScope}
905916
onConnect={connectMcpServer}

client/src/components/Sidebar.tsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ interface SidebarProps {
5858
setCustomHeaders: (headers: CustomHeadersType) => void;
5959
oauthClientId: string;
6060
setOauthClientId: (id: string) => void;
61+
oauthClientSecret: string;
62+
setOauthClientSecret: (secret: string) => void;
6163
oauthScope: string;
6264
setOauthScope: (scope: string) => void;
6365
onConnect: () => void;
@@ -87,6 +89,8 @@ const Sidebar = ({
8789
setCustomHeaders,
8890
oauthClientId,
8991
setOauthClientId,
92+
oauthClientSecret,
93+
setOauthClientSecret,
9094
oauthScope,
9195
setOauthScope,
9296
onConnect,
@@ -104,6 +108,7 @@ const Sidebar = ({
104108
const [showAuthConfig, setShowAuthConfig] = useState(false);
105109
const [showConfig, setShowConfig] = useState(false);
106110
const [shownEnvVars, setShownEnvVars] = useState<Set<string>>(new Set());
111+
const [showClientSecret, setShowClientSecret] = useState(false);
107112
const [copiedServerEntry, setCopiedServerEntry] = useState(false);
108113
const [copiedServerFile, setCopiedServerFile] = useState(false);
109114
const { toast } = useToast();
@@ -555,6 +560,38 @@ const Sidebar = ({
555560
data-testid="oauth-client-id-input"
556561
className="font-mono"
557562
/>
563+
<label className="text-sm font-medium">
564+
Client Secret
565+
</label>
566+
<div className="flex gap-2">
567+
<Input
568+
type={showClientSecret ? "text" : "password"}
569+
placeholder="Client Secret (optional)"
570+
onChange={(e) => setOauthClientSecret(e.target.value)}
571+
value={oauthClientSecret}
572+
data-testid="oauth-client-secret-input"
573+
className="font-mono"
574+
/>
575+
<Button
576+
variant="outline"
577+
size="icon"
578+
className="h-9 w-9 p-0 shrink-0"
579+
onClick={() => setShowClientSecret(!showClientSecret)}
580+
aria-label={
581+
showClientSecret ? "Hide secret" : "Show secret"
582+
}
583+
aria-pressed={showClientSecret}
584+
title={
585+
showClientSecret ? "Hide secret" : "Show secret"
586+
}
587+
>
588+
{showClientSecret ? (
589+
<Eye className="h-4 w-4" aria-hidden="true" />
590+
) : (
591+
<EyeOff className="h-4 w-4" aria-hidden="true" />
592+
)}
593+
</Button>
594+
</div>
558595
<label className="text-sm font-medium">
559596
Redirect URL
560597
</label>

client/src/components/__tests__/Sidebar.test.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ describe("Sidebar", () => {
4444
setSseUrl: jest.fn(),
4545
oauthClientId: "",
4646
setOauthClientId: jest.fn(),
47+
oauthClientSecret: "",
48+
setOauthClientSecret: jest.fn(),
4749
oauthScope: "",
4850
setOauthScope: jest.fn(),
4951
env: {},

client/src/lib/hooks/useConnection.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ interface UseConnectionOptions {
6767
// Custom headers support
6868
customHeaders?: CustomHeaders;
6969
oauthClientId?: string;
70+
oauthClientSecret?: string;
7071
oauthScope?: string;
7172
config: InspectorConfig;
7273
connectionType?: "direct" | "proxy";
@@ -89,6 +90,7 @@ export function useConnection({
8990
env,
9091
customHeaders,
9192
oauthClientId,
93+
oauthClientSecret,
9294
oauthScope,
9395
config,
9496
connectionType = "proxy",
@@ -125,12 +127,20 @@ export function useConnection({
125127
return;
126128
}
127129

130+
const clientInformation: { client_id: string; client_secret?: string } = {
131+
client_id: oauthClientId,
132+
};
133+
134+
if (oauthClientSecret) {
135+
clientInformation.client_secret = oauthClientSecret;
136+
}
137+
128138
saveClientInformationToSessionStorage({
129139
serverUrl: sseUrl,
130-
clientInformation: { client_id: oauthClientId },
140+
clientInformation,
131141
isPreregistered: true,
132142
});
133-
}, [oauthClientId, sseUrl]);
143+
}, [oauthClientId, oauthClientSecret, sseUrl]);
134144

135145
const pushHistory = (request: object, response?: object) => {
136146
setRequestHistory((prev) => [

0 commit comments

Comments
 (0)