Skip to content

Commit

Permalink
fix: return .well-known after checking OIDC capabilities
Browse files Browse the repository at this point in the history
Signed-off-by: The one with the braid <[email protected]>
  • Loading branch information
TheOneWithTheBraid committed Feb 11, 2025
1 parent db463cd commit 590f349
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions lib/src/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -616,27 +616,25 @@ class Client extends MatrixApi {
/// The result of this call is stored in [wellKnown] for later use at runtime.
@override
Future<DiscoveryInformation> getWellknown() async {
DiscoveryInformation wellKnown;
try {
final wellKnown = await super.getWellknown();
wellKnown = await super.getWellknown();

// do not reset the well known here, so super call
super.homeserver = wellKnown.mHomeserver.baseUrl.stripTrailingSlash();
_wellKnown = wellKnown;
await database?.storeWellKnown(wellKnown);

return wellKnown;
} finally {
// MSC2965 no longer expects any information on whether OIDC is supported
// to be present in .well-known - the only way to figure out is sadly
// calling the /auth_metadata endpoint.
try {
try {
_oidcAuthMetadata = await getOidcAuthMetadata();
} catch (e) {
} on http.ClientException {
Logs().v(
'[OIDC] auth_metadata endpoint not supported. '
'Fallback on legacy .well-known discovery.',
e,
);
// even though no longer required, a homeserver *might* still prefer
// the fallback on .well-known discovery as per
Expand All @@ -649,10 +647,11 @@ class Client extends MatrixApi {
}
await database?.storeOidcAuthMetadata(_oidcAuthMetadata);
Logs().v('[OIDC] Found auth metadata document.');
} catch (e) {
Logs().v('[OIDC] Homeserver does not support OIDC delegation.', e);
} on http.ClientException {
Logs().v('[OIDC] Homeserver does not support OIDC delegation.');
}
}
return wellKnown;
}

/// Checks to see if a username is available, and valid, for the server.
Expand Down

0 comments on commit 590f349

Please sign in to comment.