Fix Api authenticate missing bearer token
This commit is contained in:
parent
39b003e027
commit
6ec8ed1114
2 changed files with 8 additions and 0 deletions
|
|
@ -47,6 +47,9 @@ use Kwaadpepper\Enum\BaseEnumRoutable;
|
|||
* a replay attack scenario. Timestamps are provided in headers
|
||||
* and in the http body
|
||||
*
|
||||
* @method static self missingParameter()
|
||||
* The request is missing some parameters
|
||||
*
|
||||
* @method static self throttleRequestsException()
|
||||
* Too many requests have been attempted. The is a throttle security.
|
||||
* Normally you should not trigger this.
|
||||
|
|
@ -78,6 +81,7 @@ class ApiError extends BaseEnumRoutable
|
|||
'singleOptinCustomerExists' => 120,
|
||||
'methodNotAllowed' => 150,
|
||||
'wrongTimeStamp' => 151,
|
||||
'missingParameter' => 400,
|
||||
'authorizationException' => 403,
|
||||
'throttleRequestsException' => 429
|
||||
];
|
||||
|
|
@ -96,6 +100,7 @@ class ApiError extends BaseEnumRoutable
|
|||
'needAuth' => 'Vous devez être authentifié',
|
||||
'methodNotAllowed' => 'This method is not allowed for this request',
|
||||
'wrongTimeStamp' => 'Your request is malformed, please check timestamp header and parameter',
|
||||
'missingParameter' => 'The request is missing some parameters',
|
||||
'authorizationException' => 'You are not autorized to access this',
|
||||
'throttleRequestsException' => 'Throttle: too many request have been attempted, please retry later'
|
||||
];
|
||||
|
|
|
|||
|
|
@ -20,6 +20,9 @@ class ApiController extends Controller
|
|||
public function authenticate(Request $request)
|
||||
{
|
||||
try {
|
||||
if (!$request->bearerToken()) {
|
||||
throw new ApiErrorException(ApiError::missingParameter());
|
||||
}
|
||||
/** @var \App\Models\Service */
|
||||
$service = Service::getFromBearerToken($request->bearerToken());
|
||||
} catch (ModelNotFoundException $e) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue