PHPackages                             aslnbxrz/oneid - 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. aslnbxrz/oneid

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

aslnbxrz/oneid
==============

Professional OneID integration package for Laravel - Uzbekistan's unified identification system

v1.0.4(7mo ago)114MITPHPPHP ^8.2|^8.3|^8.4CI passing

Since Sep 27Pushed 7mo agoCompare

[ Source](https://github.com/aslnbxrz/oneid)[ Packagist](https://packagist.org/packages/aslnbxrz/oneid)[ Docs](https://github.com/aslnbxrz/oneid)[ GitHub Sponsors](https://github.com/sponsors/aslnbxrz)[ RSS](/packages/aslnbxrz-oneid/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (13)Versions (5)Used By (0)

OneID Laravel Package
=====================

[](#oneid-laravel-package)

[![Latest Version on Packagist](https://camo.githubusercontent.com/056cde5ea495dcbf71babe6303d1d94618cc4f00cbb875c63ef9af56d2f2cbd3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f61736c6e6278727a2f6f6e6569642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/aslnbxrz/oneid)[![Total Downloads](https://camo.githubusercontent.com/ee52f5f51ff73062dfb5a36a79c6b50c3dfd8931d1fcc590fcc1a170e83d1206/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f61736c6e6278727a2f6f6e6569642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/aslnbxrz/oneid)[![GitHub Tests Action Status](https://camo.githubusercontent.com/1d8cb9df91f54ef8b9dea16044668bb3657becd3827ca1d763e873d0aa11b6d5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f61736c6e6278727a2f6f6e6569642f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/aslnbxrz/oneid/actions)[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)

Professional Laravel package for integrating with **OneID** - Uzbekistan's unified identification system (Yagona identifikatsiya tizimi). This package provides a clean, secure, and easy-to-use interface for OneID authentication in Laravel applications.

🚀 Features
----------

[](#-features)

- **Easy Integration**: Simple setup and configuration
- **Flexible Routes**: Use built-in routes or create your own
- **Facade Support**: Clean facade interface for easy usage
- **Comprehensive Configuration**: Extensive configuration options
- **Error Handling**: Robust error handling and logging
- **Security**: Built-in security features and validation
- **Laravel 10+ Support**: Compatible with modern Laravel versions
- **Testing**: Comprehensive test suite included

📋 Requirements
--------------

[](#-requirements)

- PHP 8.2 or higher
- Laravel 10.0 or higher
- Valid OneID application credentials

📦 Installation
--------------

[](#-installation)

You can install the package via Composer:

```
composer require aslnbxrz/oneid
```

⚙️ Configuration
----------------

[](#️-configuration)

### 1. Publish Configuration

[](#1-publish-configuration)

Publish the configuration file:

```
php artisan vendor:publish --provider="Aslnbxrz\OneId\OneIdServiceProvider" --tag="oneid-config"
```

### 2. Environment Variables

[](#2-environment-variables)

Add the following environment variables to your `.env` file:

```
# OneID Configuration
ONEID_BASE_URL=https://sso.egov.uz
ONEID_CLIENT_ID=your_client_id
ONEID_CLIENT_SECRET=your_client_secret
ONEID_SCOPE=openid profile
ONEID_REDIRECT_URI=https://your-app.com/auth/oneid/callback

# Optional: Route Configuration
ONEID_ROUTES_ENABLED=true
ONEID_ROUTE_PREFIX=auth/oneid
ONEID_ROUTE_MIDDLEWARE=web

# Optional: Logging Configuration
ONEID_LOGGING_ENABLED=true
ONEID_LOG_LEVEL=info
ONEID_LOG_CHANNEL=default

# Optional: Security Configuration
ONEID_VERIFY_SSL=true
ONEID_RATE_LIMITING_ENABLED=true
ONEID_RATE_LIMIT_ATTEMPTS=5
ONEID_RATE_LIMIT_DECAY=1
```

### 3. OneID Application Setup

[](#3-oneid-application-setup)

1. Register your application at [OneID Portal](https://sso.egov.uz)
2. Get your `client_id` and `client_secret`
3. Set up your redirect URI to match your application

🎯 Usage
-------

[](#-usage)

### Using Facade (Recommended)

[](#using-facade-recommended)

```
use Aslnbxrz\OneId\Facades\OneID;

// Generate authorization URL
$authUrl = OneID::getAuthorizationUrl();

// Handle authentication callback
$result = OneID::handle($code);

// Check if authentication was successful
if ($result->success) {
    $userData = $result->getUserData();

    // Basic user information
    $pin = $userData->pin;
    $firstName = $userData->first_name;
    $lastName = $userData->sur_name;
    $middleName = $userData->mid_name;
    $fullName = $userData->getFullName();

    // Additional information
    $isVerified = $userData->isVerified();
    $userType = $userData->user_type; // 'I' for Individual, 'L' for Legal
    $authMethod = $userData->getAuthMethodName();
    $birthDate = $userData->getBirthDate();

    // Legal entity information (if applicable)
    if ($userData->isLegalEntity()) {
        $legalEntities = $userData->legal_info;
        $basicLegalEntity = $userData->getBasicLegalEntity();
    }

    // Process user data...
} else {
    // Handle authentication failure
    $error = $result->error;
    $message = $result->message;
}

// Logout user
$logoutResult = OneID::logout($accessToken);

// Validate token
$isValid = OneID::validateToken($accessToken);

// Get user info
$userInfo = OneID::getUserInfo($accessToken);

// Check configuration
$isConfigured = OneID::isConfigured();
$configErrors = OneID::getConfigurationErrors();
```

### Using Routes (Optional)

[](#using-routes-optional)

If you have routes enabled, you can use the built-in endpoints:

#### 1. Redirect to OneID

[](#1-redirect-to-oneid)

```
// Redirect user to OneID authorization
return redirect()->route('oneid.redirect');
```

#### 2. Handle Callback

[](#2-handle-callback)

Create a callback route in your application:

```
// routes/web.php
Route::get('/auth/oneid/callback', function (Request $request) {
    $code = $request->get('code');

    if (!$code) {
        return redirect('/login')->with('error', 'Authorization code not provided');
    }

    $result = OneID::handle($code);

    if ($result->success) {
        // Handle successful authentication
        $userData = $result->data;

        // Create or update user in your database
        $user = User::updateOrCreate(
            ['pin' => $userData['pin']],
            [
                'first_name' => $userData['first_name'],
                'last_name' => $userData['last_name'],
                'middle_name' => $userData['middle_name'] ?? null,
                'birth_date' => $userData['birth_date'] ?? null,
                'gender' => $userData['gender'] ?? null,
            ]
        );

        Auth::login($user);

        return redirect('/dashboard');
    } else {
        return redirect('/login')->with('error', $result->message);
    }
})->name('auth.oneid.callback');
```

#### 3. Logout

[](#3-logout)

```
// Logout from OneID
Route::post('/auth/oneid/logout', function (Request $request) {
    $accessToken = $request->get('access_token');

    if ($accessToken) {
        $result = OneID::logout($accessToken);

        if ($result->success) {
            Auth::logout();
            return response()->json(['message' => 'Logged out successfully']);
        }
    }

    return response()->json(['error' => 'Logout failed'], 400);
});
```

### Custom Routes

[](#custom-routes)

If you prefer to disable built-in routes and create your own:

```
ONEID_ROUTES_ENABLED=false
```

Then create your own routes:

```
// routes/web.php
Route::get('/auth/oneid', function () {
    return redirect(OneID::getAuthorizationUrl());
})->name('auth.oneid');

Route::post('/auth/oneid/handle', function (Request $request) {
    $result = OneID::handle($request->get('code'));
    return response()->json($result->toArray());
})->name('auth.oneid.handle');

Route::post('/auth/oneid/logout', function (Request $request) {
    $result = OneID::logout($request->get('access_token'));
    return response()->json($result->toArray());
})->name('auth.oneid.logout');
```

🔧 Configuration Options
-----------------------

[](#-configuration-options)

### Main Configuration

[](#main-configuration)

OptionDescriptionDefault`base_url`OneID API base URL`https://sso.egov.uz``client_id`Your OneID client IDRequired`client_secret`Your OneID client secretRequired`scope`Requested permissions`openid profile``redirect_uri`Callback URLRequired### Route Configuration

[](#route-configuration)

OptionDescriptionDefault`routes.enabled`Enable/disable built-in routes`true``routes.prefix`Route prefix`auth/oneid``routes.middleware`Route middleware`web``routes.names`Route namesCustom names### User Data Configuration

[](#user-data-configuration)

OptionDescriptionDefault`user.pin_field`PIN field name`pin``user.required_fields`Required user fields`['pin', 'first_name', 'last_name', 'middle_name']``user.optional_fields`Optional user fields`['birth_date', 'gender', 'nationality', 'region', 'district']`### Security Configuration

[](#security-configuration)

OptionDescriptionDefault`security.verify_ssl`Verify SSL certificates`true``security.rate_limiting.enabled`Enable rate limiting`true``security.rate_limiting.max_attempts`Max attempts per minute`5`🔒 Security Features
-------------------

[](#-security-features)

- **CSRF Protection**: Built-in CSRF token validation
- **Rate Limiting**: Configurable rate limiting for API calls
- **SSL Verification**: SSL certificate verification by default
- **Input Validation**: Comprehensive input validation
- **Secure Logging**: Structured logging with sensitive data protection

📊 Error Handling
----------------

[](#-error-handling)

The package provides comprehensive error handling:

```
$result = OneID::handle($code);

if (!$result->success) {
    switch ($result->error) {
        case 'token_null':
            // Could not obtain access token
            break;
        case 'missing_key':
            // Required user data missing
            break;
        default:
            // Other errors
            break;
    }
}
```

🧪 Testing
---------

[](#-testing)

Run the tests with:

```
composer test
```

Run tests with coverage:

```
composer test:coverage
```

📝 Logging
---------

[](#-logging)

The package logs all important events. You can configure logging in your `config/oneid.php`:

```
'logging' => [
    'enabled' => true,
    'level' => 'info',
    'channel' => 'default',
],
```

🤝 Contributing
--------------

[](#-contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

📄 License
---------

[](#-license)

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

🆘 Support
---------

[](#-support)

If you encounter any issues or have questions:

1. Check the [Issues](https://github.com/aslnbxrz/oneid/issues) page
2. Create a new issue if your problem isn't already reported
3. Contact the maintainer:

🙏 Acknowledgments
-----------------

[](#-acknowledgments)

- [OneID System](https://e-gov.uz/projects/one-id) - Uzbekistan's unified identification system
- [Laravel](https://laravel.com) - The PHP framework
- [Spatie](https://spatie.be) - For the excellent Laravel package tools
- [Saloon](https://saloon.dev) - For the HTTP client library

📈 Changelog
-----------

[](#-changelog)

### v1.0.0

[](#v100)

- Initial release with professional architecture
- Enhanced configuration system
- Optional route system
- Comprehensive error handling
- Security improvements
- Complete documentation
- Full test coverage
- CLI validation command
- Simple facade interface

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance63

Regular maintenance activity

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~0 days

Total

4

Last Release

224d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a725a0e94ad41b577a5c8741c0c771b7b473ed8300329646774062c200cdb441?d=identicon)[aslnbxrz](/maintainers/aslnbxrz)

---

Top Contributors

[![aslnbxrz](https://avatars.githubusercontent.com/u/60058750?v=4)](https://github.com/aslnbxrz "aslnbxrz (12 commits)")

---

Tags

authenticationegovidentitylaraveloauthoneidssouzbekistanlaravelAuthenticationSSOidentityoauthegovУзбекистанoneid

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/aslnbxrz-oneid/health.svg)

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

###  Alternatives

[laragear/two-factor

On-premises 2FA Authentication for out-of-the-box.

339785.3k8](/packages/laragear-two-factor)[auth0/login

Auth0 Laravel SDK. Straight-forward and tested methods for implementing authentication, and accessing Auth0's Management API endpoints.

2745.0M3](/packages/auth0-login)[adam-paterson/oauth2-stripe

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

172.4M4](/packages/adam-paterson-oauth2-stripe)

PHPackages © 2026

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