bda47fd88b
boolean Refactor role determination logic to use `eduPersonPrimaryAffiliation` and `amuComposante`. This simplifies checking for Polytech affiliation and identifies roles like professor, administration, and student more accurately. The API access control is updated to reflect the new role names.
71 lines
1.6 KiB
TypeScript
71 lines
1.6 KiB
TypeScript
import { type RegularTagNode, type TextNode } from "@melvdouc/xml-parser";
|
|
import { AsyncRoute } from "$fresh/src/server/types.ts";
|
|
|
|
export interface AuthenticatedState {
|
|
isAuthenticated: true;
|
|
isFromPolytech: boolean;
|
|
role: "etudiant" | "professeur" | "administration" | "autre";
|
|
session: CasContent;
|
|
availablePages: Record<string, string>;
|
|
}
|
|
|
|
interface UnauthenticatedState {
|
|
isAuthenticated: false;
|
|
isFromPolytech: false;
|
|
session: undefined;
|
|
}
|
|
|
|
export type State = AuthenticatedState | UnauthenticatedState;
|
|
|
|
export interface AppProperties {
|
|
name: string;
|
|
icon: string;
|
|
pages: Record<string, string>;
|
|
adminOnly: string[];
|
|
hint: string;
|
|
}
|
|
|
|
export interface CasTagNode extends RegularTagNode {
|
|
children: [TextNode];
|
|
}
|
|
|
|
export interface CasGroupNode extends RegularTagNode {
|
|
children: CasTagNode[];
|
|
}
|
|
|
|
export interface CasResponse extends RegularTagNode {
|
|
children: [TextNode, CasGroupNode];
|
|
}
|
|
|
|
export interface CasContent {
|
|
amuCampus: string;
|
|
amuComposante: string;
|
|
amuDateValidation: string;
|
|
coGroup: string;
|
|
eduPersonPrimaryAffiliation: string;
|
|
eduPersonPrincipalName: string;
|
|
mail: string;
|
|
displayName: string;
|
|
givenName: string;
|
|
memberOf: string[];
|
|
sn: string;
|
|
supannCivilite: string;
|
|
supannEntiteAffectation: string;
|
|
supannEtuAnneeInscription: string;
|
|
supannEtuEtape: string;
|
|
uid: string;
|
|
}
|
|
|
|
export interface LoginJWT {
|
|
iss: "PolyMPR";
|
|
iat: number;
|
|
exp: number;
|
|
aud: "PolyMPR";
|
|
user: CasContent;
|
|
}
|
|
|
|
export type EmptyObject = Record<string | number | symbol, never>;
|
|
|
|
// deno-lint-ignore no-explicit-any
|
|
export type Route = AsyncRoute<any, State>;
|