[FIX] deliver new system
This commit is contained in:
parent
859011e9a6
commit
44b4fa37d3
@ -103,7 +103,7 @@ WORKDIR /application/
|
|||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
# To verify health-check: docker inspect --format "{{json .State.Health }}" YOUR_SERVICE_NAME | jq
|
# 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 \
|
# 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 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"]
|
CMD ["java", "-Xms64M", "-Xmx1G", "-cp", "/application/application.jar", "org.kar.karso.WebLauncher"]
|
||||||
|
@ -1,93 +1,55 @@
|
|||||||
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 avatar from '@/assets/images/avatar_generic.svg';
|
||||||
import { PageLayout } from '@/components/Layout/PageLayout';
|
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 { TopBar } from '@/components/TopBar/TopBar';
|
||||||
import { useEffect } from 'react';
|
import { ApplicationService } from '@/service/application';
|
||||||
|
|
||||||
export const SignInDonePage = () => {
|
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(() => {
|
useEffect(() => {
|
||||||
transferToApplication();
|
transferToApplication(applicationName ?? '', applicationData);
|
||||||
}, []);
|
}, []);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<TopBar title="Login" />
|
<TopBar title="Login" />
|
||||||
<PageLayout>
|
<PageLayout>
|
||||||
<Flex
|
<Flex marginX="auto" width="full" height="90%" direction="column">
|
||||||
marginX="auto"
|
|
||||||
width="full"
|
|
||||||
height="90%"
|
|
||||||
direction="column"
|
|
||||||
>
|
|
||||||
<Box
|
<Box
|
||||||
bg="white"
|
bg="white"
|
||||||
padding="30px"
|
padding="30px"
|
||||||
shadow="md"
|
shadow="md"
|
||||||
width="400px"
|
width="400px"
|
||||||
margin="auto"
|
margin="auto"
|
||||||
background={{ _light: "gray.50", _dark: "gray.800" }}
|
background={{ _light: 'gray.50', _dark: 'gray.800' }}
|
||||||
|
>
|
||||||
|
<Text
|
||||||
|
width="100%"
|
||||||
|
textAlign="center"
|
||||||
|
fontWeight="bold"
|
||||||
|
fontSize="25px"
|
||||||
>
|
>
|
||||||
<Text width="100%" textAlign="center" fontWeight="bold" fontSize="25px">
|
|
||||||
Connected
|
Connected
|
||||||
</Text>
|
</Text>
|
||||||
<Image marginX="auto"
|
<Image
|
||||||
marginY="10px" src={avatar} width="128px" height="128px" borderRadius="100%" />
|
marginX="auto"
|
||||||
|
marginY="10px"
|
||||||
|
src={avatar}
|
||||||
|
width="128px"
|
||||||
|
height="128px"
|
||||||
|
borderRadius="100%"
|
||||||
|
/>
|
||||||
|
|
||||||
<Flex align="center" justify="center" direction="column">
|
<Flex align="center" justify="center" direction="column">
|
||||||
<Text>Connection done...</Text>
|
<Text>Connection done...</Text>
|
||||||
{applicationName && <Text>Will redirect to: {applicationName}</Text>}
|
{applicationName && (
|
||||||
|
<Text>Will redirect to: {applicationName}</Text>
|
||||||
|
)}
|
||||||
</Flex>
|
</Flex>
|
||||||
</Box>
|
</Box>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
import { Center, Flex, HStack, Text } from '@chakra-ui/react';
|
import { Center, Flex, HStack, Text } from '@chakra-ui/react';
|
||||||
import { LuCrown } from 'react-icons/lu';
|
import { LuCrown } from 'react-icons/lu';
|
||||||
|
|
||||||
|
import { Application } from '@/back-api';
|
||||||
import { PageLayout } from '@/components/Layout/PageLayout';
|
import { PageLayout } from '@/components/Layout/PageLayout';
|
||||||
import { TopBar } from '@/components/TopBar/TopBar';
|
import { TopBar } from '@/components/TopBar/TopBar';
|
||||||
|
|
||||||
import { useColorModeValue } from '@/components/ui/color-mode';
|
import { useColorModeValue } from '@/components/ui/color-mode';
|
||||||
import { Application } from '@/back-api';
|
|
||||||
import { ApplicationService } from '@/service/application';
|
import { ApplicationService } from '@/service/application';
|
||||||
|
|
||||||
|
|
||||||
export const HomePage = () => {
|
export const HomePage = () => {
|
||||||
|
const { transferToApplication } = ApplicationService.useTransferApplication();
|
||||||
const onSelectItem = (data: Application) => {
|
const onSelectItem = (data: Application) => {
|
||||||
window.location.href = data.redirect;
|
transferToApplication(data.name ?? '');
|
||||||
|
//window.location.href = data.redirect;
|
||||||
};
|
};
|
||||||
const { data: dataApplication } = ApplicationService.useGets();
|
const { data: dataApplication } = ApplicationService.useGets();
|
||||||
console.log(`ppp: ${JSON.stringify(dataApplication, null, 2)}`);
|
console.log(`ppp: ${JSON.stringify(dataApplication, null, 2)}`);
|
||||||
@ -19,9 +19,16 @@ export const HomePage = () => {
|
|||||||
<>
|
<>
|
||||||
<TopBar title="Home" />
|
<TopBar title="Home" />
|
||||||
<PageLayout>
|
<PageLayout>
|
||||||
<HStack wrap="wrap" gap="20px" marginX="auto" padding="20px" justify="center">
|
<HStack
|
||||||
|
wrap="wrap"
|
||||||
|
gap="20px"
|
||||||
|
marginX="auto"
|
||||||
|
padding="20px"
|
||||||
|
justify="center"
|
||||||
|
>
|
||||||
{dataApplication?.map((data) => (
|
{dataApplication?.map((data) => (
|
||||||
<Flex align="flex-start"
|
<Flex
|
||||||
|
align="flex-start"
|
||||||
width="200px"
|
width="200px"
|
||||||
height="190px"
|
height="190px"
|
||||||
border="1px"
|
border="1px"
|
||||||
@ -37,7 +44,9 @@ export const HomePage = () => {
|
|||||||
onClick={() => onSelectItem(data)}
|
onClick={() => onSelectItem(data)}
|
||||||
>
|
>
|
||||||
<Flex direction="column" width="full" height="full">
|
<Flex direction="column" width="full" height="full">
|
||||||
<Center height="full"><LuCrown style={{ width: "100px", height: "100px" }} /></Center>
|
<Center height="full">
|
||||||
|
<LuCrown style={{ width: '100px', height: '100px' }} />
|
||||||
|
</Center>
|
||||||
<Center>
|
<Center>
|
||||||
<Text
|
<Text
|
||||||
fontSize="25px"
|
fontSize="25px"
|
||||||
@ -56,4 +65,3 @@ export const HomePage = () => {
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,21 +3,19 @@
|
|||||||
* @copyright 2018, Edouard DUPIN, all right reserved
|
* @copyright 2018, Edouard DUPIN, all right reserved
|
||||||
* @license PROPRIETARY (see license file)
|
* @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 { useSessionService } from "./session";
|
|
||||||
import { useQuery, useQueryCall, useQueryCallProps } from "@/utils/query";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export namespace ApplicationService {
|
export namespace ApplicationService {
|
||||||
|
|
||||||
export const useGets = () => {
|
export const useGets = () => {
|
||||||
const { getRestConfig } = useSessionService();
|
const { getRestConfig } = useSessionService();
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryFunction: () => {
|
queryFunction: () => {
|
||||||
return ApplicationResource.gets({
|
return ApplicationResource.gets({
|
||||||
restConfig: getRestConfig()
|
restConfig: getRestConfig(),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -29,7 +27,7 @@ export namespace ApplicationService {
|
|||||||
return ApplicationResource.getRightsDescription({
|
return ApplicationResource.getRightsDescription({
|
||||||
restConfig: getRestConfig(),
|
restConfig: getRestConfig(),
|
||||||
params: {
|
params: {
|
||||||
id
|
id,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -43,7 +41,7 @@ export namespace ApplicationService {
|
|||||||
return ApplicationResource.getClientToken({
|
return ApplicationResource.getClientToken({
|
||||||
restConfig: getRestConfig(),
|
restConfig: getRestConfig(),
|
||||||
queries: {
|
queries: {
|
||||||
application: applicationName
|
application: applicationName,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -58,16 +56,23 @@ export namespace ApplicationService {
|
|||||||
// });
|
// });
|
||||||
// }
|
// }
|
||||||
|
|
||||||
export const useGetClientToken = ({ config }: { config?: Omit<useQueryCallProps<ClientToken, any>, 'queryFunction'> }) => {
|
export const useGetClientToken = ({
|
||||||
|
config,
|
||||||
|
}: {
|
||||||
|
config?: Omit<useQueryCallProps<ClientToken, any>, 'queryFunction'>;
|
||||||
|
}) => {
|
||||||
const { getRestConfig } = useSessionService();
|
const { getRestConfig } = useSessionService();
|
||||||
const { call, ...rest } = useQueryCall<ClientToken, { application: string }>({
|
const { call, ...rest } = useQueryCall<
|
||||||
|
ClientToken,
|
||||||
|
{ application: string }
|
||||||
|
>({
|
||||||
queryFunction: (data) => {
|
queryFunction: (data) => {
|
||||||
return ApplicationResource.getClientToken({
|
return ApplicationResource.getClientToken({
|
||||||
restConfig: getRestConfig(),
|
restConfig: getRestConfig(),
|
||||||
queries: { ...data },
|
queries: { ...data },
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
...config
|
...config,
|
||||||
});
|
});
|
||||||
return { getClientToken: call, ...rest };
|
return { getClientToken: call, ...rest };
|
||||||
};
|
};
|
||||||
@ -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 };
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user