Skip to content

Commit

Permalink
Added support for custom auth logics (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
ingria committed Dec 19, 2017
1 parent 9261886 commit 3963654
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Also known as X.509 client authentication.
3. This package allows `Admin` to use your app without ever logging in.
4. All users including `Admin` can still use plain password auth.

> __Pro tip__: you can also [use any other certificate attributes](https://github.com/ingria/laravel-x509-auth/wiki/Using-other-cert-attributes) for authentication, not only `emailAddress` (like `id` or `username`). I don't think you need this package in that case, but anyway 🤷.
## Prerequisites

Please don't blindly copy-paste the commands. It's important for you to know what you're doing.
Expand Down
6 changes: 3 additions & 3 deletions src/Middleware/AuthenticateWithClientCertificate.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function handle($request, Closure $next, $guard = null)

/** If the certificate is valid, log in and remember the user: */
if ($request->server('SSL_CLIENT_VERIFY') === 'SUCCESS') {
$this->auth->guard($guard)->login(self::getUserFromCert($request), true);
$this->auth->guard($guard)->login(static::getUserFromCert($request), true);

return $next($request);
}
Expand All @@ -65,7 +65,7 @@ public function handle($request, Closure $next, $guard = null)
* @param Request $request
* @return App\User
*/
private static function getUserFromCert(Request $request)
protected static function getUserFromCert(Request $request)
{
/**
* Probably misconfigured Nginx:
Expand All @@ -90,7 +90,7 @@ private static function getUserFromCert(Request $request)
* @param string $subject
* @return string
*/
private static function getEmailFromDn(string $subject): string
protected static function getEmailFromDn(string $subject): string
{
preg_match('/emailAddress=([\w\+]+@[a-z\-\d]+\.[a-z\-\.\d]{2,})/i', $subject, $match);

Expand Down

0 comments on commit 3963654

Please sign in to comment.