Skip to content

Commit 0465d0a

Browse files
DutchBenRuben van Leeuwen
andauthored
add session check on route (#32)
* 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]>
1 parent 6cd843b commit 0465d0a

File tree

3 files changed

+72
-107
lines changed

3 files changed

+72
-107
lines changed

configuration/configuration.ts

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1-
import process from 'process';
1+
import process from "process";
22

33
import {
44
Environment,
55
OrchestratorConfig,
6-
} from '@orchestrator-ui/orchestrator-ui-components';
6+
} from "@orchestrator-ui/orchestrator-ui-components";
77

88
export const DEFAULT_GRAPHQL_CORE_ENDPOINT =
9-
'http://localhost:8080/api/graphql';
10-
export const DEFAULT_ORCHESTRATOR_API_BASE_URL = 'http://localhost:8080/api';
11-
export const DEFAULT_ORCHESTRATOR_WEBSOCKET_URL = 'ws://localhost:8080';
9+
"http://localhost:8080/api/graphql";
10+
export const DEFAULT_ORCHESTRATOR_API_BASE_URL = "http://localhost:8080/api";
11+
export const DEFAULT_ORCHESTRATOR_WEBSOCKET_URL = "ws://localhost:8080";
1212

13-
export const ENGINE_STATUS_ENDPOINT = '/settings/status';
14-
export const PROCESSES_ENDPOINT = '/processes';
13+
export const ENGINE_STATUS_ENDPOINT = "/settings/status";
14+
export const PROCESS_STATUS_COUNTS_ENDPOINT = "/processes/status-counts";
15+
export const PROCESSES_ENDPOINT = "/processes";
16+
export const SUBSCRIPTION_ACTIONS_ENDPOINT = "/subscriptions/workflows";
1517
export const SUBSCRIPTION_PROCESSES_ENDPOINT =
16-
'/processes/process-subscriptions-by-subscription-id';
17-
export const DEFAULT_WORKFLOW_INFORMATION_LINK_URL = 'http://localhost:8080';
18+
"/processes/process-subscriptions-by-subscription-id";
19+
export const DEFAULT_WORKFLOW_INFORMATION_LINK_URL = "http://localhost:8080";
1820

1921
export const getInitialOrchestratorConfig = (): OrchestratorConfig => {
2022
const orchestratorGraphqlBaseUrl =
@@ -30,24 +32,20 @@ export const getInitialOrchestratorConfig = (): OrchestratorConfig => {
3032

3133
return {
3234
orchestratorApiBaseUrl,
33-
engineStatusEndpoint: orchestratorApiBaseUrl + ENGINE_STATUS_ENDPOINT,
3435
graphqlEndpointCore: orchestratorGraphqlBaseUrl,
35-
processesEndpoint: orchestratorApiBaseUrl + PROCESSES_ENDPOINT,
3636
environmentName:
3737
process.env.ENVIRONMENT_NAME ?? Environment.DEVELOPMENT,
38-
subscriptionProcessesEndpoint:
39-
orchestratorApiBaseUrl + SUBSCRIPTION_PROCESSES_ENDPOINT,
4038
orchestratorWebsocketUrl:
4139
process.env.ORCHESTRATOR_WEBSOCKET_URL ||
4240
DEFAULT_ORCHESTRATOR_WEBSOCKET_URL,
43-
authActive: process.env.AUTH_ACTIVE?.toLowerCase() != 'false',
44-
useWebSockets: process.env.USE_WEB_SOCKETS?.toLowerCase() === 'true',
45-
useThemeToggle: process.env.USE_THEME_TOGGLE?.toLowerCase() === 'true',
41+
authActive: process.env.AUTH_ACTIVE?.toLowerCase() != "false",
42+
useWebSockets: process.env.USE_WEB_SOCKETS?.toLowerCase() === "true",
43+
useThemeToggle: process.env.USE_THEME_TOGGLE?.toLowerCase() === "true",
4644
workflowInformationLinkUrl:
4745
process.env.WORKFLOW_INFORMATION_LINK_URL ??
4846
DEFAULT_WORKFLOW_INFORMATION_LINK_URL,
4947
showWorkflowInformationLink:
5048
process.env.SHOW_WORKFLOW_INFORMATION_LINK?.toLowerCase() ===
51-
'true',
49+
"true",
5250
};
5351
};

package-lock.json

Lines changed: 10 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pages/_app.tsx

Lines changed: 47 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { QueryParamProvider } from 'use-query-params';
1313
import { EuiProvider, EuiThemeColorMode } from '@elastic/eui';
1414
import '@elastic/eui/dist/eui_theme_light.min.css';
1515
import {
16-
ApiClientContextProvider,
1716
ColorModes,
1817
ConfirmationDialogContextWrapper,
1918
OrchestratorConfig,
@@ -22,6 +21,7 @@ import {
2221
WfoAuth,
2322
WfoErrorBoundary,
2423
WfoPageTemplate,
24+
WfoRouteChangeListener,
2525
WfoToastsList,
2626
defaultOrchestratorTheme,
2727
} from '@orchestrator-ui/orchestrator-ui-components';
@@ -77,64 +77,61 @@ function CustomApp({
7777
initialOrchestratorConfig={orchestratorConfig}
7878
>
7979
<StoreProvider initialOrchestratorConfig={orchestratorConfig}>
80+
<WfoRouteChangeListener />
8081
<SessionProvider session={pageProps.session}>
8182
<NoSSR>
8283
<WfoAuth>
8384
<EuiProvider
8485
colorMode={themeMode}
8586
modify={defaultOrchestratorTheme}
8687
>
87-
<ApiClientContextProvider>
88-
<QueryClientProvider
89-
client={queryClient}
90-
contextSharing={true}
91-
>
92-
<TranslationsProvider>
93-
<Head>
94-
<link
95-
rel="icon"
96-
href="/favicon.png"
97-
/>
98-
<title>
99-
Welcome to
100-
example-orchestrator-ui!
101-
</title>
102-
</Head>
103-
<main className="app">
104-
<ConfirmationDialogContextWrapper>
105-
<WfoPageTemplate
106-
getAppLogo={
107-
getAppLogo
108-
}
109-
onThemeSwitch={
110-
handleThemeSwitch
88+
<QueryClientProvider
89+
client={queryClient}
90+
contextSharing={true}
91+
>
92+
<TranslationsProvider>
93+
<Head>
94+
<link
95+
rel="icon"
96+
href="/favicon.png"
97+
/>
98+
<title>
99+
Welcome to
100+
example-orchestrator-ui!
101+
</title>
102+
</Head>
103+
<main className="app">
104+
<ConfirmationDialogContextWrapper>
105+
<WfoPageTemplate
106+
getAppLogo={getAppLogo}
107+
onThemeSwitch={
108+
handleThemeSwitch
109+
}
110+
>
111+
<QueryParamProvider
112+
adapter={
113+
NextAdapter
111114
}
115+
options={{
116+
removeDefaultsFromUrl:
117+
false,
118+
enableBatching:
119+
true,
120+
}}
112121
>
113-
<QueryParamProvider
114-
adapter={
115-
NextAdapter
116-
}
117-
options={{
118-
removeDefaultsFromUrl:
119-
false,
120-
enableBatching:
121-
true,
122-
}}
123-
>
124-
<Component
125-
{...pageProps}
126-
/>
127-
</QueryParamProvider>
128-
</WfoPageTemplate>
129-
<WfoToastsList />
130-
</ConfirmationDialogContextWrapper>
131-
<ReactQueryDevtools
132-
initialIsOpen={false}
133-
/>
134-
</main>
135-
</TranslationsProvider>
136-
</QueryClientProvider>
137-
</ApiClientContextProvider>
122+
<Component
123+
{...pageProps}
124+
/>
125+
</QueryParamProvider>
126+
</WfoPageTemplate>
127+
<WfoToastsList />
128+
</ConfirmationDialogContextWrapper>
129+
<ReactQueryDevtools
130+
initialIsOpen={false}
131+
/>
132+
</main>
133+
</TranslationsProvider>
134+
</QueryClientProvider>
138135
</EuiProvider>
139136
</WfoAuth>
140137
</NoSSR>

0 commit comments

Comments
 (0)