acinguiux-dnr-utils
v0.0.5
Published
### Overview
Readme
Geneva Utils
Overview
The Geneva Utils package is designed to provide a collection of reusable functions that can be used across various Geneva Frontend applications. These functions aim to enhance the development process and improve code efficiency by offering commonly used functionalities in a modular and organized manner.
Integrate User Authorisation with monorepo App
We get user authorisation from a different endpoint from authentication. PingID is used for authentication and for authorisation we use https://ted.shell.com/
For a user getUserPermissions service can be used to fetch Authorisation from Ted
The authorisation needs an environment variables to work with.
AUTHORISATION_URL="https://ted-api-*.shell.com"
Without this variable it is assumed the application is not setup for user Authorisation and it will not fetch user permission from Ted endpoints.
The getUserPermissions service is always cached and revalidate every 15 minutes. Even if the application requests for multiple fetch it will alway return from cahce until expires;
From the application layout it can be integrated like
const userRoles = await getUserPermissions('PLATO');
const hasAccess = !!(userRoles?.[0]?.items?.[0].item_name === 'ALL RESOURCES');
return (
<html lang="en">
<head>
<link rel="icon" href="favicon.ico" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="anonymous" />
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"
/>
</head>
<body>
<Application session={session} aiConnectionString={process.env.INSIGHTS_CONNECTION_STRING} sidebar={hasAccess}>
{hasAccess ? children : <UnauthorizedAppCard title="No permissions to view Plato" />}
</Application>
</body>
</html>
);
};
