public UsersController(IJWTManager jwtManager, IMapper mapper, IUnitOfWork unitOfWork, IUserRepository userRepository)
 {
     this.mapper         = mapper;
     this.jwtManager     = jwtManager;
     this.unitOfWork     = unitOfWork;
     this.userRepository = userRepository;
 }
Exemplo n.º 2
0
        public static void AddAuthenticationSettings(this IServiceCollection services, IJWTConfiguration jwtConfiguration, IJWTManager jwtManager)
        {
            if (!jwtConfiguration.IsEnabled())
            {
                return;
            }

            services.AddAuthentication(opt =>
            {
                opt.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                opt.DefaultScheme             = JwtBearerDefaults.AuthenticationScheme;
                opt.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
            }).AddJwtBearer(opt =>
            {
                //opt.RequireHttpsMetadata = false;
                //opt.Authority = "http://localhost:5000";
                opt.SaveToken = true;
                opt.TokenValidationParameters = jwtManager.GetTokenValidationParameters();
            });
            services.AddAuthorization(auth =>
            {
                auth.AddPolicy(POLICY_NAME, GenerateAuthorizationPolicy());
            });
        }
Exemplo n.º 3
0
 public LoginController(IJWTManager jWTManager)
 {
     _jWTManager = jWTManager;
 }