craffft / contao-oauth2-bundle
ContaoOAuth2Bundle for Symfony with Contao
Installs: 38
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 3
Forks: 2
Open Issues: 1
Type:contao-bundle
Requires
- php: >=7.1
- contao/core-bundle: ~4.4
- doctrine/orm: ~2.5
- friendsofsymfony/oauth-server-bundle: ~1.5
- menatwork/contao-multicolumnwizard: ^3.3
- symfony/browser-kit: ~2.8|~3.0
- symfony/framework-bundle: ~2.8|~3.0
- symfony/http-kernel: ~2.8|~3.0
- symfony/security: ~2.8|~3.0
Requires (Dev)
- contao/manager-plugin: ^2.0
- doctrine/doctrine-fixtures-bundle: ^2.3
- phpunit/phpunit: ^4.8
Conflicts
- contao/core: *
- contao/manager-plugin: <2.0 || >=3.0
This package is not auto-updated.
Last update: 2020-08-21 20:32:18 UTC
README
Contao OAuth2 Bundle
Contao OAuth2 Bundle for Symfony
Installation
Step 1: Download the Bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require craffft/contao-oauth2-bundle "~1.0"
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Step 2: Enable the Bundle
Then, enable the bundle by adding it to the list of registered bundles
in the app/AppKernel.php
file of your project:
<?php // app/AppKernel.php // ... class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... // Add them all! new Contao\CoreBundle\HttpKernel\Bundle\ContaoModuleBundle('multicolumnwizard', $this->getRootDir()), new FOS\OAuthServerBundle\FOSOAuthServerBundle(), new Craffft\ContaoOAuth2Bundle\CraffftContaoOAuth2Bundle(), ); // ... } // ... }
Step 3: Config the Bundle
As next add the following configuration to the app/config/config.yml
file of
your project:
# app/config/config.yml # ... # Doctrine configuration doctrine: dbal: # ... orm: auto_generate_proxy_classes: "%kernel.debug%" naming_strategy: doctrine.orm.naming_strategy.underscore auto_mapping: true # ... # FOS OAuth2 Server Bundle fos_oauth_server: db_driver: orm client_class: Craffft\ContaoOAuth2Bundle\Entity\OAuth2Client access_token_class: Craffft\ContaoOAuth2Bundle\Entity\OAuth2AccessToken refresh_token_class: Craffft\ContaoOAuth2Bundle\Entity\OAuth2RefreshToken auth_code_class: Craffft\ContaoOAuth2Bundle\Entity\OAuth2AuthCode service: user_provider: craffft.contao_oauth2.user_provider
Import the routing.yml configuration file in app/config/routing.yml:
# app/config/routing.yml fos_oauth_server_token: resource: "@FOSOAuthServerBundle/Resources/config/routing/token.xml" fos_oauth_server_authorize: resource: "@FOSOAuthServerBundle/Resources/config/routing/authorize.xml"
Copy the content of vendor/contao/core-bundle/src/Resources/config/security.yml
file and replace app/config/security.yml
file with it. Than amend it with the
following code:
# app/config/security.yml # ... security: encoders: Craffft\ContaoOAuth2Bundle\Entity\Member: id: craffft.contao_oauth2.contao_password_encoder firewalls: oauth_token: # Everyone can access the access token URL. pattern: ^/oauth/v2/token security: false api: pattern: ^/api # All URLs are protected fos_oauth: true # OAuth2 protected resource stateless: true # Do no set session cookies anonymous: false # Anonymous access is not allowed
Step 4: Generate database tables
Change your database tables to InnoDB to prevent schema update errors.
ALTER TABLE tl_member ENGINE=InnoDB; ALTER TABLE tl_oauth_client ENGINE=InnoDB;
Please update your database with the following command, because the contao install tool will not generate the symfony relevant tables.
php app/console doctrine:schema:update --force