pe / symfony-bundle-oauth2-client
Symfony integration of league/oauth2-client
Installs: 11
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=7.0.8
- doctrine/common: ^2.7
- league/oauth2-client: ^2.0 <2.3.0
- symfony/expression-language: ~4.4
- symfony/framework-bundle: ~4.4
- symfony/security-bundle: ~4.4
- symfony/twig-bundle: ~4.4
Requires (Dev)
- league/oauth2-facebook: ^2.0
- league/oauth2-github: ^2.0
- league/oauth2-google: ^2.2
- league/oauth2-instagram: ^2.0
- league/oauth2-linkedin: ^3.0
Suggests
- league/oauth2-facebook: To use Facebook authentication provider
- league/oauth2-github: To use Github authentication provider
- league/oauth2-google: To use Google authentication provider
- league/oauth2-instagram: To use Instagram authentication provider
- league/oauth2-linkedin: To use LinkedIn authentication provider
This package is auto-updated.
Last update: 2024-10-19 08:09:07 UTC
README
This bundle integrates with league/oauth2-client.
Installation
Install the library via Composer by running the following command:
composer require pe/symfony-bundle-oauth2-client
Then enable the bundle in your kernel:
<?php // app/AppKernel.php class AppKernel { public function registerBundles() { $bundles = [ // ... new PE\Bundle\OAuth2ClientBundle\PEOAuth2ClientBundle(), // ... ]; } }
or for Symfony 4.0
<?php // SF 4.0 config/bundles.php return [ PE\Bundle\OAuth2ClientBundle\PEOAuth2ClientBundle::class => ['all' => true], ];
Configuration
Add to your config with facebook provider example, all provider options match constructor options argument array keys
pe_oauth2_client: driver: orm class: social_account: App\Entity\SocialAccount provider: facebook: class: \League\OAuth2\Client\Provider\Facebook options: clientId: 123 clientSecret: 456 graphApiVersion: v2.12
Add security authenticator
security: # other security config firewalls: some_firewall: # other firewall options guard: authenticators: - pe_oauth2_client.security.authenticator
Create entities
<?php namespace App\Entity; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity() * @ORM\Table(name="oauth2_social_accounts") */ class SocialAccount extends \PE\Bundle\OAuth2ClientBundle\Model\SocialAccount { /** * @ORM\Id() * @ORM\Column(type="guid", unique=true) * @ORM\GeneratedValue(strategy="CUSTOM") * @ORM\CustomIdGenerator(class="Ramsey\Uuid\Doctrine\UuidGenerator") * * @var string */ protected $id; }