Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auth.apikey must be placed before throttling middleware ? #162

Open
damsvann opened this issue Jun 8, 2018 · 0 comments
Open

auth.apikey must be placed before throttling middleware ? #162

damsvann opened this issue Jun 8, 2018 · 0 comments

Comments

@damsvann
Copy link

damsvann commented Jun 8, 2018

Half a comment / Half a question

Laravel: v5.6
api-guard: v4.1

In the Http/Kernel.php file, middleware section I noticed that

Is half-working since the user won't be set in the $request object throttling middleware class. $request->user() will always return null.

        'api' => [
            'throttle:rate_limit,1',
            'auth.apikey',
            ...
        ],

The following is working though

        'api' => [
            'auth.apikey',
            'throttle:rate_limit,1',
            ...
        ],

As far as I remember middlewares are prioritized so this may be expected, but the documentation is wrong and should be

/**
 * The application's route middleware groups.
 *
 * @var array
 */
protected $middlewareGroups = [
    ...

    'api' => [
        'auth.apikey',
        'throttle:60,1',
        'bindings',
    ],
];

Correct me if I am wrong, I'll be pleased to assist and give more details on our laravel setup.

Edited:
Just to clarify our use case, we want to accept visitor and limit their rate with a really low threshold. To do so we need to change the middleware to not send a unauthorized response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant