public SecurityBase(ICloudFoundryOptions options, IManagementOptions mgmtOptions, ILogger logger = null, HttpClient httpClient = null) { _options = options; _mgmtOptions = mgmtOptions; _logger = logger; _httpClient = httpClient; }
public CloudFoundrySecurity(ICloudFoundryOptions options, IManagementOptions managementOptions, ILogger <CloudFoundrySecurity> logger = null) { _options = options; _managementOptions = managementOptions; _logger = logger; _base = new SecurityBase(options, managementOptions, logger); }
public static bool ShouldInvoke(this IEndpoint endpoint, IManagementOptions mgmtContext, ILogger logger = null) { var enabled = endpoint.IsEnabled(mgmtContext); var exposed = endpoint.IsExposed(mgmtContext); logger?.LogDebug($"endpoint: {endpoint.Id}, contextPath: {mgmtContext.Path}, enabled: {enabled}, exposed: {exposed}"); return(enabled && exposed); }
public CloudFoundrySecurityOwinMiddleware(OwinMiddleware next, ICloudFoundryOptions options, IEnumerable <IManagementOptions> mgmtOptions, ILogger <CloudFoundrySecurityOwinMiddleware> logger = null) : base(next) { _options = options; _logger = logger; _mgmtOptions = mgmtOptions.OfType <CloudFoundryManagementOptions>().Single(); _base = new SecurityBase(options, _mgmtOptions, logger); }
public CloudFoundrySecurityMiddleware(RequestDelegate next, ICloudFoundryOptions options, IEnumerable <IManagementOptions> mgmtOptions, ILogger <CloudFoundrySecurityMiddleware> logger = null) { _next = next; _logger = logger; _options = options; _mgmtOptions = mgmtOptions?.OfType <CloudFoundryManagementOptions>().SingleOrDefault(); _base = new SecurityBase(options, _mgmtOptions, logger); }
public CloudFoundrySecurityMiddleware(RequestDelegate next, ICloudFoundryOptions options, CloudFoundryManagementOptions mgmtOptions, ILogger <CloudFoundrySecurityMiddleware> logger = null) { _next = next; _logger = logger; _options = options; _mgmtOptions = mgmtOptions; _base = new SecurityBase(options, _mgmtOptions, logger); }
public static bool RequestVerbAndPathMatch(this IEndpoint endpoint, string httpMethod, string requestPath, IEnumerable <HttpMethod> allowedMethods, IEnumerable <IManagementOptions> mgmtOptions, bool exactMatch) { IManagementOptions matchingMgmtContext = null; return(endpoint.RequestPathMatches(requestPath, mgmtOptions, out matchingMgmtContext, exactMatch) && endpoint.IsEnabled(matchingMgmtContext) && endpoint.IsExposed(matchingMgmtContext) && allowedMethods.Any(m => m.Method.Equals(httpMethod))); }
public EndpointMiddleware(IManagementOptions mgmtOptions, ILogger logger = null) { _logger = logger; _mgmtOptions = mgmtOptions ?? throw new ArgumentNullException(nameof(mgmtOptions)); if (_mgmtOptions is ManagementEndpointOptions mgmt) { mgmt.SerializerOptions = GetSerializerOptions(mgmt.SerializerOptions); } }
public static bool IsEnabled(this IEndpointOptions options, IManagementOptions mgmtOptions) { var endpointOptions = (AbstractEndpointOptions)options; if (endpointOptions.Enabled.HasValue) { return(endpointOptions.Enabled.Value); } if (mgmtOptions.Enabled.HasValue) { return(mgmtOptions.Enabled.Value); } return(endpointOptions.DefaultEnabled); }
public CloudFoundryEndpoint(ICloudFoundryOptions options, CloudFoundryManagementOptions mgmtOptions, ILogger <CloudFoundryEndpoint> logger = null) : base(options) { if (options == null) { throw new ArgumentNullException(nameof(options)); } _mgmtOption = mgmtOptions; if (_mgmtOption == null) { throw new ArgumentNullException(nameof(mgmtOptions)); } _logger = logger; }
public CloudFoundryEndpoint(ICloudFoundryOptions options, IEnumerable <IManagementOptions> mgmtOptions, ILogger <CloudFoundryEndpoint> logger = null) : base(options) { if (options == null) { throw new ArgumentNullException(nameof(options)); } _mgmtOption = mgmtOptions?.OfType <CloudFoundryManagementOptions>().SingleOrDefault(); if (_mgmtOption == null) { throw new ArgumentNullException(nameof(mgmtOptions)); } _logger = logger; }
public MappingsEndpointMiddleware( RequestDelegate next, IMappingsOptions options, IManagementOptions mgmtOptions, MappingsEndpoint endpoint, IRouteMappings routeMappings = null, IActionDescriptorCollectionProvider actionDescriptorCollectionProvider = null, IEnumerable <IApiDescriptionProvider> apiDescriptionProviders = null, ILogger <MappingsEndpointMiddleware> logger = null) : base(endpoint, mgmtOptions, logger: logger) { _next = next; _options = options; _routeMappings = routeMappings; _actionDescriptorCollectionProvider = actionDescriptorCollectionProvider; _apiDescriptionProviders = apiDescriptionProviders; }
public static bool IsExposed(this IEndpointOptions options, IManagementOptions mgmtOptions) { var actOptions = mgmtOptions as ActuatorManagementOptions; if (!string.IsNullOrEmpty(options.Id) && actOptions != null && actOptions.Exposure != null) { var exclude = actOptions.Exposure.Exclude; if (exclude != null && (exclude.Contains("*") || exclude.Contains(options.Id))) { return(false); } var include = actOptions.Exposure.Include; if (include != null && (include.Contains("*") || include.Contains(options.Id))) { return(true); } return(false); } return(true); }
public static string GetContextPath(this IEndpointOptions options, IManagementOptions mgmtContext) { var contextPath = mgmtContext.Path; if (!contextPath.EndsWith("/") && !string.IsNullOrEmpty(options.Path)) { contextPath += "/"; } contextPath += options.Path; if (!options.ExactMatch) { if (!contextPath.EndsWith("/")) { contextPath += "/"; } contextPath += "{**_}"; } return(contextPath); }
private static bool RequestPathMatches(this IEndpoint endpoint, string requestPath, IEnumerable <IManagementOptions> mgmtOptions, out IManagementOptions matchingContext, bool exactMatch = true) { matchingContext = null; var endpointPath = endpoint.Path; if (mgmtOptions == null) { return(exactMatch ? requestPath.Equals(endpointPath) : requestPath.StartsWith(endpointPath)); } else { foreach (var context in mgmtOptions) { var contextPath = context.Path; if (!contextPath.EndsWith("/") && !string.IsNullOrEmpty(endpointPath)) { contextPath += "/"; } var fullPath = contextPath + endpointPath; if (exactMatch ? requestPath.Equals(fullPath) : requestPath.StartsWith(fullPath)) { matchingContext = context; return(true); } } return(false); } }
public static bool IsExposed(this IEndpoint endpoint, IManagementOptions mgmtContext) { return(mgmtContext == null ? true : endpoint.Options.IsExposed(mgmtContext)); }
public static bool IsEnabled(this IEndpoint endpoint, IManagementOptions mgmtContext) { return(mgmtContext == null ? endpoint.Enabled : endpoint.Options.IsEnabled(mgmtContext)); }
public ActuatorSecurityMiddlewareTest(IManagementOptions mopts) { Environment.SetEnvironmentVariable("VCAP_APPLICATION", "somestuff"); _base = new SecurityBase(new CloudFoundryEndpointOptions(), mopts); }
public ActuatorSecurityMiddlewareTest(IManagementOptions mopts) { Environment.SetEnvironmentVariable("VCAP_APPLICATION", "somestuff"); }
public TestMiddleware2(IEndpoint <string, string> endpoint, IManagementOptions mgmtOptions, ILogger logger) : base(endpoint, mgmtOptions, logger: logger) { }
public ActuatorEndpoint(IActuatorHypermediaOptions options, IEnumerable <IManagementOptions> mgmtOptions, ILogger <ActuatorEndpoint> logger = null) : base(options) { _mgmtOption = mgmtOptions?.OfType <ActuatorManagementOptions>().Single(); _logger = logger; }
public LoggersEndpointMiddleware(RequestDelegate next, LoggersEndpoint endpoint, IManagementOptions mgmtOptions, ILogger <LoggersEndpointMiddleware> logger = null) : base(endpoint, mgmtOptions, logger) { _next = next; }
public ThreadDumpEndpointMiddleware(RequestDelegate next, ThreadDumpEndpoint endpoint, IManagementOptions mgmtOptions, ILogger <ThreadDumpEndpointMiddleware> logger = null) : base(endpoint, mgmtOptions, logger: logger) { _next = next; }
public EndpointMiddleware(IManagementOptions mgmtOptions, ILogger logger = null) { _logger = logger; _mgmtOptions = mgmtOptions ?? throw new ArgumentNullException(nameof(mgmtOptions)); }
public HypermediaService(IManagementOptions mgmtOptions, IEndpointOptions options, ILogger logger = null) { _logger = logger; _mgmtOptions = mgmtOptions ?? throw new ArgumentNullException(nameof(mgmtOptions)); _options = options ?? throw new ArgumentNullException(nameof(options)); }
public EndpointMiddleware(IEndpoint <TResult> endpoint, IManagementOptions mgmtOptions, ILogger logger = null) { _logger = logger; _endpoint = endpoint ?? throw new ArgumentNullException(nameof(endpoint)); _mgmtOptions = mgmtOptions ?? throw new ArgumentNullException(nameof(mgmtOptions)); }
public CloudFoundryEndpointMiddleware(RequestDelegate next, CloudFoundryEndpoint endpoint, IManagementOptions mgmtOptions, ILogger <CloudFoundryEndpointMiddleware> logger = null) : base(endpoint, mgmtOptions, logger: logger) { _next = next; _options = endpoint.Options as ICloudFoundryOptions; }
public HealthEndpointMiddleware(RequestDelegate next, IManagementOptions mgmtOptions, ILogger <InfoEndpointMiddleware> logger = null) : base(mgmtOptions: mgmtOptions, logger: logger) { _next = next; }
public PrometheusScraperEndpointMiddleware(RequestDelegate next, PrometheusScraperEndpoint endpoint, IManagementOptions mgmtOptions, ILogger <PrometheusScraperEndpointMiddleware> logger = null) : base(endpoint, mgmtOptions, logger) { _next = next; }