diff --git a/Dockerfile b/Dockerfile
index 83845eb..9e6324c 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -103,7 +103,7 @@ WORKDIR /application/
EXPOSE 80
# To verify health-check: docker inspect --format "{{json .State.Health }}" YOUR_SERVICE_NAME | jq
-HEALTHCHECK --start-period=30s --start-interval=5s --interval=30s --timeout=5s --retries=10 \
- CMD wget --no-verbose --tries=1 --spider http://localhost:80/karso/api/health_check || exit 1
+# HEALTHCHECK --start-period=30s --start-interval=5s --interval=30s --timeout=5s --retries=10 \
+# CMD wget --no-verbose --tries=1 --spider http://localhost:80/karso/api/health_check || exit 1
CMD ["java", "-Xms64M", "-Xmx1G", "-cp", "/application/application.jar", "org.kar.karso.WebLauncher"]
diff --git a/front/src/scene/connection/SignInDonePage.tsx b/front/src/scene/connection/SignInDonePage.tsx
index ed9eecb..f605c8e 100644
--- a/front/src/scene/connection/SignInDonePage.tsx
+++ b/front/src/scene/connection/SignInDonePage.tsx
@@ -1,94 +1,56 @@
-import { Box, Flex, Image, Text, Button } from '@chakra-ui/react';
+import { useEffect } from 'react';
+
+import { Box, Flex, Image, Text } from '@chakra-ui/react';
+import { useParams } from 'react-router-dom';
import avatar from '@/assets/images/avatar_generic.svg';
import { PageLayout } from '@/components/Layout/PageLayout';
-import { useParams } from 'react-router-dom';
-import { useSessionService } from '@/service/session';
-import { ApplicationResource } from '@/back-api';
-import { toasterAPIError, toaster } from '@/components/ui/toaster';
import { TopBar } from '@/components/TopBar/TopBar';
-import { useEffect } from 'react';
-
+import { ApplicationService } from '@/service/application';
+
export const SignInDonePage = () => {
- const { getRestConfig, clearToken } = useSessionService();
- const { applicationName, applicationData} = useParams();
+ const { applicationName, applicationData } = useParams();
+ const { transferToApplication } = ApplicationService.useTransferApplication();
- const transferToApplication = (): void => {
- ApplicationResource.getClientToken({
- restConfig: getRestConfig(),
- queries: { application:applicationName ?? '' },
- }).then((response)=> {
- if (!response.url || !response.jwt) {
- toaster.create({
- title: "Error data",
- description: "Fail to retrieve data",
- type: 'error'
- });
- } else {
- toaster.create({
- title: "Request transfer",
- type:"success"
- });
- transferToApplicationThatRequiredTheSSO(response.url, response.jwt);
- }
- }).catch((error)=> {
- toasterAPIError(error);
- if (error.status == 401) {
- // Authentication error ==> auto_disconnect
- clearToken();
- toaster.create({
- title: "Disconnected by server",
- description: "Token is no more available",
- type:"error"
- });
- }
- });
- }
-
- const transferToApplicationThatRequiredTheSSO = (url: string, token: string): void => {
- if (url.slice(-1) === '/') {
- url = url.slice(0, -1);
- }
- let ssoApplicationReturnUrl;
- if (applicationData === undefined) {
- ssoApplicationReturnUrl = `${url}/aG9tZQ/false/`;
- } else {
- ssoApplicationReturnUrl = `${url}/${applicationData}/false/`;
- }
- console.log(`generate in new URL: ${ssoApplicationReturnUrl + token}`);
- //window.location.href = ssoApplicationReturnUrl + token;
- }
- useEffect(()=> {
- transferToApplication();
+ useEffect(() => {
+ transferToApplication(applicationName ?? '', applicationData);
}, []);
return (
<>
-
+
-
+
Connected
-
+
Connection done...
- {applicationName && Will redirect to: {applicationName}}
-
+ {applicationName && (
+ Will redirect to: {applicationName}
+ )}
+
diff --git a/front/src/scene/home/HomePage.tsx b/front/src/scene/home/HomePage.tsx
index 88c85a4..4bb5c18 100644
--- a/front/src/scene/home/HomePage.tsx
+++ b/front/src/scene/home/HomePage.tsx
@@ -1,17 +1,17 @@
import { Center, Flex, HStack, Text } from '@chakra-ui/react';
import { LuCrown } from 'react-icons/lu';
+import { Application } from '@/back-api';
import { PageLayout } from '@/components/Layout/PageLayout';
import { TopBar } from '@/components/TopBar/TopBar';
-
import { useColorModeValue } from '@/components/ui/color-mode';
-import { Application } from '@/back-api';
import { ApplicationService } from '@/service/application';
-
export const HomePage = () => {
+ const { transferToApplication } = ApplicationService.useTransferApplication();
const onSelectItem = (data: Application) => {
- window.location.href = data.redirect;
+ transferToApplication(data.name ?? '');
+ //window.location.href = data.redirect;
};
const { data: dataApplication } = ApplicationService.useGets();
console.log(`ppp: ${JSON.stringify(dataApplication, null, 2)}`);
@@ -19,9 +19,16 @@ export const HomePage = () => {
<>
-
+
{dataApplication?.map((data) => (
- {
onClick={() => onSelectItem(data)}
>
-
+
+
+
{
>
);
};
-
diff --git a/front/src/service/application.ts b/front/src/service/application.ts
index ec1cdd5..0aee77b 100644
--- a/front/src/service/application.ts
+++ b/front/src/service/application.ts
@@ -3,76 +3,81 @@
* @copyright 2018, Edouard DUPIN, all right reserved
* @license PROPRIETARY (see license file)
*/
+import { ApplicationResource, ClientToken, Long } from '@/back-api';
+import { toaster, toasterAPIError } from '@/components/ui/toaster';
+import { useQuery, useQueryCall, useQueryCallProps } from '@/utils/query';
-import { Long, ApplicationResource, ClientToken } from "@/back-api";
-import { useSessionService } from "./session";
-import { useQuery, useQueryCall, useQueryCallProps } from "@/utils/query";
-
-
+import { useSessionService } from './session';
export namespace ApplicationService {
+ export const useGets = () => {
+ const { getRestConfig } = useSessionService();
+ return useQuery({
+ queryFunction: () => {
+ return ApplicationResource.gets({
+ restConfig: getRestConfig(),
+ });
+ },
+ });
+ };
+ export const useGetRightsDescription = (id: Long) => {
+ const { getRestConfig } = useSessionService();
+ return useQuery({
+ queryFunction: () => {
+ return ApplicationResource.getRightsDescription({
+ restConfig: getRestConfig(),
+ params: {
+ id,
+ },
+ });
+ },
+ });
+ };
- export const useGets = () => {
- const { getRestConfig } = useSessionService();
- return useQuery({
- queryFunction: () => {
- return ApplicationResource.gets({
- restConfig: getRestConfig()
- });
- },
- });
- };
- export const useGetRightsDescription = (id: Long) => {
- const { getRestConfig } = useSessionService();
- return useQuery({
- queryFunction: () => {
- return ApplicationResource.getRightsDescription({
- restConfig: getRestConfig(),
- params: {
- id
- },
- });
- },
- });
- };
+ export const useGetApplicationReturn = (applicationName: string) => {
+ const { getRestConfig } = useSessionService();
+ return useQuery({
+ queryFunction: () => {
+ return ApplicationResource.getClientToken({
+ restConfig: getRestConfig(),
+ queries: {
+ application: applicationName,
+ },
+ });
+ },
+ });
+ };
+ // getApplicationReturn(application: string): Promise < string > {
+ // return ApplicationResource.logOut({
+ // restConfig: this.getRestConfig(),
+ // queries: {
+ // application
+ // },
+ // });
+ // }
- export const useGetApplicationReturn = (applicationName: string) => {
- const { getRestConfig } = useSessionService();
- return useQuery({
- queryFunction: () => {
- return ApplicationResource.getClientToken({
- restConfig: getRestConfig(),
- queries: {
- application: applicationName
- },
- });
- },
- });
- };
- // getApplicationReturn(application: string): Promise < string > {
- // return ApplicationResource.logOut({
- // restConfig: this.getRestConfig(),
- // queries: {
- // application
- // },
- // });
- // }
+ export const useGetClientToken = ({
+ config,
+ }: {
+ config?: Omit, 'queryFunction'>;
+ }) => {
+ const { getRestConfig } = useSessionService();
+ const { call, ...rest } = useQueryCall<
+ ClientToken,
+ { application: string }
+ >({
+ queryFunction: (data) => {
+ return ApplicationResource.getClientToken({
+ restConfig: getRestConfig(),
+ queries: { ...data },
+ });
+ },
+ ...config,
+ });
+ return { getClientToken: call, ...rest };
+ };
- export const useGetClientToken = ({ config }: { config?: Omit, 'queryFunction'> }) => {
- const { getRestConfig } = useSessionService();
- const { call, ...rest } = useQueryCall({
- queryFunction: (data) => {
- return ApplicationResource.getClientToken({
- restConfig: getRestConfig(),
- queries: { ...data },
- });
- },
- ...config
- });
- return { getClientToken: call, ...rest };
- };
-
- /*
+ /*
getApplicationSpecificToken(application: string): Promise < ClientToken > {
return ApplicationResource.getClientToken({
restConfig: this.getRestConfig(),
@@ -166,4 +171,68 @@ export namespace ApplicationService {
},
});
}*/
+
+ export const useTransferApplication = () => {
+ const { getRestConfig, clearToken } = useSessionService();
+ const transferToApplicationThatRequiredTheSSO = (
+ url: string,
+ token: string,
+ applicationData?: string
+ ): void => {
+ if (url.slice(-1) === '/') {
+ url = url.slice(0, -1);
+ }
+ let ssoApplicationReturnUrl;
+ if (applicationData === undefined) {
+ ssoApplicationReturnUrl = `${url}/aG9tZQ/false/`;
+ } else {
+ ssoApplicationReturnUrl = `${url}/${applicationData}/false/`;
+ }
+ console.log(`generate in new URL: ${ssoApplicationReturnUrl + token}`);
+ window.location.href = ssoApplicationReturnUrl + token;
+ };
+
+ const transferToApplication = (
+ appName: string,
+ applicationData?: string
+ ): void => {
+ ApplicationResource.getClientToken({
+ restConfig: getRestConfig(),
+ queries: { application: appName },
+ })
+ .then((response) => {
+ if (!response.url || !response.jwt) {
+ toaster.create({
+ title: 'Error data',
+ description: 'Fail to retrieve data',
+ type: 'error',
+ });
+ } else {
+ toaster.create({
+ title: 'Request transfer',
+ type: 'success',
+ });
+ transferToApplicationThatRequiredTheSSO(
+ response.url,
+ response.jwt,
+ applicationData
+ );
+ }
+ })
+ .catch((error) => {
+ toasterAPIError(error);
+ if (error.status == 401) {
+ // Authentication error ==> auto_disconnect
+ clearToken();
+ toaster.create({
+ title: 'Disconnected by server',
+ description: 'Token is no more available',
+ type: 'error',
+ });
+ }
+ });
+ };
+
+ return { transferToApplication };
+ };
}