-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HTTP Basic Authentication provides a quick way to authenticate users (#…
…33) * Implement auth basic * remove unused package * type hint docblock * [ci skip] update changelog * Fix request authorization basic * More test
- Loading branch information
1 parent
212dc57
commit 3ec61e7
Showing
10 changed files
with
316 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace Fluent\Auth\Contracts; | ||
|
||
interface AuthenticationBasicInterface | ||
{ | ||
/** | ||
* Attempt to authenticate using HTTP Basic Auth. | ||
* | ||
* @param string $field | ||
* @param array $extraConditions | ||
* @throws \Fluent\Auth\Exceptions\AuthenticationException | ||
*/ | ||
public function basic($field = 'email', $extraConditions = []); | ||
|
||
/** | ||
* Perform a stateless HTTP Basic login attempt. | ||
* | ||
* @param string $field | ||
* @param array $extraConditions | ||
* @throws \Fluent\Auth\Exceptions\AuthenticationException | ||
*/ | ||
public function onceBasic($field = 'email', $extraConditions = []); | ||
|
||
/** | ||
* Log a user into the application without sessions or cookies. | ||
* | ||
* @param array $credentials | ||
* @return bool | ||
*/ | ||
public function once(array $credentials = []); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Fluent\Auth\Filters; | ||
|
||
use CodeIgniter\Filters\FilterInterface; | ||
use CodeIgniter\HTTP\RequestInterface; | ||
use CodeIgniter\HTTP\ResponseInterface; | ||
use Fluent\Auth\Config\Services; | ||
use Fluent\Auth\Contracts\AuthenticationBasicInterface; | ||
use Fluent\Auth\Contracts\AuthenticationInterface; | ||
use Fluent\Auth\Contracts\AuthFactoryInterface; | ||
|
||
class AuthenticationBasicFilter implements FilterInterface | ||
{ | ||
/** @var AuthFactoryInterface|AuthenticationBasicInterface|AuthenticationInterface */ | ||
protected $auth; | ||
|
||
public function __construct() | ||
{ | ||
$this->auth = Services::auth(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function before(RequestInterface $request, $arguments = null) | ||
{ | ||
[$guard, $field, $method] = $arguments; | ||
|
||
$this->auth->guard($guard)->{$method}($field); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.