Skip to content

Commit

Permalink
Spsh 1393 (#837)
Browse files Browse the repository at this point in the history
* Moved Secrets out of config

* OX-Config now via ENV

* Removed OX-Config from static file

* Moved OX-Config to be read from values

* Kept the one OX-Config that needs to be secret

* Pulled secrets from 1Password into env

* Pulled public config into configmap from values

* Indentation fixed

* Indentation fixed

* Made dependent OX-Configs optional

* Made dependent OX-Configs optional

* Made dependent OX-Configs optional

* Made dependent OX-Configs optional

* Made dependent OX-Configs optional

* Merge errors

* Fixed failing tests

* Made configuration no longer optional

* Linting fix

* Parameter no longer optional

* Merge error

* Add missing values
  • Loading branch information
kristoff-kiefer authored Dec 18, 2024
1 parent 17de936 commit a31236d
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 32 deletions.
17 changes: 0 additions & 17 deletions charts/dbildungs-iam-server/config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@
"PASSWORD": "",
"USE_TLS": false
},
"LDAP": {
"URL": "ldap://spsh-xxx.svc.cluster.local",
"BIND_DN": "cn=admin,dc=schule-sh,dc=de",
"ADMIN_PASSWORD": "password"
},
"DATA": {
"ROOT_ORGANISATION_ID": "d39cb7cf-2f9b-45f1-849f-973661f2f057"
},
Expand All @@ -51,22 +46,10 @@
"BACKEND_FOR_FRONTEND_MODULE_LOG_LEVEL": "debug"
},
"ITSLEARNING": {
"ENABLED": false,
"ENDPOINT": "https://itslearning.example.com",
"USERNAME": "username",
"PASSWORD": "password",
"ROOT": "sh",
"ROOT_OEFFENTLICH": "oeffentlich",
"ROOT_ERSATZ": "ersatz"
},
"OX": {
"ENABLED": false,
"ENDPOINT": "https://ox_ip:ox_port/webservices/OXUserService",
"CONTEXT_ID": "1337",
"CONTEXT_NAME": "contextname",
"USERNAME": "username",
"PASSWORD": "password"
},
"PRIVACYIDEA": {
"ENDPOINT": "http://localhost:5000",
"USERNAME": "admin",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,9 @@
secretKeyRef:
name: {{ default .Values.auth.existingSecret .Values.auth.secretName }}
key: redis-password
- name: OX_PASSWORD
valueFrom:
secretKeyRef:
name: {{ default .Values.auth.existingSecret .Values.auth.secretName }}
key: ox-password
{{- end}}
5 changes: 5 additions & 0 deletions charts/dbildungs-iam-server/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ data:
LDAP_OEFFENTLICHE_SCHULEN_DOMAIN: "{{ .Values.ldap.oeffentlicheSchulenDomain }}"
LDAP_ERSATZSCHULEN_DOMAIN: "{{ .Values.ldap.ersatzschulenDomain }}"
STATUS_REDIRECT_URL: "{{ .Values.status.url }}"
OX_ENABLED: "{{ .Values.ox.enabled }}"
OX_USERNAME: "{{ .Values.ox.username }}"
OX_ENDPOINT: "{{ .Values.ox.endpoint }}"
OX_CONTEXT_ID: "{{ .Values.ox.contextId }}"
OX_CONTEXT_NAME: "{{ .Values.ox.contextName }}"
SYSTEM_RENAME_WAITING_TIME_IN_SECONDS: "{{ .Values.backend.env.renameWaitingTimeInSeconds }}"
SYSTEM_STEP_UP_TIMEOUT_ENABLED: "{{ .Values.backend.env.stepUpTimeoutEnabled }}"
SYSTEM_STEP_UP_TIMEOUT_IN_SECONDS: "{{ .Values.backend.env.stepUpTimeoutInSeconds }}"
Expand Down
1 change: 1 addition & 0 deletions charts/dbildungs-iam-server/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ data:
vidis-keycloak-role: {{ .Values.auth.vidis_keycloak_role }}
import-passphrase-secret: {{ .Values.auth.import_passphrase_secret }}
import-passphrase-salt: {{ .Values.auth.import_passphrase_salt }}
ox-password: {{ .Values.auth.ox_password }}
{{- end }}
8 changes: 8 additions & 0 deletions charts/dbildungs-iam-server/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ auth:
vidis_keycloak_role: ''
import_passphrase_secret: ''
import_passphrase_salt: ''
ox_password: ''

ox:
enabled: false
username: 'oxadmin'
endpoint: 'https://webmail.example.com'
contextId: '10'
contextName: '10'

backend:
replicaCount: 1
Expand Down
10 changes: 4 additions & 6 deletions src/modules/ox/domain/ox-event-handler.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { faker } from '@faker-js/faker';
import { DeepMocked, createMock } from '@golevelup/ts-jest';
import { createMock, DeepMocked } from '@golevelup/ts-jest';
import { Test, TestingModule } from '@nestjs/testing';
import { ConfigTestModule, LoggingTestModule } from '../../../../test/utils/index.js';
import { ClassLogger } from '../../../core/logging/class-logger.js';
Expand Down Expand Up @@ -284,9 +284,7 @@ describe('OxEventHandler', () => {
expect(oxServiceMock.send).toHaveBeenCalledWith(expect.any(CreateUserAction));
expect(oxServiceMock.send).toHaveBeenCalledWith(expect.any(ListGroupsAction));

expect(loggerMock.error).toHaveBeenCalledWith(
`Could Not Retrieve Groups For Context, contextId:undefined`,
);
expect(loggerMock.error).toHaveBeenCalledWith(`Could Not Retrieve Groups For Context, contextId:10`);
expect(eventServiceMock.publish).toHaveBeenCalledTimes(0);
});
});
Expand Down Expand Up @@ -768,8 +766,8 @@ describe('OxEventHandler', () => {
email = faker.internet.email();
oxUserId = faker.string.numeric();
oxUserName = faker.internet.userName();
contextId: faker.string.numeric();
contextName: faker.string.alpha();
contextId = '10';
contextName = 'testContext';
event = new EmailAddressChangedEvent(
personId,
faker.string.uuid(),
Expand Down
1 change: 0 additions & 1 deletion src/modules/ox/domain/ox-event-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ export class OxEventHandler {
configService: ConfigService<ServerConfig>,
) {
const oxConfig: OxConfig = configService.getOrThrow<OxConfig>('OX');

this.ENABLED = oxConfig.ENABLED;
this.authUser = oxConfig.USERNAME;
this.authPassword = oxConfig.PASSWORD;
Expand Down
10 changes: 3 additions & 7 deletions src/modules/ox/domain/ox.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { HttpService } from '@nestjs/axios';
import { Injectable } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { AxiosResponse } from 'axios';
import { Hash, createHash } from 'crypto';
import { createHash, Hash } from 'crypto';
import { XMLBuilder, XMLParser } from 'fast-xml-parser';
import { lastValueFrom } from 'rxjs';

Expand All @@ -25,7 +25,7 @@ export type OxErrorType = {
};

function isOxErrorType(err: unknown): err is OxErrorType {
if (
return !!(
err &&
typeof err === 'object' &&
'response' in err &&
Expand All @@ -34,11 +34,7 @@ function isOxErrorType(err: unknown): err is OxErrorType {
'data' in err.response &&
typeof err.response.data === 'string' &&
err.response.data
) {
return true;
}

return false;
);
}

@Injectable()
Expand Down
2 changes: 2 additions & 0 deletions src/shared/config/config.env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ export default (): Config => ({
ENDPOINT: process.env['OX_ENDPOINT'],
USERNAME: process.env['OX_USERNAME'],
PASSWORD: process.env['OX_PASSWORD'],
CONTEXT_ID: process.env['OX_CONTEXT_ID'],
CONTEXT_NAME: process.env['OX_CONTEXT_NAME'],
},
SYSTEM: {
RENAME_WAITING_TIME_IN_SECONDS: process.env['SYSTEM_RENAME_WAITING_TIME_IN_SECONDS']
Expand Down
4 changes: 3 additions & 1 deletion test/config.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@
"ENABLED": false,
"ENDPOINT": "https://ox_ip:ox_port/webservices/",
"USERNAME": "username",
"PASSWORD": "password"
"PASSWORD": "password",
"CONTEXT_ID": "10",
"CONTEXT_NAME": "testContext"
},
"IMPORT": {
"CSV_FILE_MAX_SIZE_IN_MB": 1,
Expand Down

0 comments on commit a31236d

Please sign in to comment.