Trikoder OAuth 2 Bundle
Symfony bundle which provides OAuth 2.0 authorization/resource server capabilities. The authorization and resource server actors are implemented using the thephpleague/oauth2-server library.
This bundle provides the "glue" between thephpleague/oauth2-server library and Symfony.
It implements thephpleague/oauth2-server library in a way specified by its official documentation.
For implementation into Symfony project, please see bundle documentation and official Symfony security documentation.
This package is currently in the active development.
- API endpoint for client authorization and token issuing
- Configurable client and token persistance (includes Doctrine support)
- Integration with Symfony's Security layer
Require the bundle with Composer:
composer require trikoder/oauth2-bundle --no-plugins --no-scripts
NOTE: Due to required pre-configuration, this bundle is currently not compatible with Symfony Flex.
Create the bundle configuration file under
config/packages/trikoder_oauth2.yaml. Here is a reference configuration file:
trikoder_oauth2: authorization_server: # Full path to the private key file. # How to generate a private key: https://oauth2.thephpleague.com/installation/#generating-public-and-private-keys private_key: # Required, Example: /var/oauth/private.key # The string used as an encryption key. # How to generate an encryption key: https://oauth2.thephpleague.com/installation/#string-password encryption_key: # Required # How long the issued access token should be valid for. # The value should be a valid interval: http://php.net/manual/en/dateinterval.construct.php#refsect1-dateinterval.construct-parameters access_token_ttl: PT1H # How long the issued refresh token should be valid for. # The value should be a valid interval: http://php.net/manual/en/dateinterval.construct.php#refsect1-dateinterval.construct-parameters refresh_token_ttl: P1M resource_server: # Full path to the public key file # How to generate a public key: https://oauth2.thephpleague.com/installation/#generating-public-and-private-keys public_key: # Required, Example: /var/oauth/public.key # Scopes that you wish to utilize in your application. # This should be a simple array of strings. scopes:  # Configures different persistence methods that can be used by the bundle for saving client and token data. # Only one persistence method can be configured at a time. persistence: doctrine: # Name of the entity manager that you wish to use for managing clients and tokens. entity_manager: default # Required in_memory: ~
Enable the bundle in
config/bundles.phpby adding it to the array:
Trikoder\Bundle\OAuth2Bundle\TrikoderOAuth2Bundle::class => ['all' => true]
Update the database so bundle entities can be persisted using Doctrine:
bin/console doctrine:schema:update --force
Import the routes inside your
oauth2: resource: '@TrikoderOAuth2Bundle/Resources/config/routes.xml'
You can verify that everything is working by issuing a
GET request to the
Building the environment
Make sure your Docker images are all built and up-to-date using the following command:
After that, install all the needed packages required to develop the project:
dev/bin/php composer install
You can run the test suite using the following command:
dev/bin/php composer test
This bundle enforces the PSR-2 and Symfony code standards during development using the PHP CS Fixer utility. Before commiting any code, you can run the utility so it can fix any potential rule violations for you:
dev/bin/php composer lint
All the package releases are recorded in the CHANGELOG file.
Use the issue tracker to report any issues you might have.
See the LICENSE file for license rights and limitations (MIT).
- Merge pull request #20 from ajgarlag/feature/typo
By ajgarlag, 7 months ago
- Relaxed version constraint to allow v7.3 of oauth2-server (#11)
- Merge pull request #15 from trikoder/config-override
- Disable merging for "persistence" config node
- Update CHANGELOG.md
- Merge pull request #13 from trikoder/timed-tests
- Fix incorrect test namespace
- Use "php-timecop" for time sensitive tests
- Bump test Composer version
- Bump test PHP version
- Merge pull request #12 from Korikulum/symfony-34
- Merge pull request #9 from trikoder/symfony-34
Fix bundle creating default connection
By , 7 months ago
- Pass CryptKey instance to oauth2 with permission check disabled (#10)
- Fix improper class naming
- Add testing against multiple Symfony versions
- Relax bundle dependency requirements
- Fix typo in README.md
- Get rid of Symfony 4.2 deprecations
- Make the bundle compatible with Symfony 3.4
- Remove Symfony deprecation hack
By spideyfusion, 8 months ago