Download the PHP package shoprenter/sr-oauth-jwt-security without Composer
On this page you can find all versions of the php package shoprenter/sr-oauth-jwt-security. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download shoprenter/sr-oauth-jwt-security
More information about shoprenter/sr-oauth-jwt-security
Files in shoprenter/sr-oauth-jwt-security
Package sr-oauth-jwt-security
Short Description This package provides the ability to secure endpoints with shoprenter oauth token
License MIT
Informations about the package sr-oauth-jwt-security
OAuth JWT Security Bundle for Symfony 6.4
This Symfony bundle provides JWT-based OAuth token verification and user authentication for securing your API endpoints.
Installation
-
Install the bundle using Composer:
-
Configure the bundle in
config/packages/shoprenter.yaml: - Configure security in
config/packages/security.yaml:
Usage
Securing Endpoints with Scopes
Use voter attributes to check for specific OAuth scopes:
Using Annotations/Attributes
With Symfony 6.4, you can use PHP attributes to secure controllers:
Client Authentication
Clients must include a Bearer token in the Authorization header:
Error Handling
The authenticator will return a JSON response with a 401 status code if authentication fails.
It will return 403 status if a required scope is missing.
Technical Implementation Details
Service Configuration
This bundle follows Symfony's best practices for service configuration:
- Services are defined in
src/Resources/config/services.yaml - The service configuration is loaded by the bundle's extension class (
ShoprenterOauthJWTSecurityExtension) - When the bundle is enabled in your application, all services are automatically registered with the Symfony container
This approach ensures that services are properly loaded and configured without requiring manual setup in your application.
Development
Run the container:
This command:
-d: Runs the container in detached mode (background) --name: Assigns a name to the container -v $(pwd):/var/www: Mounts your current directory to /var/www in the container
Enter the running container:
Running Tests
The bundle includes comprehensive unit tests for all core components. To run the tests:
-
Install the development dependencies:
- Run the PHPUnit tests: