mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
Add full OpenID connect provider support
This commit is contained in:
parent
14d96ac9e6
commit
947c1f4991
47 changed files with 604 additions and 247 deletions
|
|
@ -32,6 +32,17 @@ export interface ConfigType {
|
|||
enabled: boolean;
|
||||
};
|
||||
|
||||
oidc: {
|
||||
providers: {
|
||||
name: string;
|
||||
id: string;
|
||||
url: string;
|
||||
client_id: string;
|
||||
client_secret: string;
|
||||
icon: string;
|
||||
}[];
|
||||
};
|
||||
|
||||
http: {
|
||||
base_url: string;
|
||||
bind: string;
|
||||
|
|
@ -189,6 +200,9 @@ export const configDefaults: ConfigType = {
|
|||
api_key: "",
|
||||
enabled: false,
|
||||
},
|
||||
oidc: {
|
||||
providers: [],
|
||||
},
|
||||
instance: {
|
||||
banner: "",
|
||||
description: "",
|
||||
|
|
|
|||
6
utils/constants.ts
Normal file
6
utils/constants.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import { getConfig } from "@config";
|
||||
|
||||
const config = getConfig();
|
||||
|
||||
export const oauthRedirectUri = (issuer: string) =>
|
||||
`${config.http.base_url}/oauth/callback/${issuer}`;
|
||||
|
|
@ -59,3 +59,5 @@ export const checkIfOauthIsValid = (
|
|||
|
||||
return false;
|
||||
};
|
||||
|
||||
export const oauthCodeVerifiers: Record<string, string> = {};
|
||||
|
|
|
|||
20
utils/temp.ts
Normal file
20
utils/temp.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import { join } from "path";
|
||||
import { exists, mkdir, writeFile, readFile } from "fs/promises";
|
||||
|
||||
export const writeToTempDirectory = async (filename: string, data: string) => {
|
||||
const tempDir = join(process.cwd(), "temp");
|
||||
if (!(await exists(tempDir))) await mkdir(tempDir);
|
||||
|
||||
const tempFile = join(tempDir, filename);
|
||||
await writeFile(tempFile, data);
|
||||
|
||||
return tempFile;
|
||||
};
|
||||
|
||||
export const readFromTempDirectory = async (filename: string) => {
|
||||
const tempDir = join(process.cwd(), "temp");
|
||||
if (!(await exists(tempDir))) await mkdir(tempDir);
|
||||
|
||||
const tempFile = join(tempDir, filename);
|
||||
return readFile(tempFile, "utf-8");
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue