Skip to content

Commit f6f90f6

Browse files
1108 retrieve env vars (#39)
* 1108 Using getEnvironmentVariables to retrieve environment variables * Updates versions in package-lock.json and adds update commands to the README.md file * 1108 Updates environment variables in nextauth middleware * 1108 Adds breaking-changes.md file * 1108 Adds breaking-changes.md file * 1108 Adds commit hash * 1108 Update breaking-changes.md Co-authored-by: Ruben van Leeuwen <ruben@sinin.nl> * 1108 Renames README.md to update-instructions.md * 1108 Updates .env.example * 1108 Updates .env.example --------- Co-authored-by: Ruben van Leeuwen <ruben@sinin.nl>
1 parent 49262ad commit f6f90f6

File tree

6 files changed

+117
-72
lines changed

6 files changed

+117
-72
lines changed

.env.example

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
11
ENVIRONMENT_NAME=Development
2-
PROCESS_DETAIL_REFETCH_INTERVAL=3000
3-
42
ORCHESTRATOR_API_HOST=http://localhost:8080
53
ORCHESTRATOR_API_PATH=/api
64
ORCHESTRATOR_GRAPHQL_HOST=http://localhost:8080
75
ORCHESTRATOR_GRAPHQL_PATH=/api/graphql
86
ORCHESTRATOR_WEBSOCKET_URL=ws://localhost:8080
7+
USE_WEB_SOCKETS=false
8+
USE_THEME_TOGGLE=false
9+
SHOW_WORKFLOW_INFORMATION_LINK=true
10+
WORKFLOW_INFORMATION_LINK_URL="https://workfloworchestrator.org/"
911

10-
AUTH_ACTIVE=true
11-
NEXTAUTH_ID="keycloak"
12-
NEXTAUTH_CLIENT_ID="orchestrator-client"
13-
NEXTAUTH_CLIENT_SECRET="KEYCLOAK_SECRET"
14-
NEXTAUTH_SECRET="NEXTAUTH_SECRET"
15-
NEXTAUTH_ISSUER="http://localhost:8085/realms/orchestrator"
16-
NEXTAUTH_WELL_KNOWN_OVERRIDE="http://localhost:8085/auth/.well-known/openid-configuration"
12+
# Auth variables
13+
OAUTH2_ACTIVE=true
14+
NEXTAUTH_PROVIDER_ID="keycloak"
15+
NEXTAUTH_PROVIDER_NAME="Keycloak"
1716
NEXTAUTH_AUTHORIZATION_SCOPE_OVERRIDE="openid profile"
18-
NEXTAUTH_URL=http://localhost:3000/api/auth
17+
OAUTH2_CLIENT_ID="orchestrator-client"
18+
OAUTH2_CLIENT_SECRET="KEYCLOAK_SECRET"
19+
OIDC_CONF_FULL_WELL_KNOWN_URL="https://localhost:8085/api/v1/auth/.well-known/openid-configuration"
1920

20-
# docker-compose variables
21+
# Required by the Nextauth middleware
22+
NEXTAUTH_URL=http://localhost:3001/api/auth
23+
NEXTAUTH_SECRET="NEXTAUTH_SECRET"
24+
25+
# Auth variables for local development environment (Keycloak in Docker)
2126
KEYCLOAK_ADMIN=admin
2227
KEYCLOAK_ADMIN_PASSWORD=admin
2328
KEYCLOAK_PORT=8085
2429

25-
USE_WEBSOCKET=false
26-
USE_THEME_TOGGLE=false
2730

28-
SHOW_WORKFLOW_INFORMATION_LINK=false
29-
WORKFLOW_INFORMATION_LINK_URL=http://localhost:8080

breaking-changes.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Breaking Changes
2+
3+
## Commit: edec88ccce4ac168d7e23c29477ee42748d20778 (Tue Jun 4 16:09:42 2024 +0200)
4+
5+
Renaming environment variables:
6+
7+
| Old | New |
8+
| ---------------------------- | ----------------------------- |
9+
| AUTH_ACTIVE | OAUTH2_ACTIVE |
10+
| NEXTAUTH_CLIENT_ID | OAUTH2_CLIENT_ID |
11+
| NEXTAUTH_CLIENT_SECRET | OAUTH2_CLIENT_SECRET |
12+
| NEXTAUTH_ID | NEXTAUTH_PROVIDER_ID |
13+
| NEXTAUTH_ID | NEXTAUTH_PROVIDER_NAME |
14+
| NEXTAUTH_ISSUER | OIDC_CONF_FULL_WELL_KNOWN_URL |
15+
| NEXTAUTH_WELL_KNOWN_OVERRIDE | OIDC_CONF_FULL_WELL_KNOWN_URL |
16+
17+
Note: `NEXTAUTH_ID` is split up in 2 new environment variables. The `NEXTAUTH_ISSUER` and `NEXTAUTH_WELL_KNOWN_OVERRIDE` are replaced by one new environment variable.

configuration/configuration.ts

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,49 @@
1-
import process from 'process';
2-
31
import {
42
Environment,
53
OrchestratorConfig,
4+
getEnvironmentVariables,
65
} from '@orchestrator-ui/orchestrator-ui-components';
76

8-
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';
12-
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';
17-
export const SUBSCRIPTION_PROCESSES_ENDPOINT =
18-
'/processes/process-subscriptions-by-subscription-id';
19-
export const DEFAULT_WORKFLOW_INFORMATION_LINK_URL = 'http://localhost:8080';
20-
217
export const getInitialOrchestratorConfig = (): OrchestratorConfig => {
22-
const orchestratorGraphqlBaseUrl =
23-
process.env.ORCHESTRATOR_GRAPHQL_HOST &&
24-
process.env.ORCHESTRATOR_GRAPHQL_PATH
25-
? `${process.env.ORCHESTRATOR_GRAPHQL_HOST}${process.env.ORCHESTRATOR_GRAPHQL_PATH}`
26-
: DEFAULT_GRAPHQL_CORE_ENDPOINT;
8+
const {
9+
USE_THEME_TOGGLE,
10+
ENVIRONMENT_NAME,
11+
ORCHESTRATOR_API_HOST,
12+
ORCHESTRATOR_API_PATH,
13+
ORCHESTRATOR_GRAPHQL_HOST,
14+
ORCHESTRATOR_GRAPHQL_PATH,
15+
ORCHESTRATOR_WEBSOCKET_URL,
16+
USE_WEB_SOCKETS,
17+
WORKFLOW_INFORMATION_LINK_URL,
18+
SHOW_WORKFLOW_INFORMATION_LINK,
19+
OAUTH2_ACTIVE,
20+
} = getEnvironmentVariables([
21+
'USE_THEME_TOGGLE',
22+
'ENVIRONMENT_NAME',
23+
'ORCHESTRATOR_API_HOST',
24+
'ORCHESTRATOR_API_PATH',
25+
'ORCHESTRATOR_GRAPHQL_HOST',
26+
'ORCHESTRATOR_GRAPHQL_PATH',
27+
'ORCHESTRATOR_WEBSOCKET_URL',
28+
'USE_WEB_SOCKETS',
29+
'WORKFLOW_INFORMATION_LINK_URL',
30+
'SHOW_WORKFLOW_INFORMATION_LINK',
31+
'OAUTH2_ACTIVE',
32+
]);
2733

28-
const orchestratorApiBaseUrl =
29-
process.env.ORCHESTRATOR_API_HOST && process.env.ORCHESTRATOR_API_PATH
30-
? `${process.env.ORCHESTRATOR_API_HOST}${process.env.ORCHESTRATOR_API_PATH}`
31-
: DEFAULT_ORCHESTRATOR_API_BASE_URL;
34+
const graphqlEndpointCore = `${ORCHESTRATOR_GRAPHQL_HOST}${ORCHESTRATOR_GRAPHQL_PATH}`;
35+
const orchestratorApiBaseUrl = `${ORCHESTRATOR_API_HOST}${ORCHESTRATOR_API_PATH}`;
3236

3337
return {
3438
orchestratorApiBaseUrl,
35-
graphqlEndpointCore: orchestratorGraphqlBaseUrl,
36-
environmentName:
37-
process.env.ENVIRONMENT_NAME ?? Environment.DEVELOPMENT,
38-
orchestratorWebsocketUrl:
39-
process.env.ORCHESTRATOR_WEBSOCKET_URL ||
40-
DEFAULT_ORCHESTRATOR_WEBSOCKET_URL,
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',
44-
workflowInformationLinkUrl:
45-
process.env.WORKFLOW_INFORMATION_LINK_URL ??
46-
DEFAULT_WORKFLOW_INFORMATION_LINK_URL,
39+
graphqlEndpointCore,
40+
environmentName: ENVIRONMENT_NAME ?? Environment.DEVELOPMENT,
41+
orchestratorWebsocketUrl: ORCHESTRATOR_WEBSOCKET_URL,
42+
authActive: OAUTH2_ACTIVE?.toLowerCase() != 'false',
43+
useWebSockets: USE_WEB_SOCKETS?.toLowerCase() === 'true',
44+
useThemeToggle: USE_THEME_TOGGLE?.toLowerCase() === 'true',
45+
workflowInformationLinkUrl: WORKFLOW_INFORMATION_LINK_URL,
4746
showWorkflowInformationLink:
48-
process.env.SHOW_WORKFLOW_INFORMATION_LINK?.toLowerCase() ===
49-
'true',
47+
SHOW_WORKFLOW_INFORMATION_LINK?.toLowerCase() === 'true',
5048
};
5149
};

package-lock.json

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

pages/api/auth/[...nextauth].ts

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,43 @@ import { OAuthConfig } from 'next-auth/providers';
55
import {
66
WfoSession,
77
WfoUserProfile,
8+
getEnvironmentVariables,
89
} from '@orchestrator-ui/orchestrator-ui-components';
910

10-
const token_endpoint_auth_method = process.env.NEXTAUTH_CLIENT_SECRET
11+
const {
12+
OAUTH2_ACTIVE,
13+
OAUTH2_CLIENT_ID,
14+
OAUTH2_CLIENT_SECRET,
15+
NEXTAUTH_PROVIDER_ID,
16+
NEXTAUTH_PROVIDER_NAME,
17+
NEXTAUTH_AUTHORIZATION_SCOPE_OVERRIDE,
18+
OIDC_CONF_FULL_WELL_KNOWN_URL,
19+
} = getEnvironmentVariables([
20+
'OAUTH2_ACTIVE',
21+
'OAUTH2_CLIENT_ID',
22+
'OAUTH2_CLIENT_SECRET',
23+
'NEXTAUTH_PROVIDER_ID',
24+
'NEXTAUTH_PROVIDER_NAME',
25+
'NEXTAUTH_AUTHORIZATION_SCOPE_OVERRIDE',
26+
'OIDC_CONF_FULL_WELL_KNOWN_URL',
27+
]);
28+
29+
const isOauth2Enabled = OAUTH2_ACTIVE?.toLowerCase() != 'false';
30+
31+
const token_endpoint_auth_method = OAUTH2_CLIENT_SECRET
1132
? 'client_secret_basic'
1233
: 'none';
1334

14-
const authActive = process.env.AUTH_ACTIVE?.toLowerCase() != 'false';
1535
const wfoProvider: OAuthConfig<WfoUserProfile> = {
16-
id: process.env.NEXTAUTH_ID || '',
17-
name: process.env.NEXTAUTH_ID || '',
36+
id: NEXTAUTH_PROVIDER_ID,
37+
name: NEXTAUTH_PROVIDER_NAME,
1838
type: 'oauth',
19-
clientId: process.env.NEXTAUTH_CLIENT_ID || '',
20-
clientSecret: process.env.NEXTAUTH_CLIENT_SECRET || undefined,
21-
wellKnown:
22-
process.env.NEXTAUTH_WELL_KNOWN_OVERRIDE ??
23-
`${process.env.NEXTAUTH_ISSUER || ''}/.well-known/openid-configuration`,
39+
clientId: OAUTH2_CLIENT_ID,
40+
clientSecret: OAUTH2_CLIENT_SECRET || undefined,
41+
wellKnown: OIDC_CONF_FULL_WELL_KNOWN_URL,
2442
authorization: {
2543
params: {
26-
scope:
27-
process.env.NEXTAUTH_AUTHORIZATION_SCOPE_OVERRIDE ??
28-
'openid profile',
44+
scope: NEXTAUTH_AUTHORIZATION_SCOPE_OVERRIDE ?? 'openid profile',
2945
},
3046
},
3147
idToken: true,
@@ -55,7 +71,7 @@ const wfoProvider: OAuthConfig<WfoUserProfile> = {
5571
};
5672

5773
export const authOptions: AuthOptions = {
58-
providers: authActive ? [wfoProvider] : [],
74+
providers: isOauth2Enabled ? [wfoProvider] : [],
5975
callbacks: {
6076
async jwt({ token, account, profile }) {
6177
// The "account" is only available right after signing in -- adding useful data to the token

update-instructions.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## Updating library version in package-lock.json.
2+
3+
Since the version of dependency `@orchestrator-ui/orchestrator-ui-components` is `*` for proper usage in our Turborepo, we still need to update package-lock.json to make the build command build the app with the latest library version.
4+
When a new version of any of the `@orchestrator-ui/...` packages is available, the current repository needs to be manually updated.
5+
6+
Note: the command below can only be executed when the app is not part of the monorepo setup.
7+
8+
```bash
9+
npm update @orchestrator-ui/orchestrator-ui-components
10+
npm update @orchestrator-ui/eslint-config-custom
11+
npm update @orchestrator-ui/jest-config
12+
npm update @orchestrator-ui/tsconfig
13+
```

0 commit comments

Comments
 (0)