mirror of
https://github.com/hanzoai/sign.git
synced 2026-10-30 14:57:59 +00:00
The product is branded Hanzo eSign (esign.hanzo.ai, repo hanzoai/esign). Rename all workspace packages @hanzo/sign-* → @hanzo/esign-* (1052 files) and align docker/Dockerfile turbo --scope/--filter to the actual remix package name @hanzo/esign (was a pre-existing mismatch with -remix that broke the build). Protected deps (@hanzo/insights, @hanzo/logo) untouched.
61 lines
1.7 KiB
TypeScript
61 lines
1.7 KiB
TypeScript
import { Hono } from 'hono';
|
|
|
|
import { AppError } from '@hanzo/esign-lib/errors/app-error';
|
|
|
|
import { GoogleAuthOptions, HanzoAuthOptions, MicrosoftAuthOptions, OidcAuthOptions } from '../config';
|
|
import { handleOAuthCallbackUrl } from '../lib/utils/handle-oauth-callback-url';
|
|
import { handleOAuthOrganisationCallbackUrl } from '../lib/utils/handle-oauth-organisation-callback-url';
|
|
import type { HonoAuthContext } from '../types/context';
|
|
|
|
/**
|
|
* Have to create this route instead of bundling callback with oauth routes to provide
|
|
* backwards compatibility for self-hosters (legacy session-cookie name compatibility).
|
|
*/
|
|
export const callbackRoute = new Hono<HonoAuthContext>()
|
|
/**
|
|
* Hanzo IAM callback verification.
|
|
*/
|
|
.get('/hanzo', async (c) => handleOAuthCallbackUrl({ c, clientOptions: HanzoAuthOptions }))
|
|
|
|
/**
|
|
* OIDC callback verification.
|
|
*/
|
|
.get('/oidc', async (c) => handleOAuthCallbackUrl({ c, clientOptions: OidcAuthOptions }))
|
|
|
|
/**
|
|
* Organisation OIDC callback verification.
|
|
*/
|
|
.get('/oidc/org/:orgUrl', async (c) => {
|
|
const orgUrl = c.req.param('orgUrl');
|
|
|
|
try {
|
|
return await handleOAuthOrganisationCallbackUrl({
|
|
c,
|
|
orgUrl,
|
|
});
|
|
} catch (err) {
|
|
console.error(err);
|
|
|
|
if (err instanceof Error) {
|
|
throw new AppError(err.name, {
|
|
message: err.message,
|
|
statusCode: 500,
|
|
});
|
|
}
|
|
|
|
throw err;
|
|
}
|
|
})
|
|
|
|
/**
|
|
* Google callback verification.
|
|
*/
|
|
.get('/google', async (c) => handleOAuthCallbackUrl({ c, clientOptions: GoogleAuthOptions }))
|
|
|
|
/**
|
|
* Microsoft callback verification.
|
|
*/
|
|
.get('/microsoft', async (c) =>
|
|
handleOAuthCallbackUrl({ c, clientOptions: MicrosoftAuthOptions }),
|
|
);
|