WIP: titouan #23

Closed
Titouan wants to merge 6 commits from titouan into dev
8 changed files with 54 additions and 48 deletions

View File

@ -1,6 +1,11 @@
4NK_URL=
FRONT_APP_HOST=
IDNOT_BASE_URL=
IDNOT_AUTHORIZE_ENDPOINT=
IDNOT_CLIENT_ID=
BACK_API_PROTOCOL=
BACK_API_HOSTNAME=
BACK_API_PORT=
BACK_API_ROOT_URL=
BACK_API_VERSION=
ANK_BASE_REDIRECT_URI=

View File

@ -2,7 +2,7 @@ name: Build and Push to Registry
on:
push:
branches: [ dev ]
branches: [ titouan ]
env:
REGISTRY: git.4nkweb.com
@ -37,6 +37,5 @@ jobs:
push: true
ssh: default
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:dev
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:titouan
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ gitea.sha }}

View File

@ -22,6 +22,7 @@ const nextConfig = {
NEXT_PUBLIC_HOTJAR_VERSION: process.env.NEXT_PUBLIC_HOTJAR_VERSION,
NEXT_PUBLIC_4NK_URL: process.env.NEXT_PUBLIC_4NK_URL,
NEXT_PUBLIC_API_URL: process.env.NEXT_PUBLIC_API_URL,
NEXT_PUBLICK_ANK_BASE_REDIRECT_URI: process.env.NEXT_PUBLIC_ANK_BASE_REDIRECT_URI,
NEXT_PUBLIC_DEFAULT_VALIDATOR_ID: process.env.NEXT_PUBLIC_DEFAULT_VALIDATOR_ID,
NEXT_PUBLIC_DEFAULT_STORAGE_URLS: process.env.NEXT_PUBLIC_DEFAULT_STORAGE_URLS,
},
@ -42,6 +43,7 @@ const nextConfig = {
NEXT_PUBLIC_HOTJAR_VERSION: process.env.NEXT_PUBLIC_HOTJAR_VERSION,
NEXT_PUBLIC_4NK_URL: process.env.NEXT_PUBLIC_4NK_URL,
NEXT_PUBLIC_API_URL: process.env.NEXT_PUBLIC_API_URL,
NEXT_PUBLICK_ANK_BASE_REDIRECT_URI: process.env.NEXT_PUBLIC_ANK_BASE_REDIRECT_URI,
NEXT_PUBLIC_DEFAULT_VALIDATOR_ID: process.env.NEXT_PUBLIC_DEFAULT_VALIDATOR_ID,
NEXT_PUBLIC_DEFAULT_STORAGE_URLS: process.env.NEXT_PUBLIC_DEFAULT_STORAGE_URLS,
},
@ -62,6 +64,7 @@ const nextConfig = {
NEXT_PUBLIC_HOTJAR_VERSION: process.env.NEXT_PUBLIC_HOTJAR_VERSION,
NEXT_PUBLIC_4NK_URL: process.env.NEXT_PUBLIC_4NK_URL,
NEXT_PUBLIC_API_URL: process.env.NEXT_PUBLIC_API_URL,
NEXT_PUBLICK_ANK_BASE_REDIRECT_URI: process.env.NEXT_PUBLIC_ANK_BASE_REDIRECT_URI,
NEXT_PUBLIC_DEFAULT_VALIDATOR_ID: process.env.NEXT_PUBLIC_DEFAULT_VALIDATOR_ID,
NEXT_PUBLIC_DEFAULT_STORAGE_URLS: process.env.NEXT_PUBLIC_DEFAULT_STORAGE_URLS,
},

View File

@ -41,12 +41,8 @@ export default class Auth extends BaseApiService {
}
public async idNotAuth(autorizationCode: string | string[]): Promise<{ idNotUser: any; authToken: string }> {
// const variables = FrontendVariables.getInstance();
// TODO: review
const baseBackUrl = 'http://localhost:8080';//variables.BACK_API_PROTOCOL + variables.BACK_API_HOST;
const url = new URL(`${baseBackUrl}/api/v1/idnot/auth/${autorizationCode}`);
const variables = FrontendVariables.getInstance();
const url = new URL(`${variables.BACK_API_PROTOCOL}://${variables.BACK_API_HOST}:${variables.BACK_API_PORT}/api/v1/idnot/auth/${autorizationCode}`);
try {
return await this.postRequest<{ idNotUser: any; authToken: string }>(url);
} catch (err) {
@ -56,9 +52,8 @@ export default class Auth extends BaseApiService {
}
public async getIdNotUser(): Promise<{ success: boolean; data: any }> {
const baseBackUrl = 'http://localhost:8080';//variables.BACK_API_PROTOCOL + variables.BACK_API_HOST;
const url = new URL(`${baseBackUrl}/api/v1/idnot/user`);
const variables = FrontendVariables.getInstance();
const url = new URL(`${variables.BACK_API_PROTOCOL}://${variables.BACK_API_HOST}:${variables.BACK_API_PORT}/api/v1/idnot/user`);
try {
return await this.getRequest(url);
}
@ -69,9 +64,8 @@ export default class Auth extends BaseApiService {
}
public async getIdNotOfficeForUser(userId: string): Promise<any[]> {
const baseBackUrl = 'http://localhost:8080';//variables.BACK_API_PROTOCOL + variables.BACK_API_HOST;
const url = new URL(`${baseBackUrl}/api/v1/idnot/user/rattachements`);
const variables = FrontendVariables.getInstance();
const url = new URL(`${variables.BACK_API_PROTOCOL}://${variables.BACK_API_HOST}:${variables.BACK_API_PORT}/api/v1/idnot/user/rattachements`);
url.searchParams.set('idNot', userId);
try {
return await this.getRequest(url);
@ -83,9 +77,8 @@ export default class Auth extends BaseApiService {
}
public async getIdNotUserForOffice(officeId: string): Promise<any[]> {
const baseBackUrl = 'http://localhost:8080';//variables.BACK_API_PROTOCOL + variables.BACK_API_HOST;
const url = new URL(`${baseBackUrl}/api/v1/idnot/office/rattachements`);
const variables = FrontendVariables.getInstance();
const url = new URL(`${variables.BACK_API_PROTOCOL}://${variables.BACK_API_HOST}:${variables.BACK_API_PORT}/api/v1/idnot/office/rattachements`);
url.searchParams.set('idNot', officeId);
try {
return await this.getRequest(url);
@ -96,9 +89,8 @@ export default class Auth extends BaseApiService {
}
public async getUserProcessByIdNot(pairingId: string): Promise<{ success: boolean; data: { processId: string, processData: { [key: string]: any } } }> {
const baseBackUrl = 'http://localhost:8080';//variables.BACK_API_PROTOCOL + variables.BACK_API_HOST;
const url = new URL(`${baseBackUrl}/api/v1/process/user`);
const variables = FrontendVariables.getInstance();
const url = new URL(`${variables.BACK_API_PROTOCOL}://${variables.BACK_API_HOST}:${variables.BACK_API_PORT}/api/v1/process/user`);
url.searchParams.set('pairingId', pairingId);
try {
return await this.getRequest(url);
@ -109,9 +101,8 @@ export default class Auth extends BaseApiService {
}
public async getOfficeProcessByIdNot(): Promise<{ success: boolean; data: { processId: string, processData: { [key: string]: any } } }> {
const baseBackUrl = 'http://localhost:8080';//variables.BACK_API_PROTOCOL + variables.BACK_API_HOST;
const url = new URL(`${baseBackUrl}/api/v1/process/office`);
const variables = FrontendVariables.getInstance();
const url = new URL(`${variables.BACK_API_PROTOCOL}://${variables.BACK_API_HOST}:${variables.BACK_API_PORT}/api/v1/process/office`);
try {
return await this.getRequest(url);
} catch (err) {

View File

@ -89,10 +89,7 @@ export default class Customers extends BaseNotary {
}
public async sendReminder(office: any, customer: any): Promise<void> {
// TODO: review
const baseBackUrl = 'http://localhost:8080';//variables.BACK_API_PROTOCOL + variables.BACK_API_HOST;
const url = new URL(`${baseBackUrl}/api/send_reminder`);
const url = new URL(`${this.variables.BACK_API_PROTOCOL}://${this.variables.BACK_API_HOST}:${this.variables.BACK_API_PORT}/api/send_reminder`);
//const url = new URL(this.baseURl.concat(`/${uid}/send_reminder`));
try {

View File

@ -41,18 +41,18 @@ export default function StepEmail(props: IProps) {
const router = useRouter();
const error = router.query["error"];
const variables = FrontendVariables.getInstance();
const redirectUserOnConnection = useCallback(() => {
/* TODO: review
const variables = FrontendVariables.getInstance();
router.push(
`${variables.IDNOT_BASE_URL + variables.IDNOT_AUTHORIZE_ENDPOINT}?client_id=${variables.IDNOT_CLIENT_ID}&redirect_uri=${
variables.FRONT_APP_HOST
}/authorized-client&scope=openid,profile&response_type=code`,
);
*/
const redirectUri = 'http://local.4nkweb.com:3000/authorized-client';
router.push(
`https://qual-connexion.idnot.fr/user/IdPOAuth2/authorize/idnot_idp_v1?client_id=B3CE56353EDB15A9&redirect_uri=${redirectUri}&scope=openid,profile&response_type=code`,
`${variables.IDNOT_BASE_URL}/user/${variables.IDNOT_AUTHORIZE_ENDPOINT}?client_id=${variables.IDNOT_CLIENT_ID}&redirect_uri=${variables.ANK_BASE_REDIRECT_URI}&scope=openid,profile&response_type=code`,
);
}, [router]);
@ -66,7 +66,7 @@ export default function StepEmail(props: IProps) {
const closeNoEmailModal = useCallback(() => {
setIsErrorModalOpen(0);
router.push("https://connexion.idnot.fr/");
router.push(variables.IDNOT_BASE_URL);
}, [router]);
// const closeContactAdminModal = () => {

View File

@ -23,6 +23,7 @@ import Iframe from "src/sdk/Iframe";
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
import { ProgressInfo } from "src/common/Api/LeCoffreApi/sdk/ImportData";
import { FrontendVariables } from "@Front/Config/VariablesFront";
export default function LoginCallBack() {
const router = useRouter();
@ -44,7 +45,7 @@ export default function LoginCallBack() {
resolve(UserStore.instance.getUser());
return;
}
// Poll for userInfo every 100ms
const checkInterval = setInterval(() => {
if (UserStore.instance.getUser()) {
@ -52,7 +53,7 @@ export default function LoginCallBack() {
resolve(UserStore.instance.getUser());
}
}, 100);
// Timeout after 60 seconds
setTimeout(() => {
clearInterval(checkInterval);
@ -65,14 +66,22 @@ export default function LoginCallBack() {
async function getUser() {
UserStore.instance.disconnect();
// TODO: review
// HACK: If start with http://local.lecoffreio.4nkweb:3000/authorized-client
// Replace with http://localhost:3000/authorized-client
if (window.location.href.startsWith('http://local.4nkweb.com')) {
window.location.href = window.location.href.replace('http://local.4nkweb.com:3000/authorized-client', 'http://localhost:3000/authorized-client');
return;
const variables = FrontendVariables.getInstance();
if (!variables?.ANK_BASE_REDIRECT_URI || !variables?.FRONT_APP_HOST) {
console.error("Redirect URIs not properly configured");
} else if (window.location.href.startsWith(`${variables.ANK_BASE_REDIRECT_URI}/authorized-client`)) {
const newUrl = window.location.href.replace(
`${variables.ANK_BASE_REDIRECT_URI}/authorized-client`,
`${variables.FRONT_APP_HOST}/authorized-client`
);
history.replaceState(null, '', newUrl); // Change l'URL sans rechargement
}
// else if (window.location.href.startsWith(variables.ANK_BASE_REDIRECT_URI)) {
// window.location.href = window.location.href.replace(`${variables.ANK_BASE_REDIRECT_URI}/authorized-client`, `${variables.FRONT_APP_HOST}/authorized-client`);
// return;
// }
const code = router.query["code"];
if (code) {
try {
@ -83,15 +92,15 @@ export default function LoginCallBack() {
}
const user: any = await Auth.getInstance().idNotAuth(code as string);
// Extract both user data and auth token from the response
const { idNotUser, authToken } = user;
if (!authToken) {
console.error('[LoginCallback] No authToken received from backend');
return router.push(Module.getInstance().get().modules.pages.Login.props.path + "?error=1");
}
// Store the auth token for API authentication
// TODO The authToken is just a uuid for now, it's very broken
CookieService.getInstance().setCookie("leCoffreAccessToken", authToken);
@ -109,7 +118,7 @@ export default function LoginCallBack() {
CookieService.getInstance().setCookie("leCoffreUserInfo", JSON.stringify(userInfoResponse.data));
setIsAuthModalOpen(true);
console.log('[LoginCallback] authToken stored successfully');
return;
} catch (e: any) {
if (e.http_status === 401 && e.message === "Email not found") {
@ -217,7 +226,7 @@ export default function LoginCallBack() {
// Office may not have a process too
let collaboratorProcess: { processId: string, processData: { [key: string]: any } } | null = null;
let officeProcess: { processId: string, processData: { [key: string]: any } } | null = null;
// Initialize collaborator process
try {
// Wait for pairing ID to be available before proceeding
@ -225,7 +234,7 @@ export default function LoginCallBack() {
console.log('[LoginCallback] Pairing ID obtained:', pairingId);
// Check if we are part of the right collaborator process
const myCollaboratorProcessesData = await MessageBus.getInstance().getProcessesDecoded((processId: string, values: { [key: string]: any }) => {
return values['utype'] === 'collaborator'
return values['utype'] === 'collaborator'
&& values['idNot'] === userInfo.idNot
&& values['isDeleted'] === 'false';
});
@ -261,7 +270,7 @@ export default function LoginCallBack() {
console.log('[LoginCallback] Pairing ID obtained:', pairingId);
// Now we need to check for office process
const myOfficeProcessesData = await MessageBus.getInstance().getProcessesDecoded((processId: string, values: { [key: string]: any }) => {
return values['utype'] === 'office'
return values['utype'] === 'office'
&& values['idNot'] === userInfo.office.idNot
&& values['isDeleted'] === 'false';
});

View File

@ -35,6 +35,8 @@ export class FrontendVariables {
public API_URL!: string;
public ANK_BASE_REDIRECT_URI!: string;
private constructor() {}
public static getInstance(): FrontendVariables {