mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-07-03 04:55:23 +02:00
- Added logic to retrieve and delete SSO providers, ensuring proper permission checks and error handling. - Updated user trusted origins when adding or removing SSO providers, maintaining accurate origin lists. - Refactored trusted origins retrieval to improve clarity and efficiency in the authentication process. - Introduced utility functions for normalizing trusted origins and converting request headers.
36 lines
917 B
TypeScript
36 lines
917 B
TypeScript
import { db } from "@dokploy/server/db";
|
|
|
|
export const getSSOProviders = async () => {
|
|
const providers = await db.query.ssoProvider.findMany({
|
|
columns: {
|
|
id: true,
|
|
providerId: true,
|
|
issuer: true,
|
|
domain: true,
|
|
oidcConfig: true,
|
|
samlConfig: true,
|
|
},
|
|
});
|
|
return providers;
|
|
};
|
|
|
|
export const requestToHeaders = (req: {
|
|
headers?: Record<string, string | string[] | undefined>;
|
|
}): Headers => {
|
|
const headers = new Headers();
|
|
if (req?.headers) {
|
|
for (const [key, value] of Object.entries(req.headers)) {
|
|
if (value !== undefined && key.toLowerCase() !== "host") {
|
|
headers.set(key, Array.isArray(value) ? value.join(", ") : value);
|
|
}
|
|
}
|
|
}
|
|
return headers;
|
|
};
|
|
|
|
export const normalizeTrustedOrigin = (value: string): string => {
|
|
// Keep it simple: trim and remove trailing slashes.
|
|
// e.g. "https://example.com/" -> "https://example.com"
|
|
return value.trim().replace(/\/+$/, "");
|
|
};
|