-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from InseeFr/manage-unauthorized-users
feat - impl usePermissions hook and securize authorized users only
- Loading branch information
Showing
16 changed files
with
349 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
VITE_API_ENDPOINT=https://api-pilotage-enquetes.developpement.insee.fr | ||
VITE_AUTH_TYPE=oidc | ||
VITE_OIDC_CLIENT_ID=coleman-pilotage | ||
VITE_OIDC_ISSUER=https://auth.insee.test/auth/realms/questionnaire-particuliers | ||
VITE_IDENTITY_PROVIDER=insee-ssp | ||
VITE_ADMIN_LDAP_ROLE=administrateur_Platine | ||
VITE_USER_LDAP_ROLE=utilisateur_Platine | ||
VITE_API_ENDPOINT=http://localhost:8000 | ||
VITE_AUTH_TYPE=anonymous | ||
VITE_OIDC_CLIENT_ID= | ||
VITE_OIDC_ISSUER=https://localhost:8000 | ||
VITE_IDENTITY_PROVIDER= | ||
VITE_ADMIN_LDAP_ROLE=admin | ||
VITE_USER_LDAP_ROLE=user | ||
VITE_APP_URL=http://localhost:5173 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { Typography } from "@mui/material"; | ||
import { useState, useEffect } from "react"; | ||
import { useOidc } from "../hooks/useAuth"; | ||
|
||
export function AutoLogoutCountdown() { | ||
const { isUserLoggedIn, subscribeToAutoLogoutCountdown } = useOidc(); | ||
const [secondsLeft, setSecondsLeft] = useState<number | undefined>(undefined); | ||
|
||
useEffect( | ||
() => { | ||
if (!isUserLoggedIn) { | ||
return; | ||
} | ||
|
||
const { unsubscribeFromAutoLogoutCountdown } = subscribeToAutoLogoutCountdown( | ||
({ secondsLeft }) => { | ||
setSecondsLeft(secondsLeft === undefined || secondsLeft > 60 ? undefined : secondsLeft), | ||
console.log(`seconds Left: ${secondsLeft}`); | ||
}, | ||
); | ||
|
||
return () => { | ||
console.log("unsuscribing"); | ||
unsubscribeFromAutoLogoutCountdown(); | ||
}; | ||
}, | ||
// NOTE: These dependency array could very well be empty | ||
// we're just making react-hooks/exhaustive-deps happy. | ||
// Unless you're hot swapping the oidc context isUserLoggedIn | ||
// and subscribeToAutoLogoutCountdown never change for the | ||
// lifetime of the app. | ||
[isUserLoggedIn, subscribeToAutoLogoutCountdown], | ||
); | ||
|
||
if (secondsLeft === undefined) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div | ||
// Full screen overlay, blurred background | ||
style={{ | ||
position: "fixed", | ||
top: 0, | ||
left: 0, | ||
right: 0, | ||
bottom: 0, | ||
backgroundColor: "rgba(0,0,0,0.5)", | ||
backdropFilter: "blur(10px)", | ||
display: "flex", | ||
justifyContent: "center", | ||
alignItems: "center", | ||
textAlign: "center", | ||
color: "white", | ||
fontWeight: "bold", | ||
zIndex: 1200, | ||
}} | ||
> | ||
<div> | ||
<Typography variant="h5">{"Vous êtes toujours là?"}</Typography> | ||
<Typography>{`Vous allez être déconnecté(e) dans ${secondsLeft} sec.`}</Typography> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { Stack, Typography, Box, Link } from "@mui/material"; | ||
import { Row } from "../ui/Row"; | ||
import { PropsWithChildren } from "react"; | ||
import { Link as RouterLink } from "react-router-dom"; | ||
|
||
export function LogoutPage() { | ||
return ( | ||
<> | ||
<Stack | ||
position="relative" | ||
sx={{ | ||
background: "linear-gradient(270deg, #21005D 0%, #9A82DB 0%, #E12358 90%)", | ||
}} | ||
justifyContent="center" | ||
alignItems="center" | ||
minHeight={500} | ||
height="calc(100vh - 230px)" | ||
> | ||
<Typography variant="displaySmall" fontWeight={400} color="white"> | ||
{"Vous avez été deconnecté,"} | ||
</Typography> | ||
<Row spacing={2}> | ||
<Typography variant="displaySmall" fontWeight={400} color="white"> | ||
{"pour revenir sur "} | ||
</Typography> | ||
<Row typography="headlineMedium" gap={0.25} color="red.main" component="span"> | ||
<Box component="span" color="black.main" fontWeight={600}> | ||
Platine | ||
</Box> | ||
Gestion | ||
</Row> | ||
, | ||
</Row> | ||
<Typography variant="displaySmall" fontWeight={400} color="white" component={HomeLink}> | ||
{"cliquez ici"} | ||
</Typography> | ||
</Stack> | ||
</> | ||
); | ||
} | ||
|
||
const HomeLink = (props: PropsWithChildren) => { | ||
return <Link component={RouterLink} underline="none" to="/" {...props} />; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.