Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(oidc): update @wireapp/core and provide oidc with keycloak values #16550

Merged
merged 2 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"@peculiar/x509": "1.9.6",
"@wireapp/avs": "9.6.9",
"@wireapp/commons": "5.2.4",
"@wireapp/core": "43.5.6",
"@wireapp/core": "43.6.0",
"@wireapp/react-ui-kit": "9.12.6",
"@wireapp/store-engine-dexie": "2.1.7",
"@wireapp/webapp-events": "0.20.1",
Expand Down
11 changes: 8 additions & 3 deletions src/script/E2EIdentity/E2EIdentityEnrollment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

import {TimeInMillis} from '@wireapp/commons/lib/util/TimeUtil';
import {KeyAuth} from '@wireapp/core/lib/messagingProtocols/mls';
import {amplify} from 'amplify';
import {User} from 'oidc-client-ts';
import {container} from 'tsyringe';
Expand Down Expand Up @@ -232,11 +233,15 @@ export class E2EIHandler extends TypedEventEmitter<Events> {
return supportsMLS() && Config.getConfig().FEATURE.ENABLE_E2EI;
}

private async storeRedirectTargetAndRedirect(targetURL: string): Promise<void> {
private async storeRedirectTargetAndRedirect(
targetURL: string,
keyAuth: KeyAuth,
challengeURL: string,
): Promise<void> {
// store the target url in the persistent oidc service store, since the oidc service will be destroyed after the redirect
OIDCServiceStore.store.targetURL(targetURL);
this.oidcService = this.createOIDCService();
await this.oidcService.authenticate();
await this.oidcService.authenticate(keyAuth, challengeURL);
}

/**
Expand Down Expand Up @@ -294,7 +299,7 @@ export class E2EIHandler extends TypedEventEmitter<Events> {

// Check if the data is a boolean, if not, we need to handle the oauth redirect
if (typeof data !== 'boolean') {
await this.storeRedirectTargetAndRedirect(data.target);
await this.storeRedirectTargetAndRedirect(data.challenge.target, data.keyAuth, data.challenge.url);
}

// Notify user about E2EI enrolment success
Expand Down
15 changes: 13 additions & 2 deletions src/script/E2EIdentity/OIDCService/OIDCService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*
*/

import {KeyAuth} from '@wireapp/core/lib/messagingProtocols/mls';
import {UserManager, User, UserManagerSettings, WebStorageStateStore} from 'oidc-client-ts';

import {clearKeysStartingWith} from 'Util/localStorage';
Expand Down Expand Up @@ -77,8 +78,18 @@ export class OIDCService {
this.logger = getLogger('OIDC Service');
}

public async authenticate(): Promise<void> {
await this.userManager.signinRedirect({extraQueryParams: {shouldBeRedirectedByProxy: true}});
public async authenticate(keyAuth: KeyAuth, challengeUrl: string): Promise<void> {
// New claims value for keycloak
const claims = {
id_token: {
keyauth: {essential: true, value: keyAuth},
acme_aud: {essential: true, value: challengeUrl},
},
};

await this.userManager.signinRedirect({
extraQueryParams: {shouldBeRedirectedByProxy: true, claims: JSON.stringify(claims)},
});
}

public async handleAuthentication(): Promise<User | undefined> {
Expand Down
20 changes: 10 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4867,20 +4867,20 @@ __metadata:
languageName: node
linkType: hard

"@wireapp/core-crypto@npm:1.0.0-rc.29":
version: 1.0.0-rc.29
resolution: "@wireapp/core-crypto@npm:1.0.0-rc.29"
checksum: 6805c9401ef20745d7385549e81cb50ded70369bbf40c8f1b1d6bc376ef0d9360373c8edcafe3c808dcb20086714759f5b05311e81275f56c09a5e368817c6fa
"@wireapp/core-crypto@npm:1.0.0-rc.30":
version: 1.0.0-rc.30
resolution: "@wireapp/core-crypto@npm:1.0.0-rc.30"
checksum: 3787dd855cc091a63d526e73fe289a1ba93742cd159895f70c08e3e2537b8055754fb49881105b2a20e35695cd223c383fbc7af1585262a3acd599aad53d050d
languageName: node
linkType: hard

"@wireapp/core@npm:43.5.6":
version: 43.5.6
resolution: "@wireapp/core@npm:43.5.6"
"@wireapp/core@npm:43.6.0":
version: 43.6.0
resolution: "@wireapp/core@npm:43.6.0"
dependencies:
"@wireapp/api-client": ^26.10.0
"@wireapp/commons": ^5.2.4
"@wireapp/core-crypto": 1.0.0-rc.29
"@wireapp/core-crypto": 1.0.0-rc.30
"@wireapp/cryptobox": 12.8.0
"@wireapp/promise-queue": ^2.2.9
"@wireapp/protocol-messaging": 1.44.0
Expand All @@ -4896,7 +4896,7 @@ __metadata:
long: ^5.2.0
uuidjs: 4.2.13
zod: 3.22.4
checksum: 79d26ebb9e9d47298f5a971de6293804ac12e3f04c0cfc36003a887776060d95fce2a856101902e49da9979686815ffa8889881e5f2f1bc46fab58d089f450f0
checksum: 3e2333344241b46253faed7f86be71e8bffc38fd5dd3cb1f02f08aeef0c170d8e12f3c49ec8b64194cff30b0f74c78ca993d391cfd4ad41b80d0490c485751a4
languageName: node
linkType: hard

Expand Down Expand Up @@ -17568,7 +17568,7 @@ __metadata:
"@wireapp/avs": 9.6.9
"@wireapp/commons": 5.2.4
"@wireapp/copy-config": 2.1.14
"@wireapp/core": 43.5.6
"@wireapp/core": 43.6.0
"@wireapp/eslint-config": 3.0.5
"@wireapp/prettier-config": 0.6.3
"@wireapp/react-ui-kit": 9.12.6
Expand Down
Loading