api-platform / api-platform/core

Use the Open API Bearer Authentication with bearerFormat instead of Authorization Header for JWT Authentication

Open
#8,084 0 comments 4 reactions 0 assignees View on GitHub
OpenAPI
Dominant language
PHP
Stars
2.6k
Forks
980
Avg merge
2d 5h
Merged PRs (30d)
48

Description

**Description**
In the Open API v3 specification, it's possible to set a configuration for Bearer Authentication with the JWT format (see https://swagger.io/docs/specification/authentication/bearer-authentication/). Using this configuration means you don't have to copy and paste the word `BEARER ` every time.

**Example**
ATM, I've decorated the `api_platform.openapi.factory` this way :

```php
decorated)($context);

$schemas = $openApi->getComponents()->getSecuritySchemes();

$schemas['JWT'] = new \ArrayObject([
'type' => 'http',
'scheme' => 'bearer',
'bearerFormat' => 'JWT'
]);

return $openApi;
}
}
```

but I think it could be better if we could set the `bearerFormat` directly in the Api Platform configuration.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.