mirror of
https://github.com/nicotsx/zerobyte.git
synced 2026-04-18 22:09:30 -04:00
* feat: oidc feat: organization switcher refactor: org context feat: invitations GLM * feat: link current account * refactor: own page for sso registration * feat: per-user account management * refactor: code style * refactor: user existing check * refactor: restrict provider configuration to super admins only * refactor: cleanup / pr review * chore: fix lint issues * chore: pr feedbacks * test(e2e): automated tests for OIDC * fix: check url first for sso provider identification * fix: prevent oidc provider to be named "credential"
43 lines
875 B
TypeScript
43 lines
875 B
TypeScript
// @ts-nocheck
|
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
|
|
export type AuthToken = string | undefined;
|
|
|
|
export interface Auth {
|
|
/**
|
|
* Which part of the request do we use to send the auth?
|
|
*
|
|
* @default 'header'
|
|
*/
|
|
in?: 'header' | 'query' | 'cookie';
|
|
/**
|
|
* Header or query parameter name.
|
|
*
|
|
* @default 'Authorization'
|
|
*/
|
|
name?: string;
|
|
scheme?: 'basic' | 'bearer';
|
|
type: 'apiKey' | 'http';
|
|
}
|
|
|
|
export const getAuthToken = async (
|
|
auth: Auth,
|
|
callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken,
|
|
): Promise<string | undefined> => {
|
|
const token = typeof callback === 'function' ? await callback(auth) : callback;
|
|
|
|
if (!token) {
|
|
return;
|
|
}
|
|
|
|
if (auth.scheme === 'bearer') {
|
|
return `Bearer ${token}`;
|
|
}
|
|
|
|
if (auth.scheme === 'basic') {
|
|
return `Basic ${btoa(token)}`;
|
|
}
|
|
|
|
return token;
|
|
};
|