Skip to content

Commit

Permalink
fix(sso): update default client and tenant id
Browse files Browse the repository at this point in the history
- use `common` as tenant id to succeed tests on jenkins
- update instructions to replace client id and tenant id in the associated files
  • Loading branch information
SimonGolms committed Sep 1, 2022
1 parent 25bce14 commit 074bde4
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 55 deletions.
4 changes: 2 additions & 2 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
VITE_API_URL="http://localhost:3000/api"

# Azure - SSO
VITE_AZURE_ACTIVE_DIRECTORY_CLIENT_ID=""
VITE_AZURE_ACTIVE_DIRECTORY_TENANT_ID=""
VITE_AZURE_ACTIVE_DIRECTORY_CLIENT_ID="11111111-2222-3333-4444-555555555dev"
VITE_AZURE_ACTIVE_DIRECTORY_TENANT_ID="common"

# Optional for (local) development:

Expand Down
4 changes: 2 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,9 @@ def stageTest(def context) {
container('playwright') {
stage('Test Components') {
withEnv([
'VITE_AZURE_ACTIVE_DIRECTORY_CLIENT_ID=11111111-2222-3333-4444-555555555555',
'VITE_AZURE_ACTIVE_DIRECTORY_CLIENT_ID=11111111-2222-3333-4444-555555555dev',
// IMPORTANT: A valid Azure AD Tenant ID for testing purposes is required.
'VITE_AZURE_ACTIVE_DIRECTORY_TENANT_ID=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee',
'VITE_AZURE_ACTIVE_DIRECTORY_TENANT_ID=common',
]) {
sh(
label: 'Test React Components',
Expand Down
65 changes: 20 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -404,62 +404,31 @@ N/A

Update the following entries with the `Application (client) ID` and `Directory (tenant) ID` from the corresponding app registry environment

1. [`.env`](./.env)

```diff
# Azure - SSO
- REACT_APP_AZURE_ACTIVE_DIRECTORY_CLIENT_ID=""
+ REACT_APP_AZURE_ACTIVE_DIRECTORY_CLIENT_ID="123...789"
- REACT_APP_AZURE_ACTIVE_DIRECTORY_TENANT_ID=""
+ REACT_APP_AZURE_ACTIVE_DIRECTORY_TENANT_ID="123...789"
```

2. [`./chart/values.dev.yaml`](./chart/values.dev.yaml)

_Please make sure that you use the correct client id and tenant id from your app registration for the `dev` environment._
1. Replace `YOUR_CLIENT_ID_DEV` with the `Application (client) ID` from your app registration for the `dev` environment

```diff
- azureActiveDirectoryClientId: "11111111-2222-3333-4444-555555555555"
+ azureActiveDirectoryClientId: "123...-dev-...789"
- azureActiveDirectoryTenantId: "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
+ azureActiveDirectoryTenantId: "abc...-dev-...xyz"
```sh
find \( -wholename "./.env" -or -wholename "./chart/values.dev.yaml" -or -wholename "./Jenkinsfile" \) -exec sed --expression 's/11111111-2222-3333-4444-555555555dev/YOUR_CLIENT_ID_DEV/g' --in-place {} +
```

3. [`./chart/values.test.yaml`](./chart/values.test.yaml)
2. Replace `YOUR_CLIENT_ID_TEST` with the `Application (client) ID` from your app registration for the `test` environment

_Please make sure that you use the correct client id and tenant id from your app registration for the `test` environment._

```diff
- azureActiveDirectoryClientId: "11111111-2222-3333-4444-555555555555"
+ azureActiveDirectoryClientId: "123...-test-...789"
- azureActiveDirectoryTenantId: "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
+ azureActiveDirectoryTenantId: "abc...-test-...xyz"
```sh
find -wholename "./chart/values.test.yaml" -exec sed --expression 's/11111111-2222-3333-4444-55555555test/YOUR_CLIENT_ID_TEST/g' --in-place {} +
```

4. [`./chart/values.prod.yaml`](./chart/values.prod.yaml)

_Please make sure that you use the correct client id and tenant id from your app registration for the `prod` environment._
3. Replace `YOUR_CLIENT_ID_PROD` with the `Application (client) ID` from your app registration for the `prod` environment

```diff
- azureActiveDirectoryClientId: "11111111-2222-3333-4444-555555555555"
+ azureActiveDirectoryClientId: "123...-prod-...789"
- azureActiveDirectoryTenantId: "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
+ azureActiveDirectoryTenantId: "abc...-prod-...xyz"
```sh
find -wholename "./chart/values.prod.yaml" -exec sed --expression 's/11111111-2222-3333-4444-55555555prod/YOUR_CLIENT_ID_PROD/g' --in-place {} +
```

5. [`./Jenkinsfile`](./Jenkinsfile)
4. Replace `YOUR_TENANT_ID` with the `Directory (tenant) ID` from your app registration, which is basically the same for per environment (`dev`/`test`/`prod`)

_Please make sure that you use the correct client id and tenant id from your app registration for the `dev` environment._

```diff
- 'VITE_AZURE_ACTIVE_DIRECTORY_CLIENT_ID=11111111-2222-3333-4444-555555555555',
+ 'VITE_AZURE_ACTIVE_DIRECTORY_CLIENT_ID=123...-dev-...789',
...
- 'VITE_AZURE_ACTIVE_DIRECTORY_TENANT_ID=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee',
+ 'VITE_AZURE_ACTIVE_DIRECTORY_TENANT_ID=abc...-dev-...xyz',
```sh
find \( -wholename "./.env" -or -wholename "./chart/values.*.yaml" -or -wholename "./Jenkinsfile" \) -exec sed --expression 's/common/YOUR_TENANT_ID/g' --in-place {} +
```

More information: <https://docs.microsoft.com/en-us/azure/active-directory/develop/scenario-spa-app-registration>
More information: <https://docs.microsoft.com/en-us/azure/active-directory/develop/scenario-spa-app-registration>

## Local Development

Expand All @@ -479,7 +448,13 @@ nvm install --lts --latest-npm

### Set Environment Variables

See `.env.template` to create appropriate `.env` file. Ask your colleagues which values are currently necessary!
Create appropriate `.env` file from `.env.template`.

```sh
cp .env.template .env
```

Ask your colleagues which values are currently necessary!

### Install Dependencies

Expand Down
4 changes: 2 additions & 2 deletions chart/values.dev.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
azureActiveDirectoryClientId: '11111111-2222-3333-4444-555555555555'
azureActiveDirectoryTenantId: 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
azureActiveDirectoryClientId: '11111111-2222-3333-4444-555555555dev'
azureActiveDirectoryTenantId: 'common'

# apiUrl is the backend api url
apiUrl: 'http://localhost:3000/api'
4 changes: 2 additions & 2 deletions chart/values.prod.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
azureActiveDirectoryClientId: '11111111-2222-3333-4444-555555555555'
azureActiveDirectoryTenantId: 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
azureActiveDirectoryClientId: '11111111-2222-3333-4444-55555555prod'
azureActiveDirectoryTenantId: 'common'

# apiUrl is the backend api url
apiUrl: 'http://localhost:3000/api'
4 changes: 2 additions & 2 deletions chart/values.test.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
azureActiveDirectoryClientId: '11111111-2222-3333-4444-555555555555'
azureActiveDirectoryTenantId: 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
azureActiveDirectoryClientId: '11111111-2222-3333-4444-55555555test'
azureActiveDirectoryTenantId: 'common'

# apiUrl is the backend api url
apiUrl: 'http://localhost:3000/api'

0 comments on commit 074bde4

Please sign in to comment.