Skip to content

Commit 0ac0823

Browse files
foxriver76GermanBluefoxApollon77
authored
added external authentication (#3058)
Co-authored-by: Bluefox <[email protected]> Co-authored-by: Ingo Fischer <[email protected]>
1 parent 620ac86 commit 0ac0823

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The js-controller repository is a monorepo which is managed via `lerna`. Every f
88
To install the dependencies, execute
99

1010
```bash
11-
npm i --ignore-scripts
11+
npm ci --ignore-scripts
1212
```
1313

1414
in the root folder of the project.

packages/types-dev/objects.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,8 @@ declare global {
439439
password: string;
440440
/** Whether this user is enabled */
441441
enabled: boolean;
442+
/** External authentications besides password, e.g. OIDC */
443+
externalAuthentication?: Record<string, unknown>;
442444

443445
// Make it possible to narrow the object type using the custom property
444446
custom?: undefined;

packages/types-public/index.test-d.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,16 @@ function objectChangeHandler(id: string, object: ioBroker.Object | null | undefi
7878
case 'instance':
7979
case 'meta':
8080
case 'script':
81-
case 'user':
8281
// nothing special here, update these tests when we have specialized definitions
8382
break;
84-
83+
case 'user': {
84+
if (object.common.externalAuthentication?.oidc) {
85+
/** It is up to the dev how this looks like hence, oidc is of type unknown */
86+
const oidc = object.common.externalAuthentication.oidc as { sub: string };
87+
oidc.sub === 'foo';
88+
}
89+
break;
90+
}
8591
case 'state':
8692
if (object.acl) {
8793
object.acl.state.toFixed();
@@ -891,6 +897,14 @@ const _userObject: ioBroker.UserObject = {
891897
native: {},
892898
};
893899

900+
/** With external auth */
901+
const _userObjectExt: ioBroker.UserObject = {
902+
_id: 'system.user.me',
903+
type: 'user',
904+
common: { name: 'me', password: '*****', enabled: true, externalAuthentication: { oidc: { sub: 'bar' } } },
905+
native: {},
906+
};
907+
894908
// Ensure that getForeignObject tries to resolve a specific object type
895909
async () => {
896910
const inst: ioBroker.InstanceObject | null | undefined =

0 commit comments

Comments
 (0)