Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get OIDC access tokens once the authentication redirect is successful #3250

Merged
2 changes: 2 additions & 0 deletions dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"@patternfly/patternfly": "^4.183.1",
"@patternfly/react-core": "^4.198.19",
"@patternfly/react-table": "^4.75.2",
"@react-keycloak/web": "^3.4.0",
"@testing-library/jest-dom": "^5.16.2",
"@testing-library/react": "^12.1.4",
"@testing-library/user-event": "^13.5.0",
Expand All @@ -21,6 +22,7 @@
"gulp": "^4.0.2",
"jest": "^27.5.1",
"js-cookie": "^3.0.1",
"keycloak-js": "^21.0.1",
"less-watch-compiler": "^1.16.3",
"patternfly": "^3.9.0",
"react": "^17.0.2",
Expand Down
62 changes: 31 additions & 31 deletions dashboard/src/App.css
Original file line number Diff line number Diff line change
@@ -1,70 +1,70 @@
body,
html {
padding: 0;
margin: 0;
height: 100%;
padding: 0;
margin: 0;
height: 100%;
}

ul>li {
list-style-type: none;
ul > li {
list-style-type: none;
}

#root {
height: 100%;
height: 100%;
}

.App {
height: 100%;
height: 100%;
}

/* Works on Firefox */
* {
scrollbar-width: thin;
scrollbar-color: #F5F5F5 #a39f9f;
scrollbar-width: thin;
scrollbar-color: #f5f5f5 #a39f9f;
}

/* Works on Chrome, Edge, and Safari */
::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.3);
border-radius: 10px;
background-color: #F5F5F5;
box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.3);
-webkit-box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.3);
border-radius: 10px;
background-color: #f5f5f5;
box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.3);
}

::-webkit-scrollbar {
width: 5px;
background-color: #F5F5F5;
width: 5px;
background-color: #f5f5f5;
}

::-webkit-scrollbar-thumb {
box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.3);
border-radius: 10px;
-webkit-box-shadow: inset 0 0 3px rgba(0, 0, 0, .3);
background-color: #a39f9f;
box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.3);
border-radius: 10px;
-webkit-box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.3);
background-color: #a39f9f;
}

/* Works on Firefox */
* {
scrollbar-width: thin;
scrollbar-color: #F5F5F5 #a39f9f;
scrollbar-width: thin;
scrollbar-color: #f5f5f5 #a39f9f;
}

/* Works on Chrome, Edge, and Safari */
::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.3);
border-radius: 10px;
background-color: #F5F5F5;
box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.3);
-webkit-box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.3);
border-radius: 10px;
background-color: #f5f5f5;
box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.3);
}

::-webkit-scrollbar {
width: 5px;
background-color: #F5F5F5;
width: 5px;
background-color: #f5f5f5;
}

::-webkit-scrollbar-thumb {
box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.3);
border-radius: 10px;
-webkit-box-shadow: inset 0 0 3px rgba(0, 0, 0, .3);
background-color: #a39f9f;
box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.3);
border-radius: 10px;
-webkit-box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.3);
background-color: #a39f9f;
}
98 changes: 54 additions & 44 deletions dashboard/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,19 @@ import { AuthForm } from "modules/components/AuthComponent/common-components";
import AuthLayout from "modules/containers/AuthLayout";
import ComingSoonPage from "modules/components/EmptyPageComponent/ComingSoon";
import Cookies from "js-cookie";
import LoginForm from "modules/components/AuthComponent/LoginForm";
import MainLayout from "modules/containers/MainLayout";
import NoMatchingPage from "modules/components/EmptyPageComponent/NoMatchingPage";
import OverviewComponent from "modules/components/OverviewComponent";
import ProfileComponent from "modules/components/ProfileComponent";
import SignupForm from "modules/components/AuthComponent/SignupForm";
import TableOfContent from "modules/components/TableOfContent";
import TableWithFavorite from "modules/components/TableComponent";
import favicon from "./assets/logo/favicon.ico";
import { fetchEndpoints } from "./actions/endpointAction";
import { getUserDetails } from "actions/authActions";
import { showToast } from "actions/toastActions";
import { useDispatch } from "react-redux";
import { useDispatch, useSelector } from "react-redux";
import { ReactKeycloakProvider } from "@react-keycloak/web";

const ProtectedRoute = ({ redirectPath = APP_ROUTES.AUTH_LOGIN, children }) => {
const ProtectedRoute = ({ redirectPath = APP_ROUTES.AUTH, children }) => {
const loggedIn = Cookies.get("isLoggedIn");
const dispatch = useDispatch();

Expand All @@ -47,56 +45,68 @@ const HomeRoute = ({ redirectPath = APP_ROUTES.HOME }) => {

const App = () => {
const dispatch = useDispatch();
const { keycloak } = useSelector((state) => state.apiEndpoint);

useEffect(() => {
const faviconLogo = document.getElementById("favicon");
faviconLogo?.setAttribute("href", favicon);

dispatch(fetchEndpoints);
dispatch(getUserDetails());
}, [dispatch]);

return (
<div className="App">
<BrowserRouter>
<Routes>
<Route path="/" element={<HomeRoute />}></Route>
<Route path={"/" + APP_ROUTES.HOME}>
<Route element={<AuthLayout />}>
<Route path={APP_ROUTES.AUTH_LOGIN} element={<LoginForm />} />
<Route path={APP_ROUTES.AUTH} element={<AuthForm />} />
<Route path={APP_ROUTES.AUTH_SIGNUP} element={<SignupForm />} />
</Route>
<Route element={<MainLayout />}>
<Route index element={<TableWithFavorite />} />
<Route element={<ProtectedRoute />}>
<Route
path={APP_ROUTES.USER_PROFILE}
element={<ProfileComponent />}
/>
<Route
path={APP_ROUTES.RESULTS}
element={<TableWithFavorite />}
/>
<Route
path={APP_ROUTES.OVERVIEW}
element={<OverviewComponent />}
/>
<Route
path={APP_ROUTES.TABLE_OF_CONTENT}
element={<TableOfContent />}
/>
<Route
path={APP_ROUTES.ANALYSIS}
element={<ComingSoonPage />}
/>
{keycloak && (
<ReactKeycloakProvider
authClient={keycloak}
initOptions={{
onLoad: "check-sso",
checkLoginIframe: true,
enableLogging: true,
}}
>
<BrowserRouter>
<Routes>
<Route path="/" element={<HomeRoute />}></Route>
<Route path={"/" + APP_ROUTES.HOME}>
<Route element={<AuthLayout />}>
<Route path={APP_ROUTES.AUTH} element={<AuthForm />} />
</Route>
<Route element={<MainLayout />}>
<Route index element={<TableWithFavorite />} />
<Route element={<ProtectedRoute />}>
<Route
path={APP_ROUTES.USER_PROFILE}
element={<ProfileComponent />}
/>
<Route
path={APP_ROUTES.RESULTS}
element={<TableWithFavorite />}
/>
<Route
path={APP_ROUTES.OVERVIEW}
element={<OverviewComponent />}
/>
<Route
path={APP_ROUTES.TABLE_OF_CONTENT}
element={<TableOfContent />}
/>
<Route
path={APP_ROUTES.ANALYSIS}
element={<ComingSoonPage />}
/>
</Route>
<Route
path={APP_ROUTES.SEARCH}
element={<ComingSoonPage />}
/>
</Route>
<Route path="*" element={<NoMatchingPage />} />
</Route>
<Route path={APP_ROUTES.SEARCH} element={<ComingSoonPage />} />
</Route>
<Route path="*" element={<NoMatchingPage />} />
</Route>
</Routes>
</BrowserRouter>
</Routes>
</BrowserRouter>
</ReactKeycloakProvider>
)}
</div>
);
};
Expand Down
Loading