Refactor security key handling and culture info setup
Updated `IssuerSigningKeyResolver` to use array syntax for returning security keys. Changed supported culture names declaration to use square brackets and modified the creation of the `CultureInfo` list to utilize the spread operator. Adjusted exception handling to throw `InvalidOperationException` when no supported culture is found.
This commit is contained in:
parent
902848958d
commit
9158933333
@ -129,7 +129,7 @@ try
|
|||||||
{
|
{
|
||||||
var clientParams = deferredProvider.GetOptions<ClientParams>();
|
var clientParams = deferredProvider.GetOptions<ClientParams>();
|
||||||
var publicKey = clientParams!.PublicKeys.Get(authTokenKeys.Issuer, authTokenKeys.Audience);
|
var publicKey = clientParams!.PublicKeys.Get(authTokenKeys.Issuer, authTokenKeys.Audience);
|
||||||
return new List<SecurityKey>() { publicKey.SecurityKey };
|
return [publicKey.SecurityKey];
|
||||||
},
|
},
|
||||||
ValidateIssuer = true,
|
ValidateIssuer = true,
|
||||||
ValidIssuer = authTokenKeys.Issuer,
|
ValidIssuer = authTokenKeys.Issuer,
|
||||||
@ -205,10 +205,10 @@ try
|
|||||||
app.UseCors("AllowSpecificOriginsPolicy");
|
app.UseCors("AllowSpecificOriginsPolicy");
|
||||||
|
|
||||||
// Localizer
|
// Localizer
|
||||||
string[] supportedCultureNames = { "de-DE", "en-US" };
|
string[] supportedCultureNames = ["de-DE", "en-US"];
|
||||||
IList<CultureInfo> list = supportedCultureNames.Select((string cn) => new CultureInfo(cn)).ToList();
|
IList<CultureInfo> list = [.. supportedCultureNames.Select(cn => new CultureInfo(cn))];
|
||||||
CultureInfo cultureInfo = list.FirstOrDefault() ?? throw new ArgumentNullException("supportedCultureNames", "Supported cultures cannot be empty.");
|
var cultureInfo = list.FirstOrDefault() ?? throw new InvalidOperationException("There is no supported culture.");
|
||||||
RequestLocalizationOptions requestLocalizationOptions = new RequestLocalizationOptions
|
var requestLocalizationOptions = new RequestLocalizationOptions
|
||||||
{
|
{
|
||||||
SupportedCultures = list,
|
SupportedCultures = list,
|
||||||
SupportedUICultures = list
|
SupportedUICultures = list
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user