Added authentication and authorization, updated dependency injections, removed hard-coded connection string
This commit is contained in:
		| @@ -0,0 +1,24 @@ | ||||
| using System.IdentityModel.Tokens.Jwt; | ||||
| using ApplicationLayer.AuthServices.NeededServices; | ||||
| using ApplicationLayer.GeneralNeededServices; | ||||
| using Microsoft.Extensions.DependencyInjection; | ||||
|  | ||||
| namespace Infrastructure.Auth | ||||
| { | ||||
|     public static class ServiceCollectionsExtensions | ||||
|     { | ||||
|         public static IServiceCollection AddTokenGenerator(this IServiceCollection services, TokenGeneratorOptions options) | ||||
|         { | ||||
|             services.AddSingleton<JwtSecurityTokenHandler>(); | ||||
|             services.AddSingleton<ITokenGenerator, TokenGenerator>(provider => | ||||
|             { | ||||
|                 var tokenHandler = provider.GetRequiredService<JwtSecurityTokenHandler>(); | ||||
|                 var dateTimeProvider = provider.GetRequiredService<IDateTimeProvider>(); | ||||
|  | ||||
|                 return new TokenGenerator(options, tokenHandler, dateTimeProvider); | ||||
|             }); | ||||
|  | ||||
|             return services; | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user