Added auto database creation based on sql scripts and jwt key cache

This commit is contained in:
fedyna-k
2025-01-16 23:13:58 +01:00
parent 914875a3df
commit 46a417f411
8 changed files with 70 additions and 7 deletions
+10 -1
View File
@@ -7,6 +7,7 @@ import {
} from "@melvdouc/xml-parser";
import { createJwt } from "@popov/jwt";
import { setCookie } from "$std/http/cookie.ts";
import { getKey } from "$root/routes/_middleware.ts";
const SERVICE = "https://localhost/login";
const CAS = "https://ident.univ-amu.fr/cas";
@@ -23,6 +24,14 @@ interface CasResponse extends RegularTagNode {
children: [TextNode, CasGroupNode];
}
export interface LoginJWT {
iss: "PolyMPR";
iat: number;
exp: number;
aud: "PolyMPR";
user: Record<string, string | string[]>;
}
function getTag(tag: CasTagNode): [string, string] {
return [
tag.tagName.replace("cas:", ""),
@@ -55,7 +64,7 @@ function createUserJWT(casResponse: CasResponse): Promise<string> {
user: fullUserInfos,
};
const key = "NEED TO CHANGE THIS KEY FURTHER IN DEV";
const key = getKey(fullUserInfos.uid as string);
return createJwt(payload, key);
}