mirror of
https://github.com/ets-cfuhrman-pfe/EvalueTonSavoir.git
synced 2025-08-11 21:23:54 -04:00
Adds debuging informations + fixes url
This commit is contained in:
parent
ccce303693
commit
ba270db019
5 changed files with 20 additions and 6 deletions
9
.vscode/launch.json
vendored
9
.vscode/launch.json
vendored
|
|
@ -13,6 +13,13 @@
|
||||||
],
|
],
|
||||||
"program": "${workspaceFolder}/server/app.js",
|
"program": "${workspaceFolder}/server/app.js",
|
||||||
"cwd":"${workspaceFolder}/server/"
|
"cwd":"${workspaceFolder}/server/"
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
"type": "msedge",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "Debug frontend",
|
||||||
|
"url": "http://localhost:5173",
|
||||||
|
"webRoot": "${workspaceFolder}/client/"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
// constants.tsx
|
// constants.tsx
|
||||||
const ENV_VARIABLES = {
|
const ENV_VARIABLES = {
|
||||||
MODE: 'production',
|
MODE: 'production',
|
||||||
VITE_BACKEND_URL: process.env.VITE_BACKEND_URL || ""
|
VITE_BACKEND_URL: process.env.VITE_BACKEND_URL || "",
|
||||||
|
BACKEND_URL: process.env.SITE_URL != undefined ? `${process.env.SITE_URL}${process.env.USE_PORTS ? `:${process.env.BACKEND_PORT}`:''}` : process.env.VITE_BACKEND_URL || '',
|
||||||
|
FRONTEND_URL: process.env.SITE_URL != undefined ? `${process.env.SITE_URL}${process.env.USE_PORTS ? `:${process.env.PORT}`:''}` : ''
|
||||||
};
|
};
|
||||||
|
|
||||||
export { ENV_VARIABLES };
|
export { ENV_VARIABLES };
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { ENV_VARIABLES } from '../../../../constants';
|
||||||
import '../css/buttonAuth.css';
|
import '../css/buttonAuth.css';
|
||||||
|
|
||||||
interface ButtonAuthContainerProps {
|
interface ButtonAuthContainerProps {
|
||||||
|
|
@ -7,7 +8,7 @@ interface ButtonAuthContainerProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleAuthLogin = (provider: string) => {
|
const handleAuthLogin = (provider: string) => {
|
||||||
window.location.href = `/api/auth/` + provider;
|
window.location.href = `${ENV_VARIABLES.BACKEND_URL}/api/auth/${provider}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const ButtonAuth: React.FC<ButtonAuthContainerProps> = ({ providerName, providerType }) => {
|
const ButtonAuth: React.FC<ButtonAuthContainerProps> = ({ providerName, providerType }) => {
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ class PassportOAuth {
|
||||||
register(app, passport, endpoint, name, provider) {
|
register(app, passport, endpoint, name, provider) {
|
||||||
const cb_url = `${process.env['BACKEND_URL']}${endpoint}/${name}/callback`
|
const cb_url = `${process.env['BACKEND_URL']}${endpoint}/${name}/callback`
|
||||||
const self = this
|
const self = this
|
||||||
|
const scope = 'openid profile email offline_access' + ` ${provider.OAUTH_ADD_SCOPE}`;
|
||||||
|
|
||||||
passport.use(name, new OAuth2Strategy({
|
passport.use(name, new OAuth2Strategy({
|
||||||
authorizationURL: provider.OAUTH_AUTHORIZATION_URL,
|
authorizationURL: provider.OAUTH_AUTHORIZATION_URL,
|
||||||
|
|
@ -76,7 +77,7 @@ class PassportOAuth {
|
||||||
|
|
||||||
app.get(`${endpoint}/${name}`, (req, res, next) => {
|
app.get(`${endpoint}/${name}`, (req, res, next) => {
|
||||||
passport.authenticate(name, {
|
passport.authenticate(name, {
|
||||||
scope: 'openid profile email offline_access' + ` ${provider.OAUTH_ADD_SCOPE}`,
|
scope: scope,
|
||||||
prompt: 'consent'
|
prompt: 'consent'
|
||||||
})(req, res, next);
|
})(req, res, next);
|
||||||
});
|
});
|
||||||
|
|
@ -93,6 +94,7 @@ class PassportOAuth {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
console.info(`Ajout de la connexion : ${name}(OAuth)`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ class PassportOpenIDConnect {
|
||||||
const config = await this.getConfigFromConfigURL(name, provider)
|
const config = await this.getConfigFromConfigURL(name, provider)
|
||||||
const cb_url = `${process.env['BACKEND_URL']}${endpoint}/${name}/callback`
|
const cb_url = `${process.env['BACKEND_URL']}${endpoint}/${name}/callback`
|
||||||
const self = this
|
const self = this
|
||||||
|
const scope = 'openid profile email ' + `${provider.OIDC_ADD_SCOPE}`
|
||||||
|
|
||||||
passport.use(name, new OpenIDConnectStrategy({
|
passport.use(name, new OpenIDConnectStrategy({
|
||||||
issuer: config.issuer,
|
issuer: config.issuer,
|
||||||
|
|
@ -34,7 +35,7 @@ class PassportOpenIDConnect {
|
||||||
clientSecret: provider.OIDC_CLIENT_SECRET,
|
clientSecret: provider.OIDC_CLIENT_SECRET,
|
||||||
callbackURL: cb_url,
|
callbackURL: cb_url,
|
||||||
passReqToCallback: true,
|
passReqToCallback: true,
|
||||||
scope: 'openid profile email ' + `${provider.OIDC_ADD_SCOPE}`,
|
scope: scope,
|
||||||
},
|
},
|
||||||
// patch pour la librairie permet d'obtenir les groupes, PR en cours mais "morte" : https://github.com/jaredhanson/passport-openidconnect/pull/101
|
// patch pour la librairie permet d'obtenir les groupes, PR en cours mais "morte" : https://github.com/jaredhanson/passport-openidconnect/pull/101
|
||||||
async function (req, issuer, profile, times, tok, done) {
|
async function (req, issuer, profile, times, tok, done) {
|
||||||
|
|
@ -78,7 +79,7 @@ class PassportOpenIDConnect {
|
||||||
|
|
||||||
app.get(`${endpoint}/${name}`, (req, res, next) => {
|
app.get(`${endpoint}/${name}`, (req, res, next) => {
|
||||||
passport.authenticate(name, {
|
passport.authenticate(name, {
|
||||||
scope: 'openid profile email offline_access' + ` ${provider.OAUTH_ADD_SCOPE}`,
|
scope: scope,
|
||||||
prompt: 'consent'
|
prompt: 'consent'
|
||||||
})(req, res, next);
|
})(req, res, next);
|
||||||
});
|
});
|
||||||
|
|
@ -95,6 +96,7 @@ class PassportOpenIDConnect {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
console.info(`Ajout de la connexion : ${name}(OIDC)`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue