stefanprodan / WebApiThrottle

ASP.NET Web API rate limiter for IIS and Owin hosting

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Defaults ignored after throttle policy serialized to external cache

dmarlow opened this issue · comments

PR: #106

I have the following config to be used as my "default":

public static readonly ThrottlePolicy Policy = new ThrottlePolicy(perMinute: 20)
{
    // Scope to clients
    ClientThrottling = true,

    // Scope to endpoints
    EndpointThrottling = true    
};

However, when it serializes to my Redis version of IPolicyRepository, it looks like this:

{
	"IpThrottling" : false,
	"IpWhitelist" : {
		"$values" : []
	},
	"IpRules" : {},
	"ClientThrottling" : true,
	"ClientWhitelist" : {
		"$values" : []
	},
	"ClientRules" : {},
	"EndpointThrottling" : true,
	"EndpointWhitelist" : {
		"$values" : []
	},
	"EndpointRules" : {},
	"StackBlockedRequests" : false
}

I lose the perMinute default of 20 I had specified and causes my throttling to be non-operational.

I believe the fix to be setting ThrottlePolicy.Rates to public from internal.

Thanks for the PR, published on nuget v1.5.4