public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0) .AddXmlSerializerFormatters(); services.AddMvc(option => option.EnableEndpointRouting = false); services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => { options.TokenValidationParameters = new TokenValidationParameters { ValidateIssuer = true, ValidateAudience = true, ValidateLifetime = true, ValidateIssuerSigningKey = true, ValidIssuer = pconfig.ManagementApiIssuer, ValidAudience = pconfig.ManagementApiAudience, ClockSkew = TimeSpan.FromMinutes(5.0), IssuerSigningKey = new SymmetricSecurityKey(Convert.FromBase64String(pconfig.ManagmentApiSymmetricKey)) }; }); PskStorageAdapter pskAdpater = GetPskAdapter(); if (pskAdpater != null) { services.AddSingleton(pskAdpater); } services.AddPiraeusConfiguration(); services.AddOrleansConfiguration(); services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddSingleton <ILog, Logger>(); services.AddLogging(log => { log.AddConsole(); log.SetMinimumLevel(Enum.Parse <LogLevel>(pconfig.LogLevel)); }); if (!string.IsNullOrEmpty(pconfig.InstrumentationKey)) { services.AddApplicationInsightsTelemetry(pconfig.InstrumentationKey); } services.AddSingletonOrleansClusterClient(WebApiHelpers.GetOrleansConfig()); services.AddRouting(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { config = GetOrleansConfig(); pconfig = GetPiraeusConfig(); //Capl.Authorization.AuthorizationPolicy authzPolicy = GetCaplPolicy(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Latest) .AddXmlSerializerFormatters(); services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => { options.TokenValidationParameters = new TokenValidationParameters { ValidateIssuer = true, ValidateAudience = true, ValidateLifetime = true, ValidateIssuerSigningKey = true, ValidIssuer = pconfig.ManagementApiIssuer, ValidAudience = pconfig.ManagementApiAudience, ClockSkew = TimeSpan.FromMinutes(5.0), IssuerSigningKey = new SymmetricSecurityKey(Convert.FromBase64String(pconfig.ManagmentApiSymmetricKey)) }; }); PskStorageAdapter pskAdpater = GetPskAdapter(); if (pskAdpater != null) { services.AddSingleton <PskStorageAdapter>(pskAdpater); } services.AddSingleton <PiraeusConfig>(pconfig); services.AddSingleton <IClusterClient>(CreateClusterClient); services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddRouting(); //services.AddAuthorization(options => //{ // options.AddPolicy("Access", policy => // policy.Requirements.Add(new ApiAccessRequirement(authzPolicy))); //}); }
public PskController(PskStorageAdapter adapter, Logger logger = null) { this.adapter = adapter; this.logger = logger; }
public PskController(PskStorageAdapter adapter) { this.adapter = adapter; }