add france connect authorize
This commit is contained in:
parent
85728353a0
commit
04f366611d
@ -18,6 +18,7 @@
|
|||||||
"@types/react-dom": "18.0.11",
|
"@types/react-dom": "18.0.11",
|
||||||
"class-validator": "^0.14.0",
|
"class-validator": "^0.14.0",
|
||||||
"classnames": "^2.3.2",
|
"classnames": "^2.3.2",
|
||||||
|
"crypto-random-string": "^5.0.0",
|
||||||
"dotenv": "^16.0.3",
|
"dotenv": "^16.0.3",
|
||||||
"eslint": "8.36.0",
|
"eslint": "8.36.0",
|
||||||
"eslint-config-next": "13.2.4",
|
"eslint-config-next": "13.2.4",
|
||||||
|
@ -58,6 +58,11 @@ export default class Files extends BaseSuperAdmin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getUploadLink(uid: string): string {
|
||||||
|
return this.baseURl.concat(`/upload/${uid}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public async getByUid(uid: string, q?: any): Promise<File> {
|
public async getByUid(uid: string, q?: any): Promise<File> {
|
||||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
const query = { q };
|
const query = { q };
|
||||||
|
@ -20,6 +20,7 @@ import React from "react";
|
|||||||
import BasePage from "../../Base";
|
import BasePage from "../../Base";
|
||||||
import classes from "./classes.module.scss";
|
import classes from "./classes.module.scss";
|
||||||
import OcrResult from "./OcrResult";
|
import OcrResult from "./OcrResult";
|
||||||
|
import Files from "@Front/Api/LeCoffreApi/SuperAdmin/Files/Files";
|
||||||
|
|
||||||
|
|
||||||
type IProps = {};
|
type IProps = {};
|
||||||
@ -90,7 +91,7 @@ class ViewDocumentsClass extends BasePage<IPropsClass, IState> {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className={classes["file-container"]}>
|
<div className={classes["file-container"]}>
|
||||||
<FilePreview href={this.state.selectedFile.file_path as string} key={this.state.selectedFile.uid} />
|
<FilePreview href={Files.getInstance().getUploadLink(this.state.selectedFile?.uid as string)} key={this.state.selectedFile.uid} />
|
||||||
</div>
|
</div>
|
||||||
{this.state.document.files.length > 1 && (
|
{this.state.document.files.length > 1 && (
|
||||||
<div
|
<div
|
||||||
@ -199,7 +200,7 @@ class ViewDocumentsClass extends BasePage<IPropsClass, IState> {
|
|||||||
|
|
||||||
private downloadFile() {
|
private downloadFile() {
|
||||||
const fileName = this.state.selectedFile?.file_path?.split("/").pop();
|
const fileName = this.state.selectedFile?.file_path?.split("/").pop();
|
||||||
fetch(this.state.selectedFile?.file_path as string)
|
fetch(Files.getInstance().getUploadLink(this.state.selectedFile?.uid as string))
|
||||||
.then((resp) => resp.blob())
|
.then((resp) => resp.blob())
|
||||||
.then((blob) => {
|
.then((blob) => {
|
||||||
const url = window.URL.createObjectURL(blob);
|
const url = window.URL.createObjectURL(blob);
|
||||||
|
@ -10,7 +10,7 @@ import { useRouter } from "next/router";
|
|||||||
//import React, { useEffect, useState } from "react";
|
//import React, { useEffect, useState } from "react";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
//import Loader from "@Front/Components/DesignSystem/Loader";
|
//import Loader from "@Front/Components/DesignSystem/Loader";
|
||||||
import Auth from "@Front/Api/Auth/IdNot";
|
//import Auth from "@Front/Api/Auth/IdNot";
|
||||||
import Folder from "../Folder";
|
import Folder from "../Folder";
|
||||||
import LoginClass from "../Login";
|
import LoginClass from "../Login";
|
||||||
|
|
||||||
@ -75,15 +75,15 @@ export default function LoginCallBack(props: IPropsClass) {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { code } = router.query;
|
const { code } = router.query;
|
||||||
if (code) {
|
if (code) {
|
||||||
const getIdNotJwt = async () => {
|
// const getIdNotJwt = async () => {
|
||||||
try {
|
// try {
|
||||||
const authService = Auth.getInstance();
|
// const authService = Auth.getInstance();
|
||||||
await authService.getIdnotJwt(code);
|
// await authService.getIdnotJwt(code);
|
||||||
} catch (error) {
|
// } catch (error) {
|
||||||
console.error(error);
|
// console.error(error);
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
getIdNotJwt();
|
//getIdNotJwt();
|
||||||
return <Folder {...props} />;
|
return <Folder {...props} />;
|
||||||
}
|
}
|
||||||
return <LoginClass {...props} />;
|
return <LoginClass {...props} />;
|
||||||
|
@ -6,6 +6,8 @@ import Image from "next/image";
|
|||||||
import DefaultDoubleSidePage from "@Front/Components/LayoutTemplates/DefaultDoubleSidePage";
|
import DefaultDoubleSidePage from "@Front/Components/LayoutTemplates/DefaultDoubleSidePage";
|
||||||
import FranceConnectIcon from "./france-connect.svg";
|
import FranceConnectIcon from "./france-connect.svg";
|
||||||
import ExportIcon from "@Assets/Icons/export.svg";
|
import ExportIcon from "@Assets/Icons/export.svg";
|
||||||
|
import { FrontendVariables } from "@Front/Config/VariablesFront";
|
||||||
|
import cryptoRandomString from "crypto-random-string";
|
||||||
|
|
||||||
export default class LoginCustomer extends BasePage {
|
export default class LoginCustomer extends BasePage {
|
||||||
public override render(): JSX.Element {
|
public override render(): JSX.Element {
|
||||||
@ -35,12 +37,12 @@ export default class LoginCustomer extends BasePage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private redirectUserOnConnection() {
|
private redirectUserOnConnection() {
|
||||||
// const variables = FrontendVariables.getInstance();
|
const variables = FrontendVariables.getInstance();
|
||||||
// const baseFronturl =
|
// const baseFronturl =
|
||||||
// variables.BACK_API_PROTOCOL + variables.FRONT_APP_HOST + (variables.FRONT_APP_PORT ? ":" + variables.FRONT_APP_PORT : "");
|
// variables.BACK_API_PROTOCOL + variables.FRONT_APP_HOST + (variables.FRONT_APP_PORT ? ":" + variables.FRONT_APP_PORT : "");
|
||||||
// const authorizeEndPoint = variables.IDNOT_AUTHORIZE_ENDPOINT;
|
const authorizeEndPoint = variables.FC_AUTHORIZE_ENDPOINT;
|
||||||
// const clientId = variables.IDNOT_CLIENT_ID;
|
const clientId = variables.FC_CLIENT_ID;
|
||||||
// const url = `${authorizeEndPoint}?client_id=${clientId}&redirect_uri=${baseFronturl}/authorized-client&scope=openid,profile,offline_access&response_type=code`;
|
const url = `${authorizeEndPoint}?client_id=${clientId}&redirect_uri=http://localhost:8080/login-callback&scope=openid&response_type=code&state=${cryptoRandomString({length: 64})}&nonce=${cryptoRandomString({length: 64})}&acr_values=eidas1`;
|
||||||
// window.location.assign(url);
|
window.location.assign(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,10 @@ export class FrontendVariables {
|
|||||||
|
|
||||||
public KEY_DATA!: string;
|
public KEY_DATA!: string;
|
||||||
|
|
||||||
|
public FC_AUTHORIZE_ENDPOINT!: string;
|
||||||
|
|
||||||
|
public FC_CLIENT_ID!: string;
|
||||||
|
|
||||||
private constructor() {}
|
private constructor() {}
|
||||||
|
|
||||||
public static getInstance(): FrontendVariables {
|
public static getInstance(): FrontendVariables {
|
||||||
|
@ -20,6 +20,8 @@ type AppPropsWithLayout = AppProps & {
|
|||||||
frontAppPort: string;
|
frontAppPort: string;
|
||||||
idNotAuthorizeEndpoint: string;
|
idNotAuthorizeEndpoint: string;
|
||||||
idNotClientId: string;
|
idNotClientId: string;
|
||||||
|
fcAuthorizeEndpoint: string;
|
||||||
|
fcClientId: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const MyApp = (({
|
const MyApp = (({
|
||||||
@ -33,6 +35,8 @@ const MyApp = (({
|
|||||||
frontAppPort,
|
frontAppPort,
|
||||||
idNotAuthorizeEndpoint,
|
idNotAuthorizeEndpoint,
|
||||||
idNotClientId,
|
idNotClientId,
|
||||||
|
fcAuthorizeEndpoint,
|
||||||
|
fcClientId
|
||||||
}: AppPropsWithLayout) => {
|
}: AppPropsWithLayout) => {
|
||||||
const getLayout = Component.getLayout ?? ((page) => <DefaultLayout children={page}></DefaultLayout>);
|
const getLayout = Component.getLayout ?? ((page) => <DefaultLayout children={page}></DefaultLayout>);
|
||||||
|
|
||||||
@ -45,6 +49,8 @@ const MyApp = (({
|
|||||||
instance.FRONT_APP_PORT = frontAppPort;
|
instance.FRONT_APP_PORT = frontAppPort;
|
||||||
instance.IDNOT_AUTHORIZE_ENDPOINT = idNotAuthorizeEndpoint;
|
instance.IDNOT_AUTHORIZE_ENDPOINT = idNotAuthorizeEndpoint;
|
||||||
instance.IDNOT_CLIENT_ID = idNotClientId;
|
instance.IDNOT_CLIENT_ID = idNotClientId;
|
||||||
|
instance.FC_AUTHORIZE_ENDPOINT= fcAuthorizeEndpoint;
|
||||||
|
instance.FC_CLIENT_ID = fcClientId
|
||||||
|
|
||||||
return getLayout(<Component {...pageProps} />);
|
return getLayout(<Component {...pageProps} />);
|
||||||
}) as AppType;
|
}) as AppType;
|
||||||
@ -59,6 +65,8 @@ MyApp.getInitialProps = async () => {
|
|||||||
frontAppPort: process.env["NEXT_PUBLIC_FRONT_APP_PORT"],
|
frontAppPort: process.env["NEXT_PUBLIC_FRONT_APP_PORT"],
|
||||||
idNotAuthorizeEndpoint: process.env["NEXT_PUBLIC_IDNOT_AUTHORIZE_ENDPOINT"],
|
idNotAuthorizeEndpoint: process.env["NEXT_PUBLIC_IDNOT_AUTHORIZE_ENDPOINT"],
|
||||||
idNotClientId: process.env["NEXT_PUBLIC_IDNOT_CLIENT_ID"],
|
idNotClientId: process.env["NEXT_PUBLIC_IDNOT_CLIENT_ID"],
|
||||||
|
fcAuthorizeEndpoint: process.env["NEXT_PUBLIC_FC_AUTHORIZE_ENDPOINT"],
|
||||||
|
fcClientId: process.env["NEXT_PUBLIC_FC_CLIENT_ID"]
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
5
src/pages/login-callback.tsx
Normal file
5
src/pages/login-callback.tsx
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import ClientDashboard from "@Front/Components/Layouts/ClientDashboard";
|
||||||
|
|
||||||
|
export default function Route() {
|
||||||
|
return <ClientDashboard />;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user