PHPackages                             eyerim/oauth2-azure-bundle - 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. eyerim/oauth2-azure-bundle

ActiveSymfony-bundle[Authentication &amp; Authorization](/categories/authentication)

eyerim/oauth2-azure-bundle
==========================

This bundle provides a tiny wrapper for using thenetworg/oauth2-azure inside Symfony.

011.0k↓41.3%PHP

Since May 29Pushed 1y agoCompare

[ Source](https://github.com/eyerim/oauth2_azure_bundle)[ Packagist](https://packagist.org/packages/eyerim/oauth2-azure-bundle)[ RSS](/packages/eyerim-oauth2-azure-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

OAuth 2.0 for Azure Bundle
==========================

[](#oauth-20-for-azure-bundle)

[![Latest Stable Version](https://camo.githubusercontent.com/d5a126fa5035d3ce6f7d272a81fd5cbf9a65c0eb02c710d648a2efc43199e9d8/68747470733a2f2f706f7365722e707567782e6f72672f6d346e35306e2f6f61757468322d617a7572652d62756e646c652f762f737461626c65)](https://packagist.org/packages/m4n50n/oauth2-azure-bundle)[![License](https://camo.githubusercontent.com/34b76e07027cda06711cbe1befae275a1b3b06ecf7f191e6908575bc4e020283/68747470733a2f2f706f7365722e707567782e6f72672f6d346e35306e2f6f61757468322d617a7572652d62756e646c652f6c6963656e7365)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/28053df7b74f32c54a91ddefd198110480cf1ff9baec97a96bab58025637dfde/68747470733a2f2f706f7365722e707567782e6f72672f6d346e35306e2f6f61757468322d617a7572652d62756e646c652f646f776e6c6f616473)](https://packagist.org/packages/m4n50n/oauth2-azure-bundle)

This Symfony bundle serves as a tiny wrapper for the [Azure Active Directory Provider for OAuth 2.0 Client](https://github.com/TheNetworg/oauth2-azure). You can find additional documentation in the official repository.

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

[](#installation)

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

```
symfony composer require m4n50n/oauth2-azure-bundle

```

### Enable the Bundle

[](#enable-the-bundle)

Enable the bundle by adding it to the list of registered bundles in the `config/bundles.php` file of your project.

```
// config/bundles.php

return [
    // ...
    M4n50n\OAuth2AzureBundle\OAuth2AzureBundle::class => ['all' => true],
];
```

Configure the Bundle
--------------------

[](#configure-the-bundle)

Configure the bundle in the `config/packages/oauth2_azure.yaml` file:

```
# config/packages/oauth2_azure.yaml

o_auth2_azure:
  clientId: "%env(AUTH_CLIEN_ID)%"
  clientSecret: "%env(AUTH_CLIENT_PASS)%"
  tenant: "%env(AUTH_TENANT)%"
  redirectUri: "%env(AUTH_REDIRECT_URI)%"

  # Optional
  redirectToUrl: "%env(bool:AUTH_REDIRECT_TO_URL)%" # Activate redirect after authentication
  redirectUrl: "%env(AUTH_REDIRECT_URL)%" # URL to redirect after authentication
```

```
# .env

AUTH_CLIEN_ID="c3db02f0-401c-452c......"
AUTH_CLIENT_PASS="LfR8Q~yTXB5ozRejLrqE6oYqp......"
AUTH_TENANT="5fa120f8-1ee1-49e3-9b......"
AUTH_REDIRECT_URI="https://endpoint.com/api/login/azure"
AUTH_REDIRECT_TO_URL=true
AUTH_REDIRECT_URL="https://endpoint-client.com"
```

If you want the configuration / environment files to be created automatically inside your `/config` folder, you can include my private *Symfony Flex* recipes repository in your `composer.json` by adding the following configuration:

```
"extra": {
  "symfony": {
      "endpoint": [
          "https://api.github.com/repos/m4n50n/symfony_flex_recipes/contents/index.json",
          "flex://defaults"
      ]
  }
}
```

Usage
-----

[](#usage)

Inject ***OAuth2AzureFactory*** into your Service or Controller, and call the *getAuth()* method with *Request* as an argument.

If the *redirectToUrl* configuration parameter exists and has a *true* value, it will be redirected to the *redirectUrl* set after authentication. Otherwise, an ***AuthResponse*** object will be returned, containing the getOwnerData() method, which returns the data of the Azure-authenticated account.

```
use M4n50n\OAuth2AzureBundle\Factory\OAuth2AzureFactory;

final class LoginController extends AbstractController
{
    public function __construct(private OAuth2AzureFactory $OAuth2AzureFactory)
    {
    }

    #[Route(path: '/login/azure', name: 'login_azure', methods: ['GET'])]
    public function user_azureLoginRequest(JWTTokenManagerInterface $JWTManager, UserPasswordHasherInterface $userPasswordHasher)
    {
        try {
            // ...

            $auth = $this->OAuth2AzureFactory->getAuth($this->request);
            $ownerData = $auth->getOwnerData();

            /* It returns an array with the following structure:

            $ownerData = [
                "aud" => "c3db02f0-401c-452c......",
                "iss" => "https://login.microsoftonline.com/....../v2.0",
                "iat" => 1360114,
                "profileImage" => "", // base64_encode of the image binary
                "email":"josegarciarodriguez89@hotmail.com",
                "name":"Jose Garcia",

                // ... (other fields)
            ];
            */

            // ...
        } catch (\Exception $exception) {
            // ...
        }

        // ...
    }
}
```

### Methods

[](#methods)

This wrapper defines the following methods:

- Class `OAuth2AzureFactory`: `getAuth()` starts the user authentication flow.
- Class `OAuth2AzureFactory`: `getConfig()` returns the entire bundle configuration object.
- Class `AuthResponse`: `isError()` returns if there has been an error in the authentication process.

Contributing
------------

[](#contributing)

See [CONTRIBUTING](CONTRIBUTING.md) for more information.

Security
--------

[](#security)

See [SECURITY](SECURITY.md) for more information.

License
-------

[](#license)

Please see the [LICENSE](LICENSE) included in this repository for a full copy of the MIT license, which this project is licensed under.

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance26

Infrequent updates — may be unmaintained

Popularity25

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/3bd77ea71fe4c8637a294ce8747bdf29327361aa10f8f6320b33f16da2fbfc90?d=identicon)[eyeskiller](/maintainers/eyeskiller)

---

Top Contributors

[![m4n50n](https://avatars.githubusercontent.com/u/92524023?v=4)](https://github.com/m4n50n "m4n50n (2 commits)")[![eyeskiller](https://avatars.githubusercontent.com/u/5360190?v=4)](https://github.com/eyeskiller "eyeskiller (1 commits)")

### Embed Badge

![Health badge](/badges/eyerim-oauth2-azure-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/eyerim-oauth2-azure-bundle/health.svg)](https://phpackages.com/packages/eyerim-oauth2-azure-bundle)
```

###  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)
