diff --git a/src/Authorize/AuthorizeMethodInterface.php b/src/Authorize/AuthorizeMethodInterface.php new file mode 100644 index 0000000..36a43db --- /dev/null +++ b/src/Authorize/AuthorizeMethodInterface.php @@ -0,0 +1,11 @@ +getHeader('Authorization') ) { + list($method, $userPass) = explode(' ', $auth, 2) + [ null, null ]; + + if (! $method ) { + throw new \InvalidArgumentException("An authentication method must be provided"); + } + elseif (! $userPass ) { + throw new \InvalidArgumentException("A base64-encoded 'user:password' value must be provided"); + } + + + return false; + } + + return false; + } + + protected function basicMethod(string $header) : UserInterface|false + { + + } + +} \ No newline at end of file diff --git a/src/Common/AuthorizeEnum.php b/src/Common/AuthorizeEnum.php new file mode 100644 index 0000000..9839acd --- /dev/null +++ b/src/Common/AuthorizeEnum.php @@ -0,0 +1,16 @@ +loadFromPk($id) ) ) { - throw new \Exception("User not found."); + throw new \InvalidArgumentException(sprintf("User having id '%s' was not found.", $id)); } $user->logged = true; diff --git a/src/Lib/Authorize.php b/src/Lib/Authorize.php new file mode 100644 index 0000000..8825c8b --- /dev/null +++ b/src/Lib/Authorize.php @@ -0,0 +1,18 @@ +loginFailed; + } + + return $handler->handle($request); + } +} diff --git a/src/Middleware/AuthorizeMiddleware.php b/src/Middleware/AuthorizeMiddleware.php new file mode 100644 index 0000000..7b8bd13 --- /dev/null +++ b/src/Middleware/AuthorizeMiddleware.php @@ -0,0 +1,26 @@ +loginFailed; + } + + return $handler->handle($request); + } +}