PHPackages                             oshco/adfs - 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. [API Development](/categories/api)
4. /
5. oshco/adfs

ActiveLibrary[API Development](/categories/api)

oshco/adfs
==========

Library to provide ADFS integration for WebFiori based applications.

v2.0.2(2w ago)01.7kMITPHPCI passing

Since Oct 17Pushed 2w ago1 watchersCompare

[ Source](https://github.com/OSHCO/adfs)[ Packagist](https://packagist.org/packages/oshco/adfs)[ RSS](/packages/oshco-adfs/feed)WikiDiscussions main Synced today

READMEChangelog (8)Dependencies (14)Versions (11)Used By (0)

ADFS Integration for WebFiori
=============================

[](#adfs-integration-for-webfiori)

A PHP library that provides ADFS (Active Directory Federation Services) single sign-on integration for [WebFiori](https://webfiori.com) based applications using SAML 2.0.

Requirements
------------

[](#requirements)

- PHP 8.1 or later
- [WebFiori HTTP](https://github.com/WebFiori/http) 5.0+
- [WebFiori UI](https://github.com/WebFiori/ui) 4.0+
- [WebFiori File](https://github.com/WebFiori/file) 2.0+
- [WebFiori JsonX](https://github.com/WebFiori/jsonx) 4.0+

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

[](#installation)

```
composer require oshco/adfs
```

How It Works
------------

[](#how-it-works)

1. Your application builds a SAML request using `SAMLRequest` and redirects the user to the ADFS server.
2. The user authenticates on the ADFS login page.
3. ADFS posts a SAML response back to your application's callback endpoint.
4. Your `ADFSVerificationService` subclass parses the response, looks up the user, and handles success or failure.

Classes
-------

[](#classes)

Class / InterfaceDescription[`ADFSUser`](Oshco/Adfs/ADFSUser.php)Interface representing an authenticated user. Requires `getId()`.[`SAMLRequest`](Oshco/Adfs/SAMLRequest.php)Builds a SAML 2.0 authentication request. Supports XML generation and base64+deflate encoding for HTTP-Redirect binding.[`ADFSResponse`](Oshco/Adfs/ADFSResponse.php)Parses a base64-encoded SAML response from ADFS. Extracts success/failure status, username, and application name.[`ADFSVerificationService`](Oshco/Adfs/ADFSVerificationService.php)Abstract web service that acts as the ADFS callback endpoint. Subclass it to implement `getUser()` and `onSuccess()`.Usage
-----

[](#usage)

### 1. Implement the `ADFSUser` interface

[](#1-implement-the-adfsuser-interface)

```
use Oshco\Adfs\ADFSUser;

class AppUser implements ADFSUser {
    private int $id;
    private string $email;

    public function __construct(int $id, string $email) {
        $this->id = $id;
        $this->email = $email;
    }

    public function getId() {
        return $this->id;
    }
}
```

### 2. Build and send a SAML request

[](#2-build-and-send-a-saml-request)

```
use Oshco\Adfs\SAMLRequest;

$request = new SAMLRequest();
$request->setDestination('https://adfs.example.com/adfs/ls');
$request->setAppID('My Application');
$request->setAppURL('https://myapp.example.com');
$request->setIssueInstant(gmdate('Y-m-d\TH:i:s\Z'));

$encoded = $request->encode();

// Redirect user to ADFS with the encoded SAML request
header('Location: https://adfs.example.com/adfs/ls?SAMLRequest=' . urlencode($encoded));
```

### 3. Create a verification service

[](#3-create-a-verification-service)

Extend `ADFSVerificationService` and implement the two abstract methods:

```
use Oshco\Adfs\ADFSUser;
use Oshco\Adfs\ADFSVerificationService;

class MyVerificationService extends ADFSVerificationService {

    public function __construct() {
        parent::__construct('adfs-verify', 'https://myapp.example.com/login-failed');
    }

    public function getUser(string $username): ?ADFSUser {
        // Look up the user in your database by username/email
        // Return an ADFSUser instance or null if not found
    }

    public function onSuccess(ADFSUser $user) {
        // User authenticated successfully
        // Set session, redirect to dashboard, etc.
    }
}
```

When ADFS posts back to your endpoint, the service will:

- Parse the SAML response
- Call `getUser()` with the authenticated username
- Call `onSuccess()` if the user is found, or `onFail()` if not (redirects to the fail URL with a `?status=` parameter)

### 4. Inspect the SAML response

[](#4-inspect-the-saml-response)

```
use Oshco\Adfs\ADFSResponse;

$response = new ADFSResponse($_POST['SAMLResponse']);

$response->isSuccess();    // true if ADFS authentication succeeded
$response->getUserName();  // authenticated username (lowercased)
$response->getAppName();   // application name from ADFS
$response->getXMLString(); // raw XML of the SAML response
$response->storeResponse(); // save response to file for debugging
```

Running Tests
-------------

[](#running-tests)

```
composer test
```

Maintainer
----------

[](#maintainer)

- Ibrahim BinAlshikh ()

License
-------

[](#license)

This library is licensed under the [MIT License](LICENSE).

Copyright (c) 2023 Olayan Saudi Holding Company (OSHCO)

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance96

Actively maintained with recent releases

Popularity20

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.3% 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 ~138 days

Recently: every ~61 days

Total

8

Last Release

19d ago

Major Versions

v1.3.0 → v2.0.02026-05-12

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/92792203?v=4)[Olayan Saudi Holding Company (OSHCO)](/maintainers/oshco)[@OSHCO](https://github.com/OSHCO)

---

Top Contributors

[![usernane](https://avatars.githubusercontent.com/u/12120015?v=4)](https://github.com/usernane "usernane (42 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (3 commits)")

---

Tags

apiadfswebfioriWeb APIs

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/oshco-adfs/health.svg)

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

###  Alternatives

[webfiori/framework

WebFiori framework. Made to make the web bloom.

2123.0k11](/packages/webfiori-framework)[m165437/laravel-blueprint-docs

API Blueprint Renderer for Laravel

22879.8k](/packages/m165437-laravel-blueprint-docs)

PHPackages © 2026

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