示例#1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddCors(setup => setup.AddPolicy("EntireWorld", policy => policy.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()));

            services.AddCors(setup => setup.AddPolicy("LocalhostDevelopment", policy => policy.WithOrigins("http://localhost:4200").AllowAnyMethod().AllowAnyHeader()));

            services.AddControllers();

            services.AddSingleton <BranchesLogic>();

            services.AddSingleton <ManufacturersLogic>();

            services.AddSingleton <UsersLogic>();


            JwtHelper jwtHelper = new JwtHelper(Configuration.GetValue <string>("JWT:Key"));

            services.AddSingleton(jwtHelper);

            // Enable JWT Authentication:
            services.AddAuthentication(options => jwtHelper.SetAuthenticationOptions(options)).AddJwtBearer(options => jwtHelper.SetBearerOptions(options));
            services.AddControllers();
        }
示例#2
0
 public AuthController(JwtHelper jwtHelper)
 {
     this.jwtHelper = jwtHelper;
 }