Skip to content

Fix: Remove redundant auth header #107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/lib/api/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const useCrateClusterHeader = 'X-use-crate';
const projectNameHeader = 'X-project';
const workspaceNameHeader = 'X-workspace';
const mcpNameHeader = 'X-mcp';
const mcpAuthHeader = 'X-mcp-authorization';
const contextHeader = 'X-context';
const jqHeader = 'X-jq';
const authHeader = 'Authorization';
Expand Down Expand Up @@ -39,7 +38,6 @@ export const fetchApiServer = async (
headers[workspaceNameHeader] = config.mcpConfig.workspaceName;
headers[mcpNameHeader] = config.mcpConfig.controlPlaneName;
headers[contextHeader] = config.mcpConfig.contextName;
headers[mcpAuthHeader] = config.mcpConfig.mcpAuthorization;
} else {
headers[useCrateClusterHeader] = 'true';
}
Expand Down
1 change: 0 additions & 1 deletion src/lib/api/types/apiConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ type McpConfig = {
workspaceName: string;
controlPlaneName: string;
contextName: string;
mcpAuthorization: string;
};

//syntax basically combines all the atrributes from the types into one
Expand Down
31 changes: 2 additions & 29 deletions src/lib/shared/McpContext.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import {
createContext,
ReactNode,
useContext,
useEffect,
useState,
} from 'react';
import { createContext, ReactNode, useContext } from 'react';
import { ControlPlane as ManagedControlPlaneResource } from '../api/types/crate/controlPlanes.ts';
import { GetAuthPropsForContextName } from '../oidc/shared.ts';
import { AuthProvider, hasAuthParams, useAuth } from 'react-oidc-context';
import { AuthProvider } from 'react-oidc-context';
import {
ApiConfigContext,
ApiConfigProvider,
Expand Down Expand Up @@ -66,29 +60,9 @@ export const McpContextProvider = ({ children, context }: Props) => {
};

function RequireDownstreamLogin(props: { children?: ReactNode }) {
const auth = useAuth();
const mcp = useContext(McpContext);
const [hasTriedSignin, setHasTriedSignin] = useState(false);
const parentApiConfig = useContext(ApiConfigContext);

// automatically sign-in
useEffect(() => {
if (
!hasAuthParams() &&
!auth.isAuthenticated &&
!auth.activeNavigator &&
!auth.isLoading &&
!hasTriedSignin
) {
auth.signinPopup().then((_) => {
setHasTriedSignin(true);
});
}
}, [auth, hasTriedSignin]);

if (!auth.isAuthenticated || auth.isLoading) {
return <>Elevating your permissions</>;
}
return (
<>
<ApiConfigProvider
Expand All @@ -100,7 +74,6 @@ function RequireDownstreamLogin(props: { children?: ReactNode }) {
projectName: mcp.project,
workspaceName: mcp.workspace,
controlPlaneName: mcp.name,
mcpAuthorization: auth.user?.access_token ?? '',
},
}}
>
Expand Down
Loading