|
|
|
@ -5,6 +5,7 @@ using Infrastructure.Security;
|
|
|
|
|
using Microsoft.AspNetCore.Authentication;
|
|
|
|
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
|
|
|
|
using Microsoft.IdentityModel.Tokens;
|
|
|
|
|
|
|
|
|
|
namespace Infrastructure.Extensions;
|
|
|
|
@ -31,12 +32,12 @@ public static class AuthenticationSetup
|
|
|
|
|
return services;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
services.AddSingleton<JwtSecurityTokenHandler>();
|
|
|
|
|
services.AddScoped<IUserContext, UserContext>();
|
|
|
|
|
services.AddSingleton<DefaultTokenHandler>();
|
|
|
|
|
services.AddSingleton<IEncryptionService, EncryptionService>();
|
|
|
|
|
services.AddSingleton<IPostConfigureOptions<JwtBearerOptions>, JwtBearerOptionsPostConfigureOptions>();
|
|
|
|
|
services.AddSingleton<ITokenBuilder, TokenBuilder>();
|
|
|
|
|
services.TryAddSingleton<JwtSecurityTokenHandler>();
|
|
|
|
|
services.TryAddScoped<IUserContext, UserContext>();
|
|
|
|
|
services.TryAddSingleton<DefaultTokenHandler>();
|
|
|
|
|
services.TryAddSingleton<IEncryptionService, EncryptionService>();
|
|
|
|
|
services.TryAddSingleton<IPostConfigureOptions<JwtBearerOptions>, JwtBearerOptionsPostConfigureOptions>();
|
|
|
|
|
services.TryAddSingleton<ITokenBuilder, TokenBuilder>();
|
|
|
|
|
|
|
|
|
|
var key = configuration["AUDIENCE_KEY"] ?? audienceOptions.Secret;
|
|
|
|
|
ArgumentException.ThrowIfNullOrEmpty(key);
|
|
|
|
|