PHPackages                             yayasanvitka/azure-oauth2-validator - 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. yayasanvitka/azure-oauth2-validator

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

yayasanvitka/azure-oauth2-validator
===================================

Validates JWT from Azure OAuth2

v4.1.1(1mo ago)0530MITPHPPHP ^8.3CI failing

Since Oct 5Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/yayasanvitka/azure-oauth2-validator)[ Packagist](https://packagist.org/packages/yayasanvitka/azure-oauth2-validator)[ RSS](/packages/yayasanvitka-azure-oauth2-validator/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (16)Versions (17)Used By (0)

Azure OAuth 2 JWT Validator for Laravel
=======================================

[](#azure-oauth-2-jwt-validator-for-laravel)

[![License: MIT](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](https://opensource.org/licenses/MIT)[![GitHub Workflow Status (event)](https://camo.githubusercontent.com/44206c01e2f1c982fa89be8e00e8039ebf86b9acec7c817831232e737e369f10/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7961796173616e7669746b612f617a7572652d6f61757468322d76616c696461746f722f504850556e69742532305465737473)](https://camo.githubusercontent.com/44206c01e2f1c982fa89be8e00e8039ebf86b9acec7c817831232e737e369f10/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7961796173616e7669746b612f617a7572652d6f61757468322d76616c696461746f722f504850556e69742532305465737473)[![PHP Version](https://camo.githubusercontent.com/49c15fb09d47a34e5ab0d1699a5f6204ff31099717ae986df6135ff875ed4812/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f7068702f7961796173616e7669746b612f617a7572652d6f61757468322d76616c696461746f72)](https://www.php.net/releases/8.0/en.php)[![Latest release](https://camo.githubusercontent.com/5cb897da828c56ca3dfa20408934bde95f5dfcd083467060fe73c9dc6e6b93fe/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f762f7961796173616e7669746b612f617a7572652d6f61757468322d76616c696461746f72)](https://github.com/yayasanvitka/azure-oauth2-validator)[![codecov](https://camo.githubusercontent.com/f65065ee74b851a5171c8c9cd731d58ea3ba08e8d6b888339f2afe561c1373a5/68747470733a2f2f62616467656e2e6e65742f636f6465636f762f632f6769746875622f7961796173616e7669746b612f617a7572652d6f61757468322d76616c696461746f723f746f6b656e3d5151464b524139594138)](https://codecov.io/gh/yayasanvitka/azure-oauth2-validator)

About
-----

[](#about)

This package does OAuth2 token validation. **For now, it only validates client credentials**.

Documentation, Installation, and Usage Instructions
---------------------------------------------------

[](#documentation-installation-and-usage-instructions)

### Installation

[](#installation)

#### 1. Install the Package

[](#1-install-the-package)

Run the following command to install the package:

```
composer require yayasanvitka/azure-oauth2-validator
composer require rootinc/laravel-azure-middleware
```

#### 2. Publish the Package

[](#2-publish-the-package)

Run the following command to publish the package:

```
php artisan vendor:publish --provider="Yayasanvitka\AzureOauth2Validator\AzureOauth2ValidatorServiceProvider"
```

Then run command below to migrate published table.

```
php artisan migrate
```

#### 3. Add Configurations to Database Seeder

[](#3-add-configurations-to-database-seeder)

Add the following array to `Database/Seeders/ConfigTableSeeder@SettingList`:

```
[
    'key' => 'system.employee.allowed_domains',
    'name' => 'Allowed domain to login',
    'description' => '',
    'value' => '[{"domain":"btp.ac.id"},{"domain":"iteba.ac.id"},{"domain":"yayasanvitka.id"}]',
    'field' => '{"name":"value","label":"Value","type":"repeatable","fields":[{"name":"domain","type":"text","label":"Domain"}]}',
    'active' => 1,
    'created_at' => now('Asia/Jakarta'),
    'updated_at' => now('Asia/Jakarta'),
],
[
    'key' => 'azure.client.id',
    'name' => 'Azure OAuth2 Application (client) ID (UUID)',
    'description' => 'Application (client) ID (UUID) for Azure Authentication',
    'value' => '',
    'field' => '{"name":"value","label":"Azure OAuth2 Application (client) ID","type":"text"}',
    'active' => 1,
    'created_at' => now('Asia/Jakarta'),
    'updated_at' => now('Asia/Jakarta'),
],
[
    'key' => 'azure.client.secret',
    'name' => 'Azure OAuth2 Application (client) Secret',
    'description' => 'Application (client) Secret for Azure Authentication',
    'value' => '',
    'field' => '{"name":"value","label":"Azure OAuth2 Application (client) Secret","type":"text"}',
    'active' => 1,
    'created_at' => now('Asia/Jakarta'),
    'updated_at' => now('Asia/Jakarta'),
],
[
    'key' => 'azure.tenant_id',
    'name' => 'Directory (tenant) ID (UUID)',
    'description' => 'Directory (tenant) ID (UUID) for Azure Authentication',
    'value' => '',
    'field' => '{"name":"value","label":"Directory (tenant) ID","type":"text"}',
    'active' => 1,
    'created_at' => now('Asia/Jakarta'),
    'updated_at' => now('Asia/Jakarta'),
],
[
    'key' => 'azure.resource',
    'name' => 'Azure OAuth2 Resource',
    'description' => 'Valid resource to authenticate to Azure',
    'value' => '',
    'field' => '{"name":"value","label":"Resource","type":"text"}',
    'active' => 1,
    'created_at' => now('Asia/Jakarta'),
    'updated_at' => now('Asia/Jakarta'),
],
[
    'key' => 'azure.scope',
    'name' => 'Azure OAuth2 Scope',
    'description' => 'Valid scope to authenticate to Azure',
    'value' => '',
    'field' => '{"name":"value","label":"Scope","type":"text"}',
    'active' => 1,
    'created_at' => now('Asia/Jakarta'),
    'updated_at' => now('Asia/Jakarta'),
]
```

Then run command below to seed the new configuration.

```
php artisan db:seed --class=ConfigTableSeeder
```

And dont forget to register the azure config at `App\Providers\ConfigServiceProvider@overrideConfigValues`

> **Note:** You may need to log in to the app as a sysadmin (non-Microsoft account) first to ensure the config is loaded.

#### 4. Add Routes for Azure Authentication

[](#4-add-routes-for-azure-authentication)

Add the following routes to `routes/azure.php`:

```
