refactor(ConsumerService): Entfernt ReadLocalAsync Methode.
- LocalConsumer Eigenschaft in AuthApiParams hinzugefügt.
This commit is contained in:
@@ -85,13 +85,13 @@ builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
||||
{
|
||||
options.RequireHttpsMetadata = apiParams!.RequireHttpsMetadata;
|
||||
options.ClaimsIssuer = apiParams!.Issuer;
|
||||
options.Audience = apiParams!.DefaultConsumer.Audience;
|
||||
options.Audience = apiParams.LocalConsumer.Audience;
|
||||
options.TokenValidationParameters = new()
|
||||
{
|
||||
ValidateIssuer = true,
|
||||
ValidIssuer = apiParams!.Issuer,
|
||||
ValidateAudience = true,
|
||||
ValidAudience = apiParams!.DefaultConsumer.Audience,
|
||||
ValidAudience = apiParams.LocalConsumer.Audience,
|
||||
ValidateLifetime = true,
|
||||
IssuerSigningKey = issuerSigningKeyInitiator?.Value
|
||||
};
|
||||
@@ -102,7 +102,7 @@ builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
||||
{
|
||||
// if there is no token read related cookie
|
||||
if (context.Token is null // if there is no token
|
||||
&& context.Request.Cookies.TryGetValue(apiParams!.CookieName, out var token) // get token from cookies
|
||||
&& context.Request.Cookies.TryGetValue(apiParams!.DefaultCookieName, out var token) // get token from cookies
|
||||
&& token is not null)
|
||||
context.Token = token;
|
||||
return Task.CompletedTask;
|
||||
@@ -112,12 +112,10 @@ builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
app.AddDependentExtensions();
|
||||
|
||||
issuerSigningKeyInitiator = new Lazy<SecurityKey>(() =>
|
||||
{
|
||||
var factory = app.Services.GetRequiredService<ICryptoFactory>();
|
||||
var desc = factory.TokenDescriptors.Get(apiParams.Issuer, apiParams.DefaultConsumer.Audience);
|
||||
var desc = factory.TokenDescriptors.Get(apiParams.Issuer, apiParams.LocalConsumer.Audience);
|
||||
return desc.Validator.SecurityKey;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user