PHPackages                             68publishers/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. 68publishers/oauth

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

68publishers/oauth
==================

OAuth integration into Nette Framework

v1.0.1(10mo ago)15261MITPHPPHP ^8.1CI passing

Since Jan 29Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/68publishers/oauth)[ Packagist](https://packagist.org/packages/68publishers/oauth)[ RSS](/packages/68publishers-oauth/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (14)Versions (3)Used By (0)

OAuth
=====

[](#oauth)

👤 OAuth integration into Nette Framework

[![Checks](https://camo.githubusercontent.com/7aa039a8090e9fb6ef1e7bbed6a97a20a7870d045ee830cd95eabab4805614a8/68747470733a2f2f62616467656e2e6e65742f6769746875622f636865636b732f36387075626c6973686572732f6f617574682f6d61696e)](https://github.com/68publishers/oauth/actions)[![Coverage Status](https://camo.githubusercontent.com/74360af56f8ecd58612feb639cc277e38ec880b4fcd51738b4d114d8353adaac/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f36387075626c6973686572732f6f617574682f62616467652e7376673f6272616e63683d6d61696e)](https://coveralls.io/github/68publishers/oauth?branch=main)[![Total Downloads](https://camo.githubusercontent.com/f8451f6dc6709adbb6e6f0935002741f3653fd3901338983606099d2fde53362/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f64742f36387075626c6973686572732f6f61757468)](https://packagist.org/packages/68publishers/oauth)[![Latest Version](https://camo.githubusercontent.com/5b116b1de5b7caf3852d60235bc76902afcc49f334c86a89485aa3d76f984478/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f762f36387075626c6973686572732f6f61757468)](https://packagist.org/packages/68publishers/oauth)[![PHP Version](https://camo.githubusercontent.com/89f2816b88a1301b087f3d5ac462fb487e89c9f1950088b5898b6377b9ef7b94/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f7068702f36387075626c6973686572732f6f61757468)](https://packagist.org/packages/68publishers/oauth)

Installation
------------

[](#installation)

```
$ composer require 68publishers/oauth
```

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

[](#configuration)

### Facebook

[](#facebook)

```
$ composer require league/oauth2-facebook
```

```
extensions:
    68publishers.oauth: SixtyEightPublishers\OAuth\Bridge\Nette\DI\OAuthExtension
    68publishers.facebook: SixtyEightPublishers\OAuth\Bridge\Nette\DI\FacebookOAuthExtension

68publishers.facebook:
    flowName: facebook # default, not necessary to define
    config:
        enabled: true # default, not necessary to define
        clientId: ''
        clientSecret: ''
        graphApiVersion: ''
        options: [] # additional options that are passed into the client
    authenticator: App\OAuth\FacebookAuthenticator
```

### Azure

[](#azure)

```
$ composer require thenetworg/oauth2-azure
```

```
extensions:
    68publishers.oauth: SixtyEightPublishers\OAuth\Bridge\Nette\DI\OAuthExtension
    68publishers.azure: SixtyEightPublishers\OAuth\Bridge\Nette\DI\FacebookOAuthExtension

68publishers.azure:
    flowName: azure # default, not necessary to define
    config:
        enabled: true # default, not necessary to define
        clientId: ''
        clientSecret: ''
        tenantId: '' # optional, use this option only if your Azure Entra ID application is configured as a single tenant.
        options: [] # additional options that are passed into the client
    authenticator: App\OAuth\AzureAuthenticator
```

Integration
-----------

[](#integration)

### Lazy configuration

[](#lazy-configuration)

Sometimes it may be desirable to provide the configuration for an OAuth client dynamically if, for example, we have settings stored in a database. We can do this with the following implementation:

```
namespace App\OAuth\Config;

use SixtyEightPublishers\OAuth\Config\Config;
use SixtyEightPublishers\OAuth\Config\LazyConfig;
use App\SettingsProvider;

final class AzureConfig extends LazyConfig
{
    public function __construct(SettingsProvider $provider) {
        parent::__construct(
            configFactory: static function (): Config {
                return new Config(
                    flowEnabled: $provider->get('azure.enabled'),
                    options: [
                        'clientId' => $provider->get('azure.clientId'),
                        'clientSecret' => $provider->get('azure.clientSecret'),
                    ],
                );
            }
        );
    }
}
```

```
# ...

68publishers.azure:
    config: App\OAuth\Config\AzureConfig

# ...
```

### Implementing Authenticator

[](#implementing-authenticator)

Authenticator is a class implementing the `AuthenticatorInterface` interface. This class should return the identity of the user and throw an `AuthenticationException` exception in case of any problem.

```
namespace App\OAuth;

use SixtyEightPublishers\OAuth\Authentication\AuthenticatorInterface;
use SixtyEightPublishers\OAuth\Exception\AuthenticationException;
use SixtyEightPublishers\OAuth\Authorization\AuthorizationResult;
use Nette\Security\IIdentity;
use Nette\Security\SimpleIdentity;

final class AzureAuthenticator implements AuthenticatorInterface
{
    public function authenticate(string $flowName, AuthorizationResult $authorizationResult): IIdentity
    {
        $accessToken = $authorizationResult->accessToken;
        $resourceOwner = $authorizationResult->resourceOwner;

        if ($userCannotBeAuthenticated) {
            throw new AuthenticationException('User can not be authenticated.');
        }

        return new SimpleIdentity(/* ... */);
    }
}
```

### Implementing OAuth Presenter

[](#implementing-oauth-presenter)

The `OAuthPresenterTrait` trait is used for simple implementation. Next, you need to define three methods that determine what should happen if the authentication is successful or fails. All three methods should redirect at the end.

```
namespace App\Presenter;

use Nette\Application\UI\Presenter;
use SixtyEightPublishers\OAuth\Bridge\Nette\Application\OAuthPresenterTrait;
use SixtyEightPublishers\OAuth\Exception\OAuthExceptionInterface;

final class OAuthPresenter extends Presenter
{
    use OAuthPresenterTrait;

    protected function onAuthorizationRedirectFailed(string $flowName, OAuthExceptionInterface $error): void
    {
        $this->flashMessage('Authentication failed', 'error');
        $this->redirect('SignIn:');
    }

    abstract protected function onAuthenticationFailed(string $flowName, OAuthExceptionInterface $error): void
    {
        $this->flashMessage('Authentication failed', 'error');
        $this->redirect('SignIn:');
    }

    abstract protected function onUserAuthenticated(string $flowName): void
    {
        $this->flashMessage('You have been successfully logged in', 'success');
        $this->redirect('Homepage:');
    }
}
```

### Login button

[](#login-button)

The login button can be rendered simply as follows

```
Login via Azure
```

If you store the request (back link) using `Presenter::storeRequest()` you can also pass it the URL. Your `OAuthPresenter` will then automatically redirect to this link after successful authentication.

```
Login via Azure
```

License
-------

[](#license)

The package is distributed under the MIT License. See [LICENSE](LICENSE.md) for more information.

###  Health Score

36

—

LowBetter than 81% of packages

Maintenance57

Moderate activity, may be stable

Popularity19

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

###  Release Activity

Cadence

Every ~511 days

Total

2

Last Release

320d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/609005caba54757716c3c037c381376ab298714003da87c9e20aa8c501c97df8?d=identicon)[Jelen](/maintainers/Jelen)

---

Top Contributors

[![tg666](https://avatars.githubusercontent.com/u/24430186?v=4)](https://github.com/tg666 "tg666 (6 commits)")

---

Tags

netteoauthazure68publishers

###  Code Quality

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/68publishers-oauth/health.svg)

```
[![Health](https://phpackages.com/badges/68publishers-oauth/health.svg)](https://phpackages.com/packages/68publishers-oauth)
```

###  Alternatives

[thenetworg/oauth2-azure

Azure Active Directory OAuth 2.0 Client Provider for The PHP League OAuth2-Client

2509.6M47](/packages/thenetworg-oauth2-azure)

PHPackages © 2026

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