Fix feedback @moufmouf

This commit is contained in:
Gregoire Parant 2021-11-15 15:58:08 +01:00
parent a4b8a8422f
commit 210a789aa4
8 changed files with 42 additions and 40 deletions

View File

@ -22,7 +22,7 @@ MAX_USERNAME_LENGTH=8
OPID_CLIENT_ID= OPID_CLIENT_ID=
OPID_CLIENT_SECRET= OPID_CLIENT_SECRET=
OPID_CLIENT_ISSUER= OPID_CLIENT_ISSUER=
OPID_CLIENT_REDIREC_URL= OPID_CLIENT_REDIRECT_URL=
OPID_LOGIN_SCREEN_PROVIDER=http://pusher.workadventure.localhost/login-screen OPID_LOGIN_SCREEN_PROVIDER=http://pusher.workadventure.localhost/login-screen
OPID_PROFILE_SCREEN_PROVIDER= OPID_PROFILE_SCREEN_PROVIDER=
DISABLE_ANONYMOUS= DISABLE_ANONYMOUS=

View File

@ -71,7 +71,7 @@ services:
OPID_CLIENT_ID: $OPID_CLIENT_ID OPID_CLIENT_ID: $OPID_CLIENT_ID
OPID_CLIENT_SECRET: $OPID_CLIENT_SECRET OPID_CLIENT_SECRET: $OPID_CLIENT_SECRET
OPID_CLIENT_ISSUER: $OPID_CLIENT_ISSUER OPID_CLIENT_ISSUER: $OPID_CLIENT_ISSUER
OPID_CLIENT_REDIREC_URL: $OPID_CLIENT_REDIREC_URL OPID_CLIENT_REDIRECT_URL: $OPID_CLIENT_REDIRECT_URL
OPID_PROFILE_SCREEN_PROVIDER: $OPID_PROFILE_SCREEN_PROVIDER OPID_PROFILE_SCREEN_PROVIDER: $OPID_PROFILE_SCREEN_PROVIDER
DISABLE_ANONYMOUS: $DISABLE_ANONYMOUS DISABLE_ANONYMOUS: $DISABLE_ANONYMOUS
volumes: volumes:

View File

@ -73,7 +73,7 @@ services:
OPID_CLIENT_ID: $OPID_CLIENT_ID OPID_CLIENT_ID: $OPID_CLIENT_ID
OPID_CLIENT_SECRET: $OPID_CLIENT_SECRET OPID_CLIENT_SECRET: $OPID_CLIENT_SECRET
OPID_CLIENT_ISSUER: $OPID_CLIENT_ISSUER OPID_CLIENT_ISSUER: $OPID_CLIENT_ISSUER
OPID_CLIENT_REDIREC_URL: $OPID_CLIENT_REDIREC_URL OPID_CLIENT_REDIRECT_URL: $OPID_CLIENT_REDIRECT_URL
OPID_PROFILE_SCREEN_PROVIDER: $OPID_PROFILE_SCREEN_PROVIDER OPID_PROFILE_SCREEN_PROVIDER: $OPID_PROFILE_SCREEN_PROVIDER
DISABLE_ANONYMOUS: $DISABLE_ANONYMOUS DISABLE_ANONYMOUS: $DISABLE_ANONYMOUS
volumes: volumes:

View File

@ -183,8 +183,11 @@ class ConnectionManager {
} else { } else {
try { try {
await this.checkAuthUserConnexion(); await this.checkAuthUserConnexion();
analyticsClient.loggedWithSso();
} catch (err) { } catch (err) {
console.error(err); console.error(err);
this.loadOpenIDScreen();
return Promise.reject(new Error("You will be redirect on login page"));
} }
} }
this.localUser = localUserStore.getLocalUser() as LocalUser; //if authToken exist in localStorage then localUser cannot be null this.localUser = localUserStore.getLocalUser() as LocalUser; //if authToken exist in localStorage then localUser cannot be null

View File

@ -66,7 +66,6 @@ export class AuthenticateController extends BaseController {
throw Error("Token cannot to be check on Hydra"); throw Error("Token cannot to be check on Hydra");
} }
const resCheckTokenAuth = await openIDClient.checkTokenAuth(authTokenData.accessToken); const resCheckTokenAuth = await openIDClient.checkTokenAuth(authTokenData.accessToken);
console.log("resCheckTokenAuth", resCheckTokenAuth);
res.writeStatus("200"); res.writeStatus("200");
this.addCorsHeaders(res); this.addCorsHeaders(res);
return res.end(JSON.stringify({ authToken: token })); return res.end(JSON.stringify({ authToken: token }));

View File

@ -44,37 +44,37 @@ export class OpenIdProfileController extends BaseController {
} }
buildHtml(domain: string, email: string, pictureUrl?: string) { buildHtml(domain: string, email: string, pictureUrl?: string) {
return ( return `
"<!DOCTYPE html>" + <!DOCTYPE>
` <html>
<header> <head>
<style> <style>
*{ *{
font-family: PixelFont-7, monospace; font-family: PixelFont-7, monospace;
} }
body{ body{
text-align: center; text-align: center;
color: white; color: white;
} }
section{ section{
margin: 20px; margin: 20px;
} }
</style> </style>
</header> </head>
<body> <body>
<div class="container"> <div class="container">
<section> <section>
<img src="${pictureUrl ? pictureUrl : "/images/profile"}"> <img src="${pictureUrl ? pictureUrl : "/images/profile"}">
</section> </section>
<section> <section>
Profile validated by domain: <span style="font-weight: bold">${domain}</span> Profile validated by domain: <span style="font-weight: bold">${domain}</span>
</section> </section>
<section> <section>
Your email: <span style="font-weight: bold">${email}</span> Your email: <span style="font-weight: bold">${email}</span>
</section> </section>
</div> </div>
</body> </body>
` </html>
); `;
} }
} }

View File

@ -15,7 +15,7 @@ export const FRONT_URL = process.env.FRONT_URL || "http://localhost";
export const OPID_CLIENT_ID = process.env.OPID_CLIENT_ID || ""; export const OPID_CLIENT_ID = process.env.OPID_CLIENT_ID || "";
export const OPID_CLIENT_SECRET = process.env.OPID_CLIENT_SECRET || ""; export const OPID_CLIENT_SECRET = process.env.OPID_CLIENT_SECRET || "";
export const OPID_CLIENT_ISSUER = process.env.OPID_CLIENT_ISSUER || ""; export const OPID_CLIENT_ISSUER = process.env.OPID_CLIENT_ISSUER || "";
export const OPID_CLIENT_REDIREC_URL = process.env.OPID_CLIENT_REDIREC_URL || FRONT_URL + "/jwt"; export const OPID_CLIENT_REDIRECT_URL = process.env.OPID_CLIENT_REDIRECT_URL || FRONT_URL + "/jwt";
export const OPID_PROFILE_SCREEN_PROVIDER = process.env.OPID_PROFILE_SCREEN_PROVIDER || ADMIN_URL + "/profile"; export const OPID_PROFILE_SCREEN_PROVIDER = process.env.OPID_PROFILE_SCREEN_PROVIDER || ADMIN_URL + "/profile";
export const DISABLE_ANONYMOUS = process.env.DISABLE_ANONYMOUS || false; export const DISABLE_ANONYMOUS = process.env.DISABLE_ANONYMOUS || false;

View File

@ -3,7 +3,7 @@ import {
OPID_CLIENT_ID, OPID_CLIENT_ID,
OPID_CLIENT_SECRET, OPID_CLIENT_SECRET,
OPID_CLIENT_ISSUER, OPID_CLIENT_ISSUER,
OPID_CLIENT_REDIREC_URL, OPID_CLIENT_REDIRECT_URL,
} from "../Enum/EnvironmentVariable"; } from "../Enum/EnvironmentVariable";
class OpenIDClient { class OpenIDClient {
@ -15,7 +15,7 @@ class OpenIDClient {
return new issuer.Client({ return new issuer.Client({
client_id: OPID_CLIENT_ID, client_id: OPID_CLIENT_ID,
client_secret: OPID_CLIENT_SECRET, client_secret: OPID_CLIENT_SECRET,
redirect_uris: [OPID_CLIENT_REDIREC_URL], redirect_uris: [OPID_CLIENT_REDIRECT_URL],
response_types: ["code"], response_types: ["code"],
}); });
}); });
@ -38,7 +38,7 @@ class OpenIDClient {
public getUserInfo(code: string, nonce: string): Promise<{ email: string; sub: string; access_token: string }> { public getUserInfo(code: string, nonce: string): Promise<{ email: string; sub: string; access_token: string }> {
return this.initClient().then((client) => { return this.initClient().then((client) => {
return client.callback(OPID_CLIENT_REDIREC_URL, { code }, { nonce }).then((tokenSet) => { return client.callback(OPID_CLIENT_REDIRECT_URL, { code }, { nonce }).then((tokenSet) => {
return client.userinfo(tokenSet).then((res) => { return client.userinfo(tokenSet).then((res) => {
return { return {
...res, ...res,