{"id":17477454,"url":"https://github.com/elusivecodes/fyreauth","last_synced_at":"2025-04-10T09:26:33.650Z","repository":{"id":258272910,"uuid":"874575393","full_name":"elusivecodes/FyreAuth","owner":"elusivecodes","description":"FyreAuth is a free, open-source authentication and authorization library for PHP.","archived":false,"fork":false,"pushed_at":"2024-12-12T14:20:45.000Z","size":118,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-30T13:38:25.508Z","etag":null,"topics":["authentication","authorization","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elusivecodes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-18T04:45:22.000Z","updated_at":"2024-12-12T14:20:15.000Z","dependencies_parsed_at":"2025-02-13T15:38:13.382Z","dependency_job_id":null,"html_url":"https://github.com/elusivecodes/FyreAuth","commit_stats":null,"previous_names":["elusivecodes/fyreauth"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyreAuth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyreAuth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyreAuth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyreAuth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elusivecodes","download_url":"https://codeload.github.com/elusivecodes/FyreAuth/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248190816,"owners_count":21062350,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authentication","authorization","php"],"created_at":"2024-10-18T20:08:08.101Z","updated_at":"2025-04-10T09:26:33.642Z","avatar_url":"https://github.com/elusivecodes.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FyreAuth\r\n\r\n**FyreAuth** is a free, open-source authentication/authorization library for *PHP*.\r\n\r\n\r\n## Table Of Contents\r\n- [Installation](#installation)\r\n- [Basic Usage](#basic-usage)\r\n- [Methods](#methods)\r\n- [Access](#access)\r\n- [Identifier](#identifier)\r\n- [Authenticators](#authenticators)\r\n    - [Cookie](#cookie)\r\n    - [Session](#session)\r\n    - [Token](#token)\r\n- [Policy Registry](#policy-registry)\r\n- [Policies](#policies)\r\n- [Middleware](#middleware)\r\n\r\n\r\n\r\n## Installation\r\n\r\n**Using Composer**\r\n\r\n```\r\ncomposer require fyre/auth\r\n```\r\n\r\nIn PHP:\r\n\r\n```php\r\nuse Fyre\\Auth\\Auth;\r\n```\r\n\r\n\r\n## Basic Usage\r\n\r\n- `$container` is a [*Container*](https://github.com/elusivecodes/FyreContainer).\r\n- `$router` is a [*Router*](https://github.com/elusivecodes/FyreRouter).\r\n- `$config` is a [*Config*](https://github.com/elusivecodes/FyreConfig).\r\n\r\n```php\r\n$auth = new Auth($container, $router, $config)\r\n```\r\n\r\nDefault configuration options will be resolved from the \"*Auth*\" key in the [*Config*](https://github.com/elusivecodes/FyreConfig).\r\n\r\n- `$options` is an array containing the configuration options.\r\n    - `loginRoute` is a string representing the login [route](https://github.com/elusivecodes/FyreRouter) alias, and will default to \"*login*\".\r\n    - `authenticators` is an array containing configuration options for the [*authenticators*](#authenticators).\r\n    - `identifier` is an array containing configuration options for the [*Identifier*](#identifier).\r\n        - `identifierFields` is string orn array containing the identifier field name(s), and will default to \"*email*\".\r\n        - `passwordField` is a string representing the password field name, and will default to \"*password*\".\r\n        - `modelAlias` is a string representing the model alias, and will default to \"*Users*\".\r\n        - `queryCallback` is a *Closure* that will execute before running an identify query, and will default to *null*.\r\n\r\n```php\r\n$container-\u003euse(Config::class)-\u003eset('Auth', $options);\r\n```\r\n\r\n**Autoloading**\r\n\r\nIt is recommended to bind the *Auth* to the [*Container*](https://github.com/elusivecodes/FyreContainer) as a singleton.\r\n\r\n```php\r\n$container-\u003esingleton(Auth::class);\r\n```\r\n\r\nAny dependencies will be injected automatically when loading from the [*Container*](https://github.com/elusivecodes/FyreContainer).\r\n\r\n```php\r\n$auth = $container-\u003euse(Auth::class);\r\n```\r\n\r\n\r\n## Methods\r\n\r\n**Access**\r\n\r\nGet the [*Access*](#access).\r\n\r\n```php\r\n$access = $auth-\u003eaccess();\r\n```\r\n\r\n**Add Authenticator**\r\n\r\nAdd an [*Authenticator*](#authenticators).\r\n\r\n- `$authenticator` is an [*Authenticator*](#authenticators).\r\n- `$key` is a string representing the authenticator key, and will default to the [*Authenticator*](#authenticators) class name.\r\n\r\n```php\r\n$auth-\u003eaddAuthenticator($authenticator, $key);\r\n```\r\n\r\n**Attempt**\r\n\r\nAttempt to login as a user.\r\n\r\n- `$identifier` is a string representing the user identifier.\r\n- `$password` is a string representing the user password.\r\n- `$rememberMe` is a boolean indicating whether the user should be remembered, and will default to *false*.\r\n\r\n```php\r\n$user = $auth-\u003eattempt($identifier, $password, $rememberMe);\r\n```\r\n\r\n**Authenticator**\r\n\r\nGet an authenticator by key.\r\n\r\n- `$key` is a string representing the authenticator key.\r\n\r\n```php\r\n$authenticator = $auth-\u003eauthenticator($key);\r\n```\r\n\r\n**Authenticators**\r\n\r\nGet the authenticators.\r\n\r\n```php\r\n$authenticators = $auth-\u003eauthenticators();\r\n```\r\n\r\n**Get Login URL**\r\n\r\nGet the login URL.\r\n\r\n- `$redirect` is a string or [*Uri*](https://github.com/elusivecodes/FyreURI) representing the redirect URL, and will default to *null*.\r\n\r\n```php\r\n$url = $auth-\u003egetLoginUrl($redirect);\r\n```\r\n\r\n**Identifier**\r\n\r\nGet the [*Identifier*](#identifier).\r\n\r\n```php\r\n$identifier = $auth-\u003eidentifier();\r\n```\r\n\r\n**Is Logged In**\r\n\r\nDetermine if the current user is logged in.\r\n\r\n```php\r\n$isLoggedIn = $auth-\u003eisLoggedIn();\r\n```\r\n\r\n**Login**\r\n\r\nLogin as a user.\r\n\r\n- `$user` is an [*Entity*](https://github.com/elusivecodes/FyreEntity) representing the user.\r\n- `$rememberMe` is a boolean indicating whether the user should be remembered, and will default to *false*.\r\n\r\n```php\r\n$auth-\u003elogin($user, $rememberMe);\r\n```\r\n\r\n**Logout**\r\n\r\nLogout the current user.\r\n\r\n```php\r\n$auth-\u003elogout();\r\n```\r\n\r\n**User**\r\n\r\nGet the current user.\r\n\r\n```php\r\n$user = $auth-\u003euser();\r\n```\r\n\r\n\r\n## Access\r\n\r\n**After**\r\n\r\nExecute a callback after checking rules.\r\n\r\n- `$afterCallback` is a *Closure* that accepts the current user, access rule name, current result and any additional arguments.\r\n\r\n```php\r\n$access-\u003eafter($afterCallback);\r\n```\r\n\r\n**Allows**\r\n\r\nCheck whether an access rule is allowed.\r\n\r\n- `$rule` is a string representing the access rule name or [*Policy*](#policies) method.\r\n\r\nAny additional arguments supplied will be passed to the access rule callback or [*Policy*](#policies) method.\r\n\r\n```php\r\n$result = $access-\u003eallows($rule, ...$args);\r\n```\r\n\r\n**Any**\r\n\r\nCheck whether any access rule is allowed.\r\n\r\n- `$rules` is an array containing access rule names or [*Policy*](#policies) methods.\r\n\r\nAny additional arguments supplied will be passed to the access rule callbacks or [*Policy*](#policies) methods.\r\n\r\n```php\r\n$result = $access-\u003eany($rules, ...$args);\r\n```\r\n\r\n**Authorize**\r\n\r\nAuthorize an access rule.\r\n\r\n- `$rule` is a string representing the access rule name or [*Policy*](#policies) method.\r\n\r\nAny additional arguments supplied will be passed to the access rule callback or [*Policy*](#policies) method.\r\n\r\n```php\r\n$access-\u003eauthorize($rule, ...$args);\r\n```\r\n\r\n**Before**\r\n\r\nExecute a callback before checking rules.\r\n\r\n- `$beforeCallback` is a *Closure* that accepts the current user, access rule name and any additional arguments.\r\n\r\n```php\r\n$access-\u003ebefore($beforeCallback);\r\n```\r\n\r\n**Clear**\r\n\r\nClear all rules and callbacks.\r\n\r\n```php\r\n$access-\u003eclear();\r\n```\r\n\r\n**Define**\r\n\r\nDefine an access rule.\r\n\r\n- `$rule` is a string representing the access rule name.\r\n- `$callback` is a *Closure* that accepts the current user and any additional arguments.\r\n\r\n```php\r\n$access-\u003edefine($rule, $callback);\r\n```\r\n\r\n**Denies**\r\n\r\nCheck whether an access rule is not allowed.\r\n\r\n- `$rule` is a string representing the access rule name or [*Policy*](#policies) method.\r\n\r\nAny additional arguments supplied will be passed to the access rule callback or [*Policy*](#policies) method.\r\n\r\n```php\r\n$result = $access-\u003edenies($rule, ...$args);\r\n```\r\n\r\n**None**\r\n\r\nCheck whether no access rule is allowed.\r\n\r\n- `$rules` is an array containing access rule names or [*Policy*](#policies) methods.\r\n\r\nAny additional arguments supplied will be passed to the access rule callbacks or [*Policy*](#policies) methods.\r\n\r\n```php\r\n$result = $access-\u003enone($rules, ...$args);\r\n```\r\n\r\n\r\n## Identifier\r\n\r\n**Attempt**\r\n\r\nAttempt to identify a user.\r\n\r\n- `$identifier` is a string representing the user identifier.\r\n- `$password` is a string representing the user password.\r\n\r\n```php\r\n$user = $identifier-\u003eattempt($identifier, $password);\r\n```\r\n\r\n**Get Identifier Fields**\r\n\r\nGet the user identifier fields.\r\n\r\n```php\r\n$identifierFields = $identifier-\u003egetIdentifierFields();\r\n```\r\n\r\n**Get Model**\r\n\r\nGet the identity [*Model*](https://github.com/elusivecodes/FyreORM#models).\r\n\r\n```php\r\n$model = $identifier-\u003egetModel();\r\n```\r\n\r\n**Get Password Field**\r\n\r\nGet the user password field.\r\n\r\n```php\r\n$passwordField = $identifier-\u003egetPasswordField();\r\n```\r\n\r\n**Identify**\r\n\r\nFind an identity by identifier.\r\n\r\n- `$identifier` is a string representing the user identifier.\r\n\r\n```php\r\n$user = $identifier-\u003eidentify($identifier);\r\n```\r\n\r\n\r\n## Authenticators\r\n\r\nCustom authenticators can be created by extending the `\\Fyre\\Auth\\Authenticator` class, and overwriting the below methods as required.\r\n\r\n**Authenticate**\r\n\r\nAuthenticate a [*ServerRequest*](https://github.com/elusivecodes/FyreServer#server-requests).\r\n\r\n- `$request` is a [*ServerRequest*](https://github.com/elusivecodes/FyreServer#server-requests).\r\n\r\n```php\r\n$user = $authenticator-\u003eauthenticate($request);\r\n```\r\n\r\n**Before Response**\r\n\r\nUpdate the [*ClientResponse*](https://github.com/elusivecodes/FyreServer#client-responses) before sending to client.\r\n\r\n- `$response` is a [*ClientResponse*](https://github.com/elusivecodes/FyreServer#client-responses).\r\n\r\n```php\r\n$response = $authenticator-\u003ebeforeResponse($response);\r\n```\r\n\r\n**Login**\r\n\r\nLogin as a user.\r\n\r\n- `$user` is an [*Entity*](https://github.com/elusivecodes/FyreEntity) representing the user.\r\n- `$rememberMe` is a boolean indicating whether the user should be remembered, and will default to *false*.\r\n\r\n```php\r\n$authenticator-\u003elogin($user, $rememberMe);\r\n```\r\n\r\n**Logout**\r\n\r\nLogout the current user.\r\n\r\n```php\r\n$authenticator-\u003elogout();\r\n```\r\n\r\n\r\n### Cookie\r\n\r\n```php\r\nuse Fyre\\Auth\\Authenticators\\CookieAuthenticator;\r\n```\r\n\r\nThe cookie authenticator can be loaded using custom configuration.\r\n\r\n- `$auth` is an *Auth*.\r\n- `$options` is an array containing configuration options.\r\n    - `cookieName` is a string representing the cookie name, and will default to \"*auth*\".\r\n    - `cookieOptions` is an array containing additional options for setting the cookie.\r\n        - `expires` is a number representing the cookie lifetime, and will default to *null*.\r\n        - `domain` is a string representing the cookie domain, and will default to \"\".\r\n        - `path` is a string representing the cookie path, and will default to \"*/*\".\r\n        - `secure` is a boolean indicating whether to set a secure cookie, and will default to *false*.\r\n        - `httpOnly` is a boolean indicating whether to the cookie should be HTTP only, and will default to *true*.\r\n        - `sameSite` is a string representing the cookie same site, and will default to \"*Lax*\".\r\n    - `identifierField` is a string representing the identifier field of the user, and will default to \"*email*\".\r\n    - `passwordfield` is a string representing the password field of the user, and will default to \"*password*\".\r\n    - `salt` is a string representing the salt to use when generating the token, and will default to *null*.\r\n\r\n```php\r\n$authenticator = new CookieAuthenticator($auth, $options);\r\n```\r\n\r\nThis authenticator is only active when the `$rememberMe` argument is set to *true* in the `$auth-\u003eattempt` or `$auth-\u003elogin` methods.\r\n\r\n### Session\r\n\r\n```php\r\nuse Fyre\\Auth\\Authenticators\\SessionAuthenticator;\r\n```\r\n\r\nThe session authenticator can be loaded using custom configuration.\r\n\r\n- `$auth` is an *Auth*.\r\n- `$session` is a [*Session*](https://github.com/elusivecodes/FyreSession).\r\n- `$options` is an array containing configuration options.\r\n    - `sessionKey` is a string representing the session key, and will default to \"*auth*\".\r\n    - `sessionField` is a string representing the session field of the user, and will default to \"*id*\".\r\n\r\n```php\r\n$authenticator = new SessionAuthenticator($auth, $session, $options);\r\n```\r\n\r\n### Token\r\n\r\n```php\r\nuse Fyre\\Auth\\Authenticators\\TokenAuthenticator;\r\n```\r\n\r\nThe token authenticator can be loaded using custom configuration.\r\n\r\n- `$auth` is an *Auth*.\r\n- `$options` is an array containing configuration options.\r\n    - `tokenHeader` is a string representing the token header name, and will default to \"*Authorization*\".\r\n    - `tokenHeaderPrefix` is a string representing the token header prefix, and will default to \"*Bearer*\".\r\n    - `tokenQuery` is a string representing the query parameter, and will default to *null*.\r\n    - `tokenField` is a string representing the token field of the user, and will default to \"*token*\".\r\n\r\n```php\r\n$authenticator = new TokenAuthenticator($auth, $options);\r\n```\r\n\r\n\r\n## Policy Registry\r\n\r\n```php\r\nuse Fyre\\Auth\\PolicyRegistry;\r\n```\r\n\r\n- `$container` is a [*Container*](https://github.com/elusivecodes/FyreContainer).\r\n- `$inflector` is an [*Inflector*](https://github.com/elusivecodes/FyreInflector).\r\n\r\n```php\r\n$policyRegistry = new PolicyRegistry($container, $inflector);\r\n```\r\n\r\n**Add Namespace**\r\n\r\nAdd a namespace for loading policies.\r\n\r\n- `$namespace` is a string representing the namespace.\r\n\r\n```php\r\n$policyRegistry-\u003eaddNamespace($namespace);\r\n```\r\n\r\n**Build**\r\n\r\nBuild a [*Policy*](#policies).\r\n\r\n- `$alias` is a string representing the [*Model*](https://github.com/elusivecodes/FyreORM#models) alias or class name.\r\n\r\n```php\r\n$policy = $policyRegistry-\u003ebuild($alias);\r\n```\r\n\r\n**Clear**\r\n\r\nClear all namespaces and policies.\r\n\r\n```php\r\n$policyRegistry-\u003eclear();\r\n```\r\n\r\n**Get Namespaces**\r\n\r\nGet the namespaces.\r\n\r\n```php\r\n$namespaces = $policyRegistry-\u003enamespaces();\r\n```\r\n\r\n**Has Namespace**\r\n\r\nDetermine if a namespace exists.\r\n\r\n- `$namespace` is a string representing the namespace.\r\n\r\n```php\r\n$hasNamespace = $policyRegistry-\u003ehasNamespace($namespace);\r\n```\r\n\r\n**Map**\r\n\r\nMap an alias to a [*Policy*](#policies) class name.\r\n\r\n- `$alias` is a string representing the [*Model*](https://github.com/elusivecodes/FyreORM#models) alias or class name.\r\n- `$className` is a string representing the [*Policy*](#policies) class name.\r\n\r\n```php\r\n$policyRegistry-\u003emap($alias, $className);\r\n```\r\n\r\n**Remove Namespace**\r\n\r\nRemove a namespace.\r\n\r\n- `$namespace` is a string representing the namespace.\r\n\r\n```php\r\n$policyRegistry-\u003eremoveNamespace($namespace);\r\n```\r\n\r\n**Resolve Alias**\r\n\r\nResolve a modal alias.\r\n\r\n- `$alias` is a model alias or class name.\r\n\r\n```php\r\n$alias = $policyRegistry-\u003eresolveAlias($alias);\r\n```\r\n\r\n**Unload**\r\n\r\nUnload a policy.\r\n\r\n- `$alias` is a string representing the [*Model*](https://github.com/elusivecodes/FyreORM#models) alias or class name.\r\n\r\n```php\r\n$policyRegistry-\u003eunload($alias);\r\n```\r\n\r\n**Use**\r\n\r\nLoad a shared [*Policy*](#policies) instance.\r\n\r\n- `$alias` is a string representing the [*Model*](https://github.com/elusivecodes/FyreORM#models) alias or class name.\r\n\r\n```php\r\n$policy = $policyRegistry-\u003euse($alias);\r\n```\r\n\r\n\r\n## Policies\r\n\r\nPolicies can be created by suffixing the singular model alias with \"*Policy*\" as the class name.\r\n\r\nPolicy rules should be represented as methods on the class, that accept the current user and resolved [*Entity*](https://github.com/elusivecodes/FyreEntity) as arguments.\r\n\r\n\r\n## Middleware\r\n\r\n### Auth Middleware\r\n\r\n```php\r\nuse Fyre\\Auth\\Middleware\\AuthMiddleware;\r\n```\r\n\r\nThis middleware will authenticate using the loaded authenticators, and add any authentication headers to the response.\r\n\r\n- `$auth` is an *Auth*.\r\n\r\n```php\r\n$middleware = new AuthMiddleware($auth);\r\n```\r\n\r\nAny dependencies will be injected automatically when loading from the [*Container*](https://github.com/elusivecodes/FyreContainer).\r\n\r\n```php\r\n$middleware = $container-\u003euse(AuthMiddleware::class);\r\n```\r\n\r\n**Handle**\r\n\r\nHandle a [*ServerRequest*](https://github.com/elusivecodes/FyreServer#server-requests).\r\n\r\n- `$request` is a [*ServerRequest*](https://github.com/elusivecodes/FyreServer#server-requests).\r\n- `$next` is a *Closure*.\r\n\r\n```php\r\n$response = $middleware-\u003ehandle($request, $next);\r\n```\r\n\r\nThis method will return a [*ClientResponse*](https://github.com/elusivecodes/FyreServer#client-responses).\r\n\r\n### Authenticated Middleware\r\n\r\n```php\r\nuse Fyre\\Auth\\Middleware\\AuthenticatedMiddleware;\r\n```\r\n\r\nThis middleware will throw an [*UnauthorizedException*](https://github.com/elusivecodes/FyreError#http-exceptions) or return a login [*RedirectResponse*](https://github.com/elusivecodes/FyreServer#redirect-responses) if the user is not authenticated.\r\n\r\n- `$auth` is an *Auth*.\r\n\r\n```php\r\n$middleware = new AuthenticatedMiddleware($auth);\r\n```\r\n\r\nAny dependencies will be injected automatically when loading from the [*Container*](https://github.com/elusivecodes/FyreContainer).\r\n\r\n```php\r\n$middleware = $container-\u003euse(AuthenticatedMiddleware::class);\r\n```\r\n\r\n**Handle**\r\n\r\nHandle a [*ServerRequest*](https://github.com/elusivecodes/FyreServer#server-requests).\r\n\r\n- `$request` is a [*ServerRequest*](https://github.com/elusivecodes/FyreServer#server-requests).\r\n- `$next` is a *Closure*.\r\n\r\n```php\r\n$response = $middleware-\u003ehandle($request, $next);\r\n```\r\n\r\nThis method will return a [*ClientResponse*](https://github.com/elusivecodes/FyreServer#client-responses).\r\n\r\n### Authorized Middleware\r\n\r\n```php\r\nuse Fyre\\Auth\\Middleware\\AuthorizedMiddleware;\r\n```\r\n\r\nThis middleware will throw a [*ForbiddenException*](https://github.com/elusivecodes/FyreError#http-exceptions) or a login [*RedirectResponse*](https://github.com/elusivecodes/FyreServer#redirect-responses) if the user is not authorized.\r\n\r\n- `$auth` is an *Auth*.\r\n\r\n```php\r\n$middleware = new AuthorizedMiddleware($auth);\r\n```\r\n\r\nAny dependencies will be injected automatically when loading from the [*Container*](https://github.com/elusivecodes/FyreContainer).\r\n\r\n```php\r\n$middleware = $container-\u003euse(AuthorizedMiddleware::class);\r\n```\r\n\r\n**Handle**\r\n\r\nHandle a [*ServerRequest*](https://github.com/elusivecodes/FyreServer#server-requests).\r\n\r\n- `$request` is a [*ServerRequest*](https://github.com/elusivecodes/FyreServer#server-requests).\r\n- `$next` is a *Closure*.\r\n\r\n```php\r\n$response = $middleware-\u003ehandle($request, $next);\r\n```\r\n\r\nThis method will return a [*ClientResponse*](https://github.com/elusivecodes/FyreServer#client-responses).\r\n\r\n### Unauthenticated Middleware\r\n\r\n```php\r\nuse Fyre\\Auth\\Middleware\\UnauthenticatedMiddleware;\r\n```\r\n\r\nThis middleware will throw a [*NotFoundException*](https://github.com/elusivecodes/FyreError#http-exceptions) if the user is authenticated.\r\n\r\n- `$auth` is an *Auth*.\r\n\r\n```php\r\n$middleware = new UnauthenticatedMiddleware($auth);\r\n```\r\n\r\nAny dependencies will be injected automatically when loading from the [*Container*](https://github.com/elusivecodes/FyreContainer).\r\n\r\n```php\r\n$middleware = $container-\u003euse(UnauthenticatedMiddleware::class);\r\n```\r\n\r\n**Handle**\r\n\r\nHandle a [*ServerRequest*](https://github.com/elusivecodes/FyreServer#server-requests).\r\n\r\n- `$request` is a [*ServerRequest*](https://github.com/elusivecodes/FyreServer#server-requests).\r\n- `$next` is a *Closure*.\r\n\r\n```php\r\n$response = $middleware-\u003ehandle($request, $next);\r\n```\r\n\r\nThis method will return a [*ClientResponse*](https://github.com/elusivecodes/FyreServer#client-responses).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felusivecodes%2Ffyreauth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felusivecodes%2Ffyreauth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felusivecodes%2Ffyreauth/lists"}