Skip to content
This repository has been archived by the owner on Jun 21, 2024. It is now read-only.

Commit

Permalink
📝 added README
Browse files Browse the repository at this point in the history
  • Loading branch information
bssth committed Oct 26, 2019
1 parent 46e6b03 commit 3d91bfc
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# HTTP Auth Wrapper
Library provides simple HTTP authentication

# Installation
Just download and include classes from `src` or
use Composer:

`composer require mikechip/php-httpauth`

# Sample use
```php
require_once('vendor/autoload.php');

$auth = new Mike4ip\HttpAuth();
$auth->addLogin('admin', 'test');
$auth->addLogin('foo', 'bar');
$auth->requireAuth();

print('This is your hidden page');
```

# Customization
```php
require_once('vendor/autoload.php');

/*
* HTTP Auth with customization
*/
$auth = new Mike4ip\HttpAuth();
$auth->setRealm('Pass login and password');

// Set unauthorized callback
$auth->onUnauthorized(function() {
print("<h1>403 Forbidden</h1>");
die;
})->setCheckFunction(function($user, $pwd) {
// List of logins => passwords
$users = [
'admin' => 'test',
'foo' => 'bar'
];

// Returns true if login and password matches
return (isset($users[$user]) && $users[$user] === $pwd);
})->requireAuth();

print('This is your hidden page');
```

# Feedback
Use **Issues** to contact me

0 comments on commit 3d91bfc

Please sign in to comment.