Skip to content

Commit ed937ae

Browse files
Update README.md
Signed-off-by: LUIZ HAMILTON ROBERTO DA SILVA <[email protected]>
1 parent c18d1d7 commit ed937ae

1 file changed

Lines changed: 87 additions & 52 deletions

File tree

  • SysAdmin-Tools/ActiveDirectory-SSO-Integrations/PHP-API
Lines changed: 87 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,62 @@
11
# 🔹 PHP-API: Active Directory SSO Integration
22

3+
![PHP](https://img.shields.io/badge/PHP-8.0+-777BB4?style=for-the-badge&logo=php&logoColor=white)
4+
![LDAP](https://img.shields.io/badge/Auth-LDAP%20%7C%20AD-0A66C2?style=for-the-badge)
5+
![SSO](https://img.shields.io/badge/SSO-Active%20Directory-2E7D32?style=for-the-badge)
6+
![Security](https://img.shields.io/badge/Security-Enterprise--Grade-4CAF50?style=for-the-badge)
7+
38
## 📌 Overview
49

5-
The **PHP-API** module implements **LDAP-based Single Sign-On (SSO)** with **Active Directory**, designed to work across an entire AD forest via **Global Catalog (GC)**.
6-
It offers a lightweight, secure, and standardized approach to authenticating users via AD in legacy or modern PHP environments.
10+
The **PHP-API** module implements **LDAP-based Single Sign-On (SSO)** with **Active Directory**, designed to operate across an **entire AD forest** using the **Global Catalog (GC)**.
11+
12+
It provides a **lightweight, auditable, and secure authentication layer** for both **legacy and modern PHP applications**, following the same security and design principles used across the **Windows-SysAdmin-ProSuite**.
13+
14+
This integration is ideal for environments where:
15+
- IIS/Apache-based applications still rely on PHP
16+
- Forest-wide authentication is required
17+
- Minimal privileges and predictable behavior are mandatory
718

819
---
920

1021
## 📁 Folder Structure
1122

12-
```
23+
```text
1324
ActiveDirectory-SSO-Integrations/
1425
15-
├── 📂 PHP-API/ # Parent folder for PHP API integration
16-
│ ├── 📂 public/ # Publicly accessible endpoints
17-
│ │ ├── 📜 index.php # Entry point with SSO detection via $_SERVER['REMOTE_USER']
18-
│ │ ├── 📜 login.php # Manual login fallback
19-
│ │ ├── 📜 dashboard.php # Protected user dashboard
20-
│ │ └── 📜 logout.php # Destroys session and logs out
21-
22-
│ ├── 📂 config/ # Configuration and LDAP logic
23-
│ │ ├── 📜 env.php # Loads .env credentials into runtime
24-
│ │ └── 📜 ldap.php # Handles LDAP connection and authentication
25-
26-
│ ├── 📜 .env.example # Example file for LDAP credentials
27-
│ ├── 📜 composer.json # Project dependencies
28-
│ └── 📜 README.md # Documentation for PHP-API integration
26+
├── PHP-API/
27+
│ ├── public/
28+
│ │ ├── index.php # Entry point with SSO auto-detection
29+
│ │ ├── login.php # Manual login fallback
30+
│ │ ├── dashboard.php # Protected resource
31+
│ │ └── logout.php # Session termination
32+
33+
│ ├── config/
34+
│ │ ├── env.php # Loads environment variables
35+
│ │ └── ldap.php # LDAP bind and authentication logic
36+
37+
│ ├── .env.example # Environment template
38+
│ ├── composer.json # Dependency definitions
39+
│ └── README.md # Module documentation
2940
```
3041

3142
---
3243

3344
## 🛠️ Prerequisites
3445

35-
- **PHP 8.0+**
36-
- **OpenLDAP or Active Directory** with Global Catalog enabled
37-
- **Apache/Nginx with PHP support**
38-
- **Composer (dependency manager)**
46+
- **PHP 8.0 or later**
47+
- **Active Directory** with **Global Catalog enabled**
48+
- **Apache or Nginx** with PHP support
49+
- **Composer** (dependency manager)
50+
- PHP extensions:
51+
- `ldap`
52+
- `mbstring`
53+
- `openssl`
3954

4055
---
4156

4257
## ⚙️ Configuration
4358

44-
Edit `.env` file with your AD service account and forest-wide settings:
59+
Create a `.env` file based on `.env.example`:
4560

4661
```env
4762
LDAP_URL=ldap://ldap.headq.scriptguy:3268
@@ -50,56 +65,74 @@ LDAP_USERNAME=ad-sso-authentication@scriptguy
5065
LDAP_PASSWORD=YourSecurePassword
5166
```
5267

53-
Load it in runtime using `env.php` with `vlucas/phpdotenv` support.
68+
The configuration is loaded at runtime via `vlucas/phpdotenv`.
69+
70+
> 🔐 **Best Practice**:
71+
> The LDAP bind account must be **read-only**, non-interactive, and excluded from application logon.
5472
5573
---
5674

5775
## 🚀 How to Run
5876

59-
1. **Clone the repository:**
60-
```bash
61-
git clone https://github.com/brazilianscriptguy/Windows-SysAdmin-ProSuite.git
62-
cd Windows-SysAdmin-ProSuite/SysAdmin-Tools/ActiveDirectory-SSO-Integrations/PHP-API
63-
```
77+
1. **Clone the repository**
78+
```bash
79+
git clone https://github.com/brazilianscriptguy/Windows-SysAdmin-ProSuite.git
80+
cd Windows-SysAdmin-ProSuite/SysAdmin-Tools/ActiveDirectory-SSO-Integrations/PHP-API
81+
```
6482

65-
2. **Create your environment file:**
66-
```bash
67-
cp .env.example .env
68-
```
83+
2. **Create environment file**
84+
```bash
85+
cp .env.example .env
86+
```
6987

70-
3. **Install dependencies with Composer:**
71-
```bash
72-
composer install
73-
```
88+
3. **Install dependencies**
89+
```bash
90+
composer install
91+
```
92+
93+
4. **Start development server**
94+
```bash
95+
php -S localhost:8000 -t public
96+
```
7497

75-
4. **Run the development server:**
76-
```bash
77-
php -S localhost:8000 -t public
78-
```
98+
Access the application at:
99+
`http://localhost:8000`
79100

80101
---
81102

82-
## 🔐 LDAP Authentication Highlights
103+
## 🔐 LDAP Authentication Design
83104

84-
- Forest-wide querying using **Global Catalog (port 3268)**
85-
- **inetOrgPerson accounts are explicitly blocked** from logging in
86-
- **Account enable/disable status is ignored** (AD handles that)
87-
- Service account does not require elevated privileges (read-only)
105+
- Forest-wide authentication via **Global Catalog (TCP 3268)**
106+
- Explicit block of **service / inetOrgPerson accounts**
107+
- No password caching
108+
- No elevated directory permissions required
109+
- All validation handled server-side
88110

89111
---
90112

91-
## 💻 Sample Authentication Flow
113+
## 🔄 Authentication Flow
92114

93115
1. User accesses `index.php`
94-
2. If `$_SERVER['REMOTE_USER']` is available, SSO proceeds
95-
3. If not, fallback to `login.php` for manual credential input
96-
4. Authenticated users redirected to `dashboard.php`
116+
2. If `$_SERVER['REMOTE_USER']` exists → automatic SSO
117+
3. Otherwise → fallback to `login.php`
118+
4. Credentials validated against AD
119+
5. Authorized users redirected to `dashboard.php`
120+
6. Sessions destroyed via `logout.php`
121+
122+
---
123+
124+
## 🔒 Security Notes
125+
126+
- No credentials stored in code or logs
127+
- Environment-based secret management
128+
- Compatible with reverse proxies and IIS rewrite rules
129+
- Safe for intranet and DMZ deployments
97130

98131
---
99132

100133
## 📜 License
101134

102-
[![MIT License](https://img.shields.io/badge/License-MIT-blue.svg?style=for-the-badge)](https://github.com/brazilianscriptguy/Windows-SysAdmin-ProSuite/blob/main/.github/LICENSE.txt)
135+
[![MIT License](https://img.shields.io/badge/License-MIT-blue?style=for-the-badge)](https://github.com/brazilianscriptguy/Windows-SysAdmin-ProSuite/blob/main/.github/LICENSE.txt)
103136

104137
---
105138

@@ -111,9 +144,11 @@ Load it in runtime using `env.php` with `vlucas/phpdotenv` support.
111144

112145
## 📩 Support
113146

114-
[![Email Badge](https://img.shields.io/badge/[email protected]?style=for-the-badge&logo=gmail)](mailto:[email protected])
147+
[![Email](https://img.shields.io/badge/[email protected]?style=for-the-badge&logo=gmail)](mailto:[email protected])
115148
[![GitHub Issues](https://img.shields.io/badge/GitHub%20Issues-Report%20Here-blue?style=for-the-badge&logo=github)](https://github.com/brazilianscriptguy/Windows-SysAdmin-ProSuite/blob/main/.github/BUG_REPORT.md)
116149

117150
---
118151

119-
<p align="center">🌐 <strong>Bring AD SSO to your PHP apps — Fast and Secure!</strong> 🔒</p>
152+
<p align="center">🌐 <strong>Enterprise‑grade AD SSO for PHP applications</strong> 🔒</p>
153+
154+
© 2026 Luiz Hamilton Silva. All rights reserved.

0 commit comments

Comments
 (0)