mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralsec.git
synced 2025-10-29 18:02:29 +00:00
Proper error returning for rate limiting.
This commit is contained in:
@@ -62,6 +62,7 @@ components:
|
||||
- 7 # ACCESS_DENIED,
|
||||
- 8 # INVALID_TOKEN
|
||||
- 9 # expired token
|
||||
- 10 # rate limit exceeded
|
||||
ErrorDetails:
|
||||
type: string
|
||||
ErrorDescription:
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace OpenWifi {
|
||||
Poco::Net::HTTPRequest::HTTP_GET,
|
||||
Poco::Net::HTTPRequest::HTTP_OPTIONS},
|
||||
Server,
|
||||
Internal, false, true , RateLimit{.Interval=2000,.MaxCalls=10}) {}
|
||||
Internal, false, true , RateLimit{.Interval=1000,.MaxCalls=10}) {}
|
||||
static const std::list<const char *> PathName() { return std::list<const char *>{"/api/v1/oauth2/{token}","/api/v1/oauth2"}; };
|
||||
void DoGet() final;
|
||||
void DoPost() final;
|
||||
|
||||
@@ -81,7 +81,8 @@ namespace OpenWifi {
|
||||
INTERNAL_ERROR,
|
||||
ACCESS_DENIED,
|
||||
INVALID_TOKEN,
|
||||
EXPIRED_TOKEN
|
||||
EXPIRED_TOKEN,
|
||||
RATE_LIMIT_EXCEEDED
|
||||
};
|
||||
|
||||
class AppServiceRegistry {
|
||||
@@ -1524,8 +1525,9 @@ namespace OpenWifi {
|
||||
Request = &RequestIn;
|
||||
Response = &ResponseIn;
|
||||
|
||||
if(RateLimited_ && RESTAPI_RateLimiter()->IsRateLimited(RequestIn,MyRates_.Interval, MyRates_.MaxCalls))
|
||||
return;
|
||||
if(RateLimited_ && RESTAPI_RateLimiter()->IsRateLimited(RequestIn,MyRates_.Interval, MyRates_.MaxCalls)) {
|
||||
return UnAuthorized("Rate limit exceeded.",RATE_LIMIT_EXCEEDED);
|
||||
}
|
||||
|
||||
if (!ContinueProcessing())
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user