mirror of
https://github.com/graphql-hive/console
synced 2026-04-21 14:37:17 +00:00
* feat: support login via okta * add deployment config * feat: automatically start okta login when visiting /auth with okta provider query parameter * remove trailing slash from base url * laurin pls * ... * adjust deployment url * we dont need this * docs: document how to enabled Google and GitHub social login (#511) * docs: document how to enabled Google and GitHub social login * Apply suggestions from code review * Apply suggestions from code review * docs: add Okta instructions * fix typo * add database migration * feat: env decoding * auto generate id * add generates types for the postgres table * implement crud graphql fields for the oidc integration entites * add unique constraint for the oidc domain column * use correct sql query for updating an oidc integration * return organization from deleteOIDCIntegration ok result * add crud forms to the settings page * update integration test fixture value * drop unique constraint for oidc_integrations.domain as this would allow a malicous user to block another account from using a domain * move notice to isolated component * apply url normalization in a central place * implement supertokens provider and overrides for dynamic oidc provider integrations * relocate code to correct files * prettify oidc crud forms * replace Query.isOIDCIntegrationFeatureEnabled with the Organization.viewerCanManageOIDCIntegration field * do not show oidc integrations for personal organizations + disable crud endpoints if the feature is disabled * load oidc integration for the supertokens flow via trpc from the server * prepare encryption secret within constructor * add user to organization upon oidc login * login via oidc does not create a personal organization * redirect oidc user to oidc organization * disallow oidc users to create an organization * disallow oidc accounts joining another organization * add test for updating an oidc integration * enhance ui * add documentation for OIDC SSO * add more tests * import Callout component * update snapshots * rename field User.isLinkedToOIDCIntegration to User.canSwitchOrganization to be more decriptive * add traling new line * gracefully handle unique constraint * upgrade supertokens-auth-react and adjust the code in order to remove the global preApiHook * sync image versions with tests * remove obsolete comment * rename database column * bruv * add test for oidc user deletion
44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
import { NextApiRequest, NextApiResponse } from 'next';
|
|
import { graphql } from '@/lib/api/utils';
|
|
import { env } from '@/env/backend';
|
|
|
|
export async function ensureGithubIntegration(
|
|
req: NextApiRequest,
|
|
input: {
|
|
installationId: string;
|
|
orgId: string;
|
|
}
|
|
) {
|
|
const { orgId, installationId } = input;
|
|
await graphql({
|
|
url: `${env.appBaseUrl}/api/proxy`,
|
|
headers: {
|
|
...req.headers,
|
|
'content-type': 'application/json',
|
|
},
|
|
operationName: 'addGitHubIntegration',
|
|
query: /* GraphQL */ `
|
|
mutation addGitHubIntegration($input: AddGitHubIntegrationInput!) {
|
|
addGitHubIntegration(input: $input)
|
|
}
|
|
`,
|
|
variables: {
|
|
input: {
|
|
organization: orgId,
|
|
installationId: installationId,
|
|
},
|
|
},
|
|
});
|
|
}
|
|
|
|
export default async function githubCallback(req: NextApiRequest, res: NextApiResponse) {
|
|
console.log('GitHub Integration Callback');
|
|
const installationId = req.query.installation_id as string;
|
|
const orgId = req.query.state as string;
|
|
|
|
await ensureGithubIntegration(req, {
|
|
installationId,
|
|
orgId,
|
|
});
|
|
res.redirect(`/${orgId}/settings`);
|
|
}
|