コード例 #1
0
 public LoginController(IConfiguration config, PhotoboxDB database)
 {
     _config    = config;
     _database  = database;
     _pwHelper  = new PasswordHelper();
     _jwtHelper = new JWTHelper(config);
 }
コード例 #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var        settings   = Configuration.GetSection("DatabaseSettings").Get <DatabaseSettings> ();
            PhotoboxDB photoboxDB = new PhotoboxDB(settings);

            services.AddSingleton(photoboxDB);
            services.AddControllers();
            services.AddCors();
            services.AddControllers().AddNewtonsoftJson();

            services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
            .AddJwtBearer(options => {
                options.TokenValidationParameters = new TokenValidationParameters {
                    ValidateIssuer           = true,
                    ValidateAudience         = true,
                    ValidateLifetime         = true,
                    ValidateIssuerSigningKey = true,
                    ValidIssuer      = Configuration["Jwt:Issuer"],
                    ValidAudience    = Configuration["Jwt:Issuer"],
                    IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["Jwt:Key"]))
                };
            });
        }
コード例 #3
0
 public ImageController(PhotoboxDB DB)
 {
     this.DB = DB;
 }
コード例 #4
0
 public PhotographerController(IConfiguration config, PhotoboxDB database)
 {
     _config   = config;
     _database = database;
     _pwHelper = new PasswordHelper();
 }
コード例 #5
0
 public BrokerController(IConfiguration config, PhotoboxDB database)
 {
     _config    = config;
     _database  = database;
     _jwtHelper = new JWTHelper(config);
 }