PHPackages                             lajax/yii2-http-auth - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. lajax/yii2-http-auth

ActiveYii2-extension[HTTP &amp; Networking](/categories/http)

lajax/yii2-http-auth
====================

Yii2 Http Authentication extension

0.1.0(10y ago)43.6k↑50%1BSD-3-ClausePHP

Since Apr 16Pushed 7y ago3 watchersCompare

[ Source](https://github.com/lajax/yii2-http-auth)[ Packagist](https://packagist.org/packages/lajax/yii2-http-auth)[ RSS](/packages/lajax-yii2-http-auth/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (4)Used By (0)

Yii2 HTTP authentication extension
==================================

[](#yii2-http-authentication-extension)

[![Latest Version on Packagist](https://camo.githubusercontent.com/9a01acfbea10d88485f3418a9638a7c4ee59cf6d161499cb55d2a9bf36bfa32c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c616a61782f796969322d687474702d617574682e7376673f7374796c653d666c6174)](https://packagist.org/packages/lajax/yii2-http-auth)[![Software License](https://camo.githubusercontent.com/fe307b89ef875de4554b94c096b149900ffec754fa74a70c80bd794c42d4105f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d425344332d627269676874677265656e2e7376673f7374796c653d666c6174)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/c0e7b69910f12a871477f7fe2ad15bb1f753dfc35ddef773072452b522c7956d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c616a61782f796969322d687474702d617574682e7376673f7374796c653d666c6174)](https://packagist.org/packages/lajax/yii2-http-auth)

This extension can be used to protect your Yii2 application with HTTP authentication against unauthorized access. For example you can use it to prevent users seeing your development environment.

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

[](#installation)

Via [Composer](http://getcomposer.org/download/)

```
composer require lajax/yii2-http-auth

```

Usage
-----

[](#usage)

You need to `bootstrap` the component on the start of the application.

On execution the component will check the IP address of the user. If the IP address is not in the `allowedIps` list, a HTTP authentication will be performed.

With the `users` option you can specify username and password pairs for accessing the application. The value can be either an actual password, or an MD5 hash of the password.

### Config

[](#config)

```
'bootstrap' => ['httpAuth'],
'components' =>  [
    // ...
    'httpAuth' => [
        'class' => 'lajax\httpauth\Component',
        'allowedIps' => ['127.0.0.1', '127.0.0.2'],
        'users' => [
            // Actual password:
            'mrsmith' => '123456',
            // MD5 hash of the password:
            'mrssmith' => 'e10adc3949ba59abbe56e057f20f883e',
        ],
        'errorAction' => 'site/error',
    ],
    // ...
]
```

Testing
-------

[](#testing)

```
composer test

```

Coding style
------------

[](#coding-style)

The project uses the PSR-2 coding standard. Related commands:

- `composer cs-fix`: Fix coding style issues.
- `composer cs-check`: Check for coding style issues.

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

License
-------

[](#license)

The 3-Clause BSD License. Please see [License File](LICENSE.md) for more information.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 76.5% 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 ~168 days

Total

3

Last Release

3705d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/92584220fadca858bc97cc515957be2a1058a58ff95adde7a3c076d3eb7e1026?d=identicon)[lajax](/maintainers/lajax)

---

Top Contributors

[![moltam](https://avatars.githubusercontent.com/u/4578365?v=4)](https://github.com/moltam "moltam (13 commits)")[![lajax](https://avatars.githubusercontent.com/u/5390245?v=4)](https://github.com/lajax "lajax (4 commits)")

---

Tags

httpsecurityAuthenticationpasswordyii2extensionusernameallowedIps

### Embed Badge

![Health badge](/badges/lajax-yii2-http-auth/health.svg)

```
[![Health](https://phpackages.com/badges/lajax-yii2-http-auth/health.svg)](https://phpackages.com/packages/lajax-yii2-http-auth)
```

###  Alternatives

[linslin/yii2-curl

Easy and nice cURL extension with RESTful support for Yii2

1811.5M20](/packages/linslin-yii2-curl)[joni-jones/yii2-wschat

Online chat based on web sockets and ratchet php

981.3k](/packages/joni-jones-yii2-wschat)[sven/super-basic-auth

A lightweight package to add basic authentication to your Laravel app.

232.6k](/packages/sven-super-basic-auth)[yiiplus/yii2-websocket

使用yii2封装 websocket 扩展

212.6k](/packages/yiiplus-yii2-websocket)

PHPackages © 2026

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