private static void AddJwtAuthetication(this IServiceCollection services, IJwtTokenConfigurationProvider jwtTokenConfigProvider) { services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => { options.TokenValidationParameters = new TokenValidationParameters() { ValidateIssuerSigningKey = false, IssuerSigningKey = jwtTokenConfigProvider.Key, ValidateIssuer = false, ValidIssuer = jwtTokenConfigProvider.Issuer, ValidateAudience = false, ValidAudience = jwtTokenConfigProvider.Audience, ValidateLifetime = false }; }); services.AddAuthorization(options => { options.AddPolicy(Policy.IsPortfolioOwner, policy => policy.Requirements.Add(new PortfolioOwnerRequirement())); options.AddPolicy(Policy.CanMantainStocks, policy => policy.RequireRole(Role.Administrator)); }); }
public AuthenticationController(IUserService userService, IJwtTokenConfigurationProvider jwtTokenConfigurationProvider) { _UserService = userService; _JwtTokenConfigurationProvider = jwtTokenConfigurationProvider; }