File tree Expand file tree Collapse file tree
Applications/Backend/Source/HttpsRichardy.Federation.Application/Handlers/Connect Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11namespace HttpsRichardy . Federation . Application . Handlers . Connect ;
22
3- public sealed class FetchOpenIDConfigurationHandler ( IHostInformationProvider host ) :
3+ public sealed class FetchOpenIDConfigurationHandler ( IHostInformationProvider host , IRealmCollection realmCollection ) :
44 IDispatchHandler < FetchOpenIDConfigurationParameters , Result < OpenIDConfigurationScheme > >
55{
6- public Task < Result < OpenIDConfigurationScheme > > HandleAsync (
6+ public async Task < Result < OpenIDConfigurationScheme > > HandleAsync (
77 FetchOpenIDConfigurationParameters parameters , CancellationToken cancellation = default )
88 {
9- var configuration = ConnectMapper . AsConfiguration ( host . Address ) ;
9+ var realmFilters = RealmFilters . WithSpecifications ( )
10+ . WithName ( parameters . Realm )
11+ . Build ( ) ;
1012
11- return Task . FromResult ( Result < OpenIDConfigurationScheme > . Success ( configuration ) ) ;
13+ var realms = await realmCollection . GetRealmsAsync ( realmFilters , cancellation ) ;
14+ var realm = realms . FirstOrDefault ( ) ;
15+
16+ if ( realm is null )
17+ {
18+ return Result < OpenIDConfigurationScheme > . Failure ( RealmErrors . RealmDoesNotExist ) ;
19+ }
20+
21+ var configuration = ConnectMapper . AsConfiguration ( host . Address , parameters . Realm ) ;
22+
23+ return Result < OpenIDConfigurationScheme > . Success ( configuration ) ;
1224 }
1325}
You can’t perform that action at this time.
0 commit comments