PHPackages                             towa/spryker-social-oauth - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. towa/spryker-social-oauth

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

towa/spryker-social-oauth
=========================

Social OAuth Module for Spryker

012.7k↓44.4%2PHP

Since Mar 2Pushed 3y ago1 watchersCompare

[ Source](https://github.com/towa-digital/spryker-social-oauth)[ Packagist](https://packagist.org/packages/towa/spryker-social-oauth)[ RSS](/packages/towa-spryker-social-oauth/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

TowaSprykerOauth Module
=======================

[](#towasprykeroauth-module)

[![Minimum PHP Version](https://camo.githubusercontent.com/0e9ac047546796cfdbe1423d1f4d91c8f37d2fbb11614a7900bb7686aaa5401f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230372e342d3838393242462e737667)](https://php.net/)

A Spryker wrapper for [`knpuniversity/oauth2-client-bundle`](https://github.com/knpuniversity/oauth2-client-bundle)

Installation
============

[](#installation)

```
docker/sdk cli composer require "towa/spryker-social-oauth" --no-update
docker/sdk cli composer update "towa/spryker-social-oauth"
```

Usage
=====

[](#usage)

Configuration
-------------

[](#configuration)

In your `config_default.php` add your provider configuration. E.g.

```
// config-default.php

use Towa\Service\TowaSprykerOauth\TowaSprykerOauthConstants;

$config[TowaSprykerOauthConstants::TOWA_SPRYKER_AUTH_CONFIG] = [
    'github' => [
        'clientId'          => '{github-client-id}',
        'clientSecret'      => '{github-client-secret}',
        'redirectUri'       => 'https://example.com/callback-url',
    ],
    'google' => [
        'clientId'     => '{google-client-id}',
        'clientSecret' => '{google-client-secret}',
        'redirectUri'  => 'https://example.com/callback-url',
        'hostedDomain' => 'example.com', // optional; used to restrict access to users on your G Suite/Google Apps for Business accounts
    ]
]

```

> Make sure you have the correct client installed for your provider. Please refer to

Add the Towa Namespace to the Core Namespaces.

```
// config_default.php

$config[KernelConstants::CORE_NAMESPACES] = [
    ...
    'Towa'
];

```

Agent Configuration
-------------------

[](#agent-configuration)

Extend the SecurityApplicationPlugin on Project level.

```
// Pyz\Yves\Security\Plugin\Application\SecurityApplicationPlugin

class SecurityApplicationPlugin extends SprykerSecurityApplicationPlugin
{
    public const SERVICE_SECURITY_AUTHENTICATION_PROVIDER_TOWA = 'security.authentication_provider.agent.dao';

    /**
     * @param \Spryker\Service\Container\ContainerInterface $container
     *
     * @return \Spryker\Service\Container\ContainerInterface
     */
    protected function addListenerPrototypes(ContainerInterface $container): ContainerInterface
    {
        $container = $this->addTowaAuthenticator($container);
        $container = parent::addListenerPrototypes($container);

        return $container;
    }

    /**
     * @param \Spryker\Service\Container\ContainerInterface $container
     *
     * @return \Spryker\Service\Container\ContainerInterface
     */
    protected function addAuthenticationProviderPrototypes(ContainerInterface $container): ContainerInterface
    {
        $container = parent::addAuthenticationProviderPrototypes($container);
        $container = $this->addTowaAuthenticationProvider($container);

        return $container;
    }

    /**
     * @param \Spryker\Service\Container\ContainerInterface $container
     *
     * @return \Spryker\Service\Container\ContainerInterface
     */
    private function addTowaAuthenticator(ContainerInterface $container): ContainerInterface
    {
        $container->set(
            AgentAuthenticator::AUTHENTICATOR_KEY,
            new AgentAuthenticator(
                $this->getFactory()->getProvider(),
                $this->getFactory()->getProviderClient(),
                $this->getFactory()->getUserClient(),
            )
        );

        return $container;
    }

    /**
     * @param \Spryker\Service\Container\ContainerInterface $container
     *
     * @return \Spryker\Service\Container\ContainerInterface
     */
    protected function addTowaAuthenticationProvider(ContainerInterface $container): ContainerInterface
    {
        $container->set(
            static::SERVICE_SECURITY_AUTHENTICATION_PROVIDER_KEYCLOAK,
            new AgentAuthenticationProvider(
                $container->get(AgentAuthenticator::AUTHENTICATOR_KEY),
                $this->getFactory()->createAgentUserProvider(),
                new UserChecker()
            )
        );

        return $container;
    }
}
```

In the SecurityFactory you now need to add functions for the proper Provider and Client.

```
// Pyz\Yves\Security\Plugin\Application\SecurityApplicationPlugin

class SecurityFactory extends SprykerSecurityFactory
{
    /**
     * @return \Pyz\Yves\Security\Dependency\Client\SecurityToCustomerClientInterface
     */
    public function getCustomerClient(): SecurityToCustomerClientInterface
    {
        return $this->getProvidedDependency(SecurityDependencyProvider::CLIENT_CUSTOMER);
    }

    /**
     * @return \Pyz\Client\User\UserClientInterface
     */
    public function getUserClient(): UserClientInterface
    {
        return $this->getProvidedDependency(SecurityDependencyProvider::CLIENT_USER);
    }

    /**
     * @return \Towa\Service\TowaSprykerOauth\TowaSprykerOauthServiceInterface
     */
    public function getTowaOauthService(): TowaOauthServiceInterface
    {
        return $this->getProvidedDependency(SecurityDependencyProvider::SERVICE_TOWAOAUTH);
    }

    /**
     * @return \League\OAuth2\Client\Provider\AbstractProvider
     */
    public function getProvider(): AbstractProvider
    {
        return $this->getTowaOauthService()->getSocialOauthProvider('github'); // replace github with whichever provider you are using
    }

    /**
     * @return \KnpU\OAuth2ClientBundle\Client\OAuth2ClientInterface
     */
    public function getProviderClient(): OAuth2ClientInterface
    {
        return $this->getTowaOauthService()->getSocialOauthClient('github'); // replace github with whichever provider you are using
    }

    /**
     * @return \Symfony\Component\Security\Core\User\UserProviderInterface
     */
    public function createAgentUserProvider(): UserProviderInterface
    {
        return new AgentUserProvider();
    }
}

```

Adjust the DependencyProvider

```
class SecurityDependencyProvider extends SprykerSecurityDependencyProvider
{
    public const CLIENT_CUSTOMER = 'CLIENT_CUSTOMER';
    public const SERVICE_TOWAOAUTH = 'SERVICE_TOWAOAUTH';
    public const CLIENT_USER = 'CLIENT_USER';

    /**
     * @param \Spryker\Yves\Kernel\Container $container
     *
     * @return \Spryker\Yves\Kernel\Container
     */
    public function provideDependencies(Container $container): Container
    {
        $container = parent::provideDependencies($container);

        $container = $this->addCustomerClient($container);
        $container = $this->addTowaOauthService($container);
        $container = $this->addUserClient($container);

        return $container;
    }

    /**
     * @param \Spryker\Yves\Kernel\Container $container
     *
     * @return \Spryker\Yves\Kernel\Container
     */
    protected function addCustomerClient(Container $container): Container
    {
        $container->set(static::CLIENT_CUSTOMER, function (Container $container): SecurityToCustomerClientInterface {
            return new SecurityToCustomerClientBridge(
                $container->getLocator()->customer()->client()
            );
        });

        return $container;
    }

    /**
     * @param \Spryker\Yves\Kernel\Container $container
     *
     * @return \Spryker\Yves\Kernel\Container
     */
    private function addTowaOauthService(Container $container): Container
    {
        $container->set(static::SERVICE_TOWAOAUTH, function (Container $container): TowaOauthServiceInterface {
            return $container->getLocator()->TowaSprykerOauth()->service();
        });

        return $container;
    }

    /**
     * @param \Spryker\Yves\Kernel\Container $container
     *
     * @return \Spryker\Yves\Kernel\Container
     */
    private function addUserClient(Container $container): Container
    {
        $container->set(static::CLIENT_USER, function (Container $container): UserClientInterface {
            return $container->getLocator()->user()->client();
        });

        return $container;
    }
}

```

Yves Configuration
------------------

[](#yves-configuration)

TODO

Zed Configuration
-----------------

[](#zed-configuration)

TODO

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity23

Early-stage or recently created project

 Bus Factor1

Top contributor holds 62.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/0ae79fe5eac63e70cae17e807413a5a30fafcc54c11fb23a8e5808fa3b3a51ec?d=identicon)[TOWA](/maintainers/TOWA)

---

Top Contributors

[![Gabsii](https://avatars.githubusercontent.com/u/23434539?v=4)](https://github.com/Gabsii "Gabsii (27 commits)")[![fabio-towa](https://avatars.githubusercontent.com/u/77491577?v=4)](https://github.com/fabio-towa "fabio-towa (7 commits)")[![zoltanpolyak](https://avatars.githubusercontent.com/u/214793328?v=4)](https://github.com/zoltanpolyak "zoltanpolyak (7 commits)")[![polyakz](https://avatars.githubusercontent.com/u/27897571?v=4)](https://github.com/polyakz "polyakz (1 commits)")[![simonrauch](https://avatars.githubusercontent.com/u/17831964?v=4)](https://github.com/simonrauch "simonrauch (1 commits)")

### Embed Badge

![Health badge](/badges/towa-spryker-social-oauth/health.svg)

```
[![Health](https://phpackages.com/badges/towa-spryker-social-oauth/health.svg)](https://phpackages.com/packages/towa-spryker-social-oauth)
```

###  Alternatives

[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)[beatswitch/lock

A flexible, driver based Acl package for PHP 5.4+

870304.7k2](/packages/beatswitch-lock)[amocrm/amocrm-api-library

amoCRM API Client

182728.5k6](/packages/amocrm-amocrm-api-library)[vonage/jwt

A standalone package for creating JWTs for Vonage APIs

424.1M4](/packages/vonage-jwt)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
