Skip to content

Commit

Permalink
add session check on route (#32)
Browse files Browse the repository at this point in the history
* 1077: Add Route change listener that checks for a session when auth is enabled

* 1077: Prettier fixes

* Update library version

---------

Co-authored-by: Ruben van Leeuwen <[email protected]>
  • Loading branch information
DutchBen and Ruben van Leeuwen authored May 14, 2024
1 parent 6cd843b commit 0465d0a
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 107 deletions.
32 changes: 15 additions & 17 deletions configuration/configuration.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import process from 'process';
import process from "process";

import {
Environment,
OrchestratorConfig,
} from '@orchestrator-ui/orchestrator-ui-components';
} from "@orchestrator-ui/orchestrator-ui-components";

export const DEFAULT_GRAPHQL_CORE_ENDPOINT =
'http://localhost:8080/api/graphql';
export const DEFAULT_ORCHESTRATOR_API_BASE_URL = 'http://localhost:8080/api';
export const DEFAULT_ORCHESTRATOR_WEBSOCKET_URL = 'ws://localhost:8080';
"http://localhost:8080/api/graphql";
export const DEFAULT_ORCHESTRATOR_API_BASE_URL = "http://localhost:8080/api";
export const DEFAULT_ORCHESTRATOR_WEBSOCKET_URL = "ws://localhost:8080";

export const ENGINE_STATUS_ENDPOINT = '/settings/status';
export const PROCESSES_ENDPOINT = '/processes';
export const ENGINE_STATUS_ENDPOINT = "/settings/status";
export const PROCESS_STATUS_COUNTS_ENDPOINT = "/processes/status-counts";
export const PROCESSES_ENDPOINT = "/processes";
export const SUBSCRIPTION_ACTIONS_ENDPOINT = "/subscriptions/workflows";
export const SUBSCRIPTION_PROCESSES_ENDPOINT =
'/processes/process-subscriptions-by-subscription-id';
export const DEFAULT_WORKFLOW_INFORMATION_LINK_URL = 'http://localhost:8080';
"/processes/process-subscriptions-by-subscription-id";
export const DEFAULT_WORKFLOW_INFORMATION_LINK_URL = "http://localhost:8080";

export const getInitialOrchestratorConfig = (): OrchestratorConfig => {
const orchestratorGraphqlBaseUrl =
Expand All @@ -30,24 +32,20 @@ export const getInitialOrchestratorConfig = (): OrchestratorConfig => {

return {
orchestratorApiBaseUrl,
engineStatusEndpoint: orchestratorApiBaseUrl + ENGINE_STATUS_ENDPOINT,
graphqlEndpointCore: orchestratorGraphqlBaseUrl,
processesEndpoint: orchestratorApiBaseUrl + PROCESSES_ENDPOINT,
environmentName:
process.env.ENVIRONMENT_NAME ?? Environment.DEVELOPMENT,
subscriptionProcessesEndpoint:
orchestratorApiBaseUrl + SUBSCRIPTION_PROCESSES_ENDPOINT,
orchestratorWebsocketUrl:
process.env.ORCHESTRATOR_WEBSOCKET_URL ||
DEFAULT_ORCHESTRATOR_WEBSOCKET_URL,
authActive: process.env.AUTH_ACTIVE?.toLowerCase() != 'false',
useWebSockets: process.env.USE_WEB_SOCKETS?.toLowerCase() === 'true',
useThemeToggle: process.env.USE_THEME_TOGGLE?.toLowerCase() === 'true',
authActive: process.env.AUTH_ACTIVE?.toLowerCase() != "false",
useWebSockets: process.env.USE_WEB_SOCKETS?.toLowerCase() === "true",
useThemeToggle: process.env.USE_THEME_TOGGLE?.toLowerCase() === "true",
workflowInformationLinkUrl:
process.env.WORKFLOW_INFORMATION_LINK_URL ??
DEFAULT_WORKFLOW_INFORMATION_LINK_URL,
showWorkflowInformationLink:
process.env.SHOW_WORKFLOW_INFORMATION_LINK?.toLowerCase() ===
'true',
"true",
};
};
50 changes: 10 additions & 40 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

97 changes: 47 additions & 50 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { QueryParamProvider } from 'use-query-params';
import { EuiProvider, EuiThemeColorMode } from '@elastic/eui';
import '@elastic/eui/dist/eui_theme_light.min.css';
import {
ApiClientContextProvider,
ColorModes,
ConfirmationDialogContextWrapper,
OrchestratorConfig,
Expand All @@ -22,6 +21,7 @@ import {
WfoAuth,
WfoErrorBoundary,
WfoPageTemplate,
WfoRouteChangeListener,
WfoToastsList,
defaultOrchestratorTheme,
} from '@orchestrator-ui/orchestrator-ui-components';
Expand Down Expand Up @@ -77,64 +77,61 @@ function CustomApp({
initialOrchestratorConfig={orchestratorConfig}
>
<StoreProvider initialOrchestratorConfig={orchestratorConfig}>
<WfoRouteChangeListener />
<SessionProvider session={pageProps.session}>
<NoSSR>
<WfoAuth>
<EuiProvider
colorMode={themeMode}
modify={defaultOrchestratorTheme}
>
<ApiClientContextProvider>
<QueryClientProvider
client={queryClient}
contextSharing={true}
>
<TranslationsProvider>
<Head>
<link
rel="icon"
href="/favicon.png"
/>
<title>
Welcome to
example-orchestrator-ui!
</title>
</Head>
<main className="app">
<ConfirmationDialogContextWrapper>
<WfoPageTemplate
getAppLogo={
getAppLogo
}
onThemeSwitch={
handleThemeSwitch
<QueryClientProvider
client={queryClient}
contextSharing={true}
>
<TranslationsProvider>
<Head>
<link
rel="icon"
href="/favicon.png"
/>
<title>
Welcome to
example-orchestrator-ui!
</title>
</Head>
<main className="app">
<ConfirmationDialogContextWrapper>
<WfoPageTemplate
getAppLogo={getAppLogo}
onThemeSwitch={
handleThemeSwitch
}
>
<QueryParamProvider
adapter={
NextAdapter
}
options={{
removeDefaultsFromUrl:
false,
enableBatching:
true,
}}
>
<QueryParamProvider
adapter={
NextAdapter
}
options={{
removeDefaultsFromUrl:
false,
enableBatching:
true,
}}
>
<Component
{...pageProps}
/>
</QueryParamProvider>
</WfoPageTemplate>
<WfoToastsList />
</ConfirmationDialogContextWrapper>
<ReactQueryDevtools
initialIsOpen={false}
/>
</main>
</TranslationsProvider>
</QueryClientProvider>
</ApiClientContextProvider>
<Component
{...pageProps}
/>
</QueryParamProvider>
</WfoPageTemplate>
<WfoToastsList />
</ConfirmationDialogContextWrapper>
<ReactQueryDevtools
initialIsOpen={false}
/>
</main>
</TranslationsProvider>
</QueryClientProvider>
</EuiProvider>
</WfoAuth>
</NoSSR>
Expand Down

0 comments on commit 0465d0a

Please sign in to comment.