Skip to content
Snippets Groups Projects
Select Git revision
  • 70dde3115c463d45d4f0548a6860aaca585d79cf
  • master default protected
  • doc-script-gen-off-tests
  • 366-signe-a-cote-du-droit-en-vigueur-sur-l-ui-pour-indiquer-que-la-reforme-a-eu-lieu-mais-qu-elle-n
  • revalo_retraites
  • 381-pb-affichage-labels-des-parametres-sur-plus-de-3-lignes
  • ajoute-duplicate-aide-logement
  • poc_castype_ia
  • parametres-editables-budget
  • ui-parametres
  • 355-les-dispositifs-prestations-sociales-du-graphique-se-cachent-montrent-en-meme-temps-2
  • 358-les-variables-dont-le-montant-est-nul-apparaissent-en-bleu-et-non-cliquables
  • 356-ajuster-la-largeur-sur-les-graphiques-budgetaires
  • incoherence_cas_type_0
  • fix-ui-suppression-tranches-baremes
  • ajout-agregat-cehr-version-plf
  • impact_carbone
  • xlsx
  • header_revamp
  • 270-concevoir-la-page-d-accueil-leximpact
  • 219-conversion-des-montants-min-et-max-de-l-axe-des-x-en-smic
  • 0.0.1177
  • 0.0.1176
  • 0.0.1175
  • 0.0.1174
  • 0.0.1173
  • 0.0.1172
  • 0.0.1171
  • 0.0.1170
  • 0.0.1169
  • 0.0.1168
  • 0.0.1167
  • 0.0.1166
  • 0.0.1165
  • 0.0.1164
  • 0.0.1163
  • 0.0.1162
  • 0.0.1161
  • 0.0.1160
  • 0.0.1159
  • 0.0.1158
41 results

urls.ts

Blame
  • oauth2.ts 2.04 KiB
    import { SvelteKitAuth } from "sk-auth"
    import { OAuth2Provider } from "sk-auth/providers"
    
    import config from "$lib/server/config"
    import type { User } from "$lib/users"
    
    type Profile = User
    
    interface Tokens {
      access_token: string
      expires_in: number
      id_token: string
      "not-before-policy"?: number
      refresh_expires_in?: number
      refresh_token?: string
      session_state?: string
      scope: string // "openid email profile"
      token_type: string // "Bearer"
    }
    
    const { baseUrl, oauth2 } = config
    
    export const oauth2Authenticator =
      oauth2 === undefined
        ? undefined
        : new SvelteKitAuth({
            basePath: "/authentication",
            // callbacks: {
            //   jwt(token, profile) {
            //     if (profile?.provider) {
            //       const { provider, ...account } = profile;
            //       token = {
            //         ...token,
            //         user: {
            //           ...(token.user ?? {}),
            //           connections: { ...(token.user?.connections ?? {}), [provider]: account },
            //         },
            //       };
            //     }
    
            //     return token;
            //   },
            // },
            host: new URL(baseUrl).host,
            jwtSecret: oauth2.jwtSecret,
            protocol: new URL(baseUrl).protocol.replace(/:$/, ""),
            providers: [
              new OAuth2Provider<Profile, Tokens>({
                accessTokenUrl: oauth2.accessTokenUrl,
                // authorizationParams?: any;
                authorizationUrl: oauth2.authorizationUrl,
                clientId: oauth2.clientId,
                clientSecret: oauth2.clientSecret,
                // contentType: "application/json",
                contentType: "application/x-www-form-urlencoded",
                // grantType: "authorization_code",
                // headers?: any;
                id: "leximpact",
                // params: any;
                profileUrl: oauth2.profileUrl,
                // responseType: "code",
                scope: ["openid", "profile", "email"],
    
                profile(profile) {
                  return { ...profile, provider: "leximpact" }
                },
              }),
            ],
          })