Skip to content
Discussion options

You must be logged in to vote

Hi @terabytesoftw , I solved the problem.

The main challenge was to catch requests from unauthenticated users and block them by IP as well. The issue was that the authentication component aborts the request early when the user is not authenticated, so the rate limiter never got a chance to run for those requests.

To fix this, I extended CompositeAuth into a custom RateLimitedCompositeAuth class and used beforeAction to catch requests before they are aborted by the authenticator, like this:

$behaviors['authenticator'] = [
    'class' => RateLimitedCompositeAuth::class,
    'except' => ['login', ...],
    'authMethods' => [
        HttpBearerAuth::class,
    ],
];

Then, for authenticated r…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@mfoq
Comment options

Answer selected by mfoq
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants