mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 19:45:05 +01:00
Fix bug & move oidc clientConfigs to app configs
This commit is contained in:
parent
a375acf875
commit
c23039894f
@ -63,6 +63,7 @@ export class CompleteOIDCLoginViewModel extends ViewModel {
|
||||
|
||||
const oidcApi = new OidcApi({
|
||||
issuer,
|
||||
clientConfigs: this.platform.config.oidc.clientConfigs,
|
||||
clientId,
|
||||
request: this._request,
|
||||
encoding: this._encoding,
|
||||
|
@ -135,6 +135,7 @@ export class Client {
|
||||
try {
|
||||
const oidcApi = new OidcApi({
|
||||
issuer,
|
||||
clientConfigs: this._platform.config.oidc.clientConfigs,
|
||||
request: this._platform.request,
|
||||
encoding: this._platform.encoding,
|
||||
crypto: this._platform.crypto,
|
||||
@ -265,6 +266,7 @@ export class Client {
|
||||
if (sessionInfo.oidcIssuer) {
|
||||
const oidcApi = new OidcApi({
|
||||
issuer: sessionInfo.oidcIssuer,
|
||||
clientConfigs: this._platform.config.oidc.clientConfigs,
|
||||
clientId: sessionInfo.oidcClientId,
|
||||
request: this._platform.request,
|
||||
encoding: this._platform.encoding,
|
||||
@ -487,6 +489,7 @@ export class Client {
|
||||
await hsApi.logout({log}).response();
|
||||
const oidcApi = new OidcApi({
|
||||
issuer: sessionInfo.oidcIssuer,
|
||||
clientConfigs: this._platform.config.oidc.clientConfigs,
|
||||
clientId: sessionInfo.oidcClientId,
|
||||
request: this._platform.request,
|
||||
encoding: this._platform.encoding,
|
||||
|
@ -58,17 +58,12 @@ type IssuerUri = string;
|
||||
interface ClientConfig {
|
||||
client_id: string;
|
||||
client_secret?: string;
|
||||
uris: string[],
|
||||
}
|
||||
|
||||
// These are statically configured OIDC client IDs for particular issuers:
|
||||
const clientIds: Record<IssuerUri, ClientConfig> = {
|
||||
"https://id.thirdroom.io/realms/thirdroom/": {
|
||||
client_id: "thirdroom"
|
||||
},
|
||||
};
|
||||
|
||||
export class OidcApi<N extends object = SegmentType> {
|
||||
_issuer: string;
|
||||
_clientConfigs: Record<IssuerUri, ClientConfig>;
|
||||
_requestFn: RequestFunction;
|
||||
_encoding: any;
|
||||
_crypto: any;
|
||||
@ -76,8 +71,9 @@ export class OidcApi<N extends object = SegmentType> {
|
||||
_metadataPromise: Promise<any>;
|
||||
_registrationPromise: Promise<any>;
|
||||
|
||||
constructor({ issuer, request, encoding, crypto, urlCreator, clientId }) {
|
||||
constructor({ issuer, request, encoding, crypto, urlCreator, clientId, clientConfigs }) {
|
||||
this._issuer = issuer;
|
||||
this._clientConfigs = clientConfigs;
|
||||
this._requestFn = request;
|
||||
this._encoding = encoding;
|
||||
this._crypto = crypto;
|
||||
@ -121,8 +117,8 @@ export class OidcApi<N extends object = SegmentType> {
|
||||
// use static client if available
|
||||
const authority = `${this.issuer}${this.issuer.endsWith('/') ? '' : '/'}`;
|
||||
|
||||
if (clientIds[authority]) {
|
||||
return clientIds[authority];
|
||||
if (this._clientConfigs[authority] && this._clientConfigs[authority].uris.includes(this._urlCreator.absoluteAppUrl())) {
|
||||
return this._clientConfigs[authority];
|
||||
}
|
||||
|
||||
const headers = new Map();
|
||||
|
@ -5,5 +5,13 @@
|
||||
"applicationServerKey": "BC-gpSdVHEXhvHSHS0AzzWrQoukv2BE7KzpoPO_FfPacqOo3l1pdqz7rSgmB04pZCWaHPz7XRe6fjLaC-WPDopM"
|
||||
},
|
||||
"defaultHomeServer": "matrix.org",
|
||||
"bugReportEndpointUrl": "https://element.io/bugreports/submit"
|
||||
"bugReportEndpointUrl": "https://element.io/bugreports/submit",
|
||||
"oidc": {
|
||||
"clientConfigs": {
|
||||
"https://id.thirdroom.io/realms/thirdroom/": {
|
||||
"client_id": "thirdroom",
|
||||
"uris": ["http:localhost:3000", "https://thirdroom.io"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user