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

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

lampask/oauth
=============

OAuth integration into Nette Framework

01PHP

Since Jul 18Pushed 1y agoCompare

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

READMEChangelogDependenciesVersions (1)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

14

—

LowBetter than 2% of packages

Maintenance27

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity18

Early-stage or recently created project

 Bus Factor1

Top contributor holds 66.7% 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/7f626634204fd2db109631dde0c6619a88586cf97192b07a46e23891d8bb76a3?d=identicon)[lampask](/maintainers/lampask)

---

Top Contributors

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

### Embed Badge

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

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

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[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)[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

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

PHPackages © 2026

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