public void Save(SettingsEntity settings) { ValidateSettings(settings); operations = new SettingsOperations(); operations.Save(settings); }
public SettingsEntity Get() { operations = new SettingsOperations(); SettingsEntity settings = operations.Get(); ValidateSettings(settings); return(settings); }
public static void AddAuthenticationAPI(this IServiceCollection services) { var setting = SettingsOperations.GetConfiguration <AuthenticationOptions>(services); services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => { options.Authority = setting.Authority; options.Audience = setting.Audience; options.RequireHttpsMetadata = false; }); }
public async Task GetSettingsAsync_ExpectedResult() { IANSSafeDNSClient client = Substitute.For <IANSSafeDNSClient>(); client.GetAsync <Settings>("/safedns/v1/settings").Returns(new Settings() { ID = 123 }); var ops = new SettingsOperations <Settings>(client); var settings = await ops.GetSettingsAsync(); Assert.AreEqual(123, settings.ID); }
public static void AddAuthenticationAPI(this IServiceCollection services) { var setting = SettingsOperations.GetConfiguration <AuthenticationOptions>(services); services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => { options.Authority = setting.Authority; options.TokenValidationParameters = new TokenValidationParameters { ValidateIssuer = true, ValidIssuer = setting.Issuer, ValidateAudience = true, ValidAudience = setting.Audience, ValidateLifetime = true }; }); }
public static void AddSwaggerAPI(this IServiceCollection services) { var setting = SettingsOperations.GetConfiguration <ApiOptions>(services); services.AddSwaggerGen(c => { c.SwaggerDoc(setting.Version, new OpenApiInfo { Title = setting.Title, Description = setting.Description, Contact = new OpenApiContact { Email = setting.SupportEmail, Name = setting.SupportName } }); c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme { Description = "JWT Authorization header using the Bearer scheme. \r\n\r\n Enter 'Bearer' [space] and then your token in the text input below.\r\n\r\nExample: \"Bearer 12345abcdef\"", Name = "Authorization", In = ParameterLocation.Header, Type = SecuritySchemeType.ApiKey, Scheme = "Bearer" }); c.AddSecurityRequirement(new OpenApiSecurityRequirement() { { new OpenApiSecurityScheme { Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "Bearer" }, Scheme = "oauth2", Name = "Bearer", In = ParameterLocation.Header }, new List <string>() } }); }); }
public void ChangeURL(SettingsEntity settings) { operations = new SettingsOperations(); operations.ChangeURL(settings); }
public void Reset() { operations = new SettingsOperations(); operations.Reset(); }