feat(api): Make Lysand a full OAuth2/OpenID Connect provider as well as still Mastodon compatible

This commit is contained in:
Jesse Wierzbinski 2024-04-17 22:42:12 -10:00
parent f9f4a99cb9
commit 5cb48b2f3b
No known key found for this signature in database
29 changed files with 8466 additions and 279 deletions

View file

@ -89,6 +89,8 @@ export interface Config {
client_secret: string;
icon: string;
}[];
jwt_key: string;
};
http: {
@ -447,6 +449,7 @@ export const defaultConfig: Config = {
},
oidc: {
providers: [],
jwt_key: "",
},
http: {
base_url: "https://lysand.social",

View file

@ -137,23 +137,14 @@ export class RequestParser {
* @throws Error if body is invalid
*/
private async parseFormUrlencoded<T>(): Promise<Partial<T>> {
const formData = await this.request.formData();
const result: Partial<T> = {};
const parsed = parse(await this.request.text(), {
parseArrays: true,
interpretNumericEntities: true,
});
for (const [key, value] of formData.entries()) {
if (key.endsWith("[]")) {
const arrayKey = key.slice(0, -2) as keyof T;
if (!result[arrayKey]) {
result[arrayKey] = [] as T[keyof T];
}
(result[arrayKey] as FormDataEntryValue[]).push(value);
} else {
result[key as keyof T] = value as T[keyof T];
}
}
return result;
return castBooleanObject(
parsed as PossiblyRecursiveObject,
) as Partial<T>;
}
/**