Closed JoschiZ closed 7 months ago
Each instance would need a different CallbackPath so they don't get mixed up.
It's worth noting that there's now a unified oauth.battle.net server that covers all regions except China. We may want to update the aspnet-contrib provider to use oauth.battle.net by default and fall back to oauth.battlenet.com.cn for China.
Note: the OpenIddict Battle.net integration already uses the unified server + their OIDC-capable login flow, if you're interested in giving it a try (more info here if you're not familiar with the OpenIddict web providers: https://kevinchalet.com/2022/12/16/getting-started-with-the-openiddict-web-providers/).
Now that you mention it I remember that that they wanted to do some kind of unified server. But thanks @Tratcher for the info, I knew there was something I missed / didn't understand correctly. That problem would have been too common, even though that provider is probably not that common.
I will certainly take a look at OpenIddict, it looks really interesting.
Thanks for the quick answer!
Proposed change to use the global server as part of our v8.0.0 release is here: #813
Support for the unified server will be part of our imminent 8.0 release.
Describe the bug
The BattleNet Provider has 5 regions and in general if you plan on supporting one you probably want to support all of them. This is currently impossible, because registering the same provider twice, with different
authenticationScheme
anddisplayName
, results in the following error, if you try to login with a region that was not the first registered one.I guess it is because
Calls
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<TOptions>, OAuthPostConfigureOptions<TOptions, THandler>>());
with the same types multiple timesTOptions == BattleNetAuthenticationOptions
andTHandler == BattleNetAuthenticationHandler
. This results in only the first instance being correctly registered and working.Steps To reproduce
to this
Try to login with BattleNetEurope.
Expected behaviour
You should be able to register all regions independently of each other.
Actual behaviour
If you try to register multiple providers with different regions it crashes.
System information
.NET SDK: Version: 7.0.403 Commit: 142776d834
Runtime Environment: OS Name: Windows OS Version: 10.0.19044 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\7.0.403\
Host: Version: 8.0.0-rc.2.23479.6 Architecture: x64 Commit: 0b25e38ad3
Additional context
I tried creating a proxy type, that just inherits from
BattleNetAuthenticationHandler
But this doesn't work, because
BattleNetAuthenticationOptions
is still the same and leads to the same error. Creating a proxy of both doesn't work, becauseBattleNetAuthenticationHandler
inheritsOAuthHandler<BattleNetAuthenticationOptions>
andAddOAuth
requires one to be convertible to the other.