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