-
Notifications
You must be signed in to change notification settings - Fork 540
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Use `IPostConfigureOptions<T>` to configure the URLs for BattleNet. - Add new `Unified` and `Custom` regions. - Update/add XML documentation. - Undo obsolete attributes.
- Loading branch information
1 parent
c0183d7
commit 80cd250
Showing
7 changed files
with
298 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
src/AspNet.Security.OAuth.BattleNet/BattleNetPostConfigureOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) | ||
* See https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers | ||
* for more information concerning the license and the contributors participating to this project. | ||
*/ | ||
|
||
using Microsoft.Extensions.Options; | ||
|
||
namespace AspNet.Security.OAuth.BattleNet; | ||
|
||
/// <summary> | ||
/// A class used to setup defaults for all <see cref="BattleNetAuthenticationOptions"/>. | ||
/// </summary> | ||
public class BattleNetPostConfigureOptions : IPostConfigureOptions<BattleNetAuthenticationOptions> | ||
{ | ||
/// <inheritdoc/> | ||
public void PostConfigure( | ||
string? name, | ||
[NotNull] BattleNetAuthenticationOptions options) | ||
{ | ||
switch (options.Region) | ||
{ | ||
case BattleNetAuthenticationRegion.Unified: | ||
options.AuthorizationEndpoint = BattleNetAuthenticationDefaults.Unified.AuthorizationEndpoint; | ||
options.TokenEndpoint = BattleNetAuthenticationDefaults.Unified.TokenEndpoint; | ||
options.UserInformationEndpoint = BattleNetAuthenticationDefaults.Unified.UserInformationEndpoint; | ||
break; | ||
|
||
case BattleNetAuthenticationRegion.America: | ||
options.AuthorizationEndpoint = BattleNetAuthenticationDefaults.America.AuthorizationEndpoint; | ||
options.TokenEndpoint = BattleNetAuthenticationDefaults.America.TokenEndpoint; | ||
options.UserInformationEndpoint = BattleNetAuthenticationDefaults.America.UserInformationEndpoint; | ||
break; | ||
|
||
case BattleNetAuthenticationRegion.China: | ||
options.AuthorizationEndpoint = BattleNetAuthenticationDefaults.China.AuthorizationEndpoint; | ||
options.TokenEndpoint = BattleNetAuthenticationDefaults.China.TokenEndpoint; | ||
options.UserInformationEndpoint = BattleNetAuthenticationDefaults.China.UserInformationEndpoint; | ||
break; | ||
|
||
case BattleNetAuthenticationRegion.Europe: | ||
options.AuthorizationEndpoint = BattleNetAuthenticationDefaults.Europe.AuthorizationEndpoint; | ||
options.TokenEndpoint = BattleNetAuthenticationDefaults.Europe.TokenEndpoint; | ||
options.UserInformationEndpoint = BattleNetAuthenticationDefaults.Europe.UserInformationEndpoint; | ||
break; | ||
|
||
case BattleNetAuthenticationRegion.Korea: | ||
options.AuthorizationEndpoint = BattleNetAuthenticationDefaults.Korea.AuthorizationEndpoint; | ||
options.TokenEndpoint = BattleNetAuthenticationDefaults.Korea.TokenEndpoint; | ||
options.UserInformationEndpoint = BattleNetAuthenticationDefaults.Korea.UserInformationEndpoint; | ||
break; | ||
|
||
case BattleNetAuthenticationRegion.Taiwan: | ||
options.AuthorizationEndpoint = BattleNetAuthenticationDefaults.Taiwan.AuthorizationEndpoint; | ||
options.TokenEndpoint = BattleNetAuthenticationDefaults.Taiwan.TokenEndpoint; | ||
options.UserInformationEndpoint = BattleNetAuthenticationDefaults.Taiwan.UserInformationEndpoint; | ||
break; | ||
|
||
case BattleNetAuthenticationRegion.Custom: | ||
break; // Do nothing | ||
|
||
default: | ||
throw new NotSupportedException($"The BattleNet region '{options.Region}' is not supported."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.