0

Using Laravel 5.6

I don't want to use withoutMiddleware - I am trying instead to override the default throttle settings, but nothing seems to work.

'api' => [
    'throttle:60,1',
    'auth:api',
],

Changing the throttle number seems to do absolutely nothing.

The error is always:

(
    [message] => Too Many Attempts.
    [exception] => Symfony\Component\HttpKernel\Exception\HttpException
    [file] => /root/laravel/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php
    [line] => 120
)

It runs locally, but on circleci, no cigar - too many attempts.

It almost seems like only circlci is ignoring any settings relating to throttling and doing it's own dang thing.

I've attempted changing everything - but the only thing that stops it happening is withoutMiddleware and that has other side effects I don't want.

Tim Ogilvy
  • 1,923
  • 1
  • 24
  • 36

1 Answers1

0

Ended up fixing this with a variation on this solution from GitHub.

Created an environment variable in .env:

OAUTH_TOKEN_MAX_ATTEMPTS='60,1' 

Then added the following to App\Providers\RouteServiceProvider:

/**
 * Define the routes for the application.
 *
 * @return void
 */
public function map()
{
    $this->mapApiRoutes();

    $this->mapWebRoutes();

    $oauthMaxAttemtps = env('OAUTH_TOKEN_MAX_ATTEMPTS', '60,1');

    Route::post('/oauth/token', [
        'uses' => '\Laravel\Passport\Http\Controllers\AccessTokenController@issueToken',
        'middleware' => "throttle:$oauthMaxAttemtps",
    ]);
}

and in .circlci/cofig.yml:

jobs:
  build:
    docker:
      - image: weengsteam/php7.1-mysql-5.7
    working_directory: ~/laravel
    environment:
        APP_NAME: API
        APP_ENV: testing
        APP_KEY: base64:pLeAsEdOnTcOmEaNdStEaLmYdAtA?=
        APP_DEBUG: true
        DB_CONNECTION: mysql
        DB_HOST: 127.0.0.1
        DB_PORT: 3306
        DB_DATABASE: testing
        DB_USERNAME: laravel
        DB_PASSWORD: not-a-secret
        OAUTH_TOKEN_MAX_ATTEMPTS: 600,1
Tim Ogilvy
  • 1,923
  • 1
  • 24
  • 36