Skip to content

Commit

Permalink
Make hydrogen generate the device scope
Browse files Browse the repository at this point in the history
  • Loading branch information
sandhose committed Jul 4, 2022
1 parent 897fc54 commit 12d1760
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/domain/login/StartOIDCLoginViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ export class StartOIDCLoginViewModel extends ViewModel {
async discover() {
// Ask for the metadata once so it gets discovered and cached
await this._api.metadata()
await this._api.ensureRegistered();
await this._api.registration();
}

async startOIDCLogin() {
const deviceScope = this._api.generateDeviceScope();
const p = this._api.generateParams({
scope: "openid",
scope: `openid ${deviceScope}`,
redirectUri: this.urlCreator.createOIDCRedirectURL(),
});
const clientId = await this._api.clientId();
Expand Down
5 changes: 5 additions & 0 deletions src/matrix/net/OidcApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ export class OidcApi {
return metadata["registration_endpoint"];
}

generateDeviceScope(): String {
const deviceId = randomString(10);
return `urn:matrix:device:${deviceId}`;
}

generateParams({ scope, redirectUri }: { scope: string, redirectUri: string }): AuthorizationParams {
return {
scope,
Expand Down

0 comments on commit 12d1760

Please sign in to comment.