-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #221 from aedart/update-docs
Update docs for version 9.x
- Loading branch information
Showing
392 changed files
with
721 additions
and
726 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
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
45 changes: 45 additions & 0 deletions
45
docs/archive/current/auth/fortify/exceptions/failed-login-attempt.md
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,45 @@ | ||
--- | ||
description: Failed Login Attempt Exception | ||
sidebarDepth: 0 | ||
--- | ||
|
||
# Failed Login Attempt | ||
|
||
The `FailedLoginAttempt` exception is an alternative to Laravel's default validation exception that is thrown, on | ||
unsuccessful login attempts. The custom exception ensures that an HTTP | ||
["401 Unauthorized"](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401) response is sent back to a client, | ||
instead of a ["422 Unprocessable Content"](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422). | ||
|
||
The exception can be used in combination with a custom "attempt to authenticate" action (_see example below_). | ||
|
||
```php | ||
use Aedart\Auth\Fortify\Exceptions\FailedLoginAttempt; | ||
use Laravel\Fortify\Actions\AttemptToAuthenticate as BaseAttemptToAuthenticate; | ||
use Laravel\Fortify\Fortify; | ||
|
||
class AttemptToAuthenticate extends BaseAttemptToAuthenticate | ||
{ | ||
protected function throwFailedAuthenticationException($request) | ||
{ | ||
$this->limiter->increment($request); | ||
|
||
throw FailedLoginAttempt::withMessages([ | ||
Fortify::username() => [trans('auth.failed')], | ||
]); | ||
} | ||
} | ||
``` | ||
|
||
To use such an action, you will have to modify Laravel Fortify's default | ||
[authentication pipeline](https://laravel.com/docs/12.x/fortify#customizing-the-authentication-pipeline). | ||
|
||
```php | ||
Fortify::authenticateThrough(function (Request $request) { | ||
return array_filter([ | ||
// ...previous actions not shown... | ||
|
||
AttemptToAuthenticate::class, | ||
PrepareAuthenticatedSession::class, | ||
]); | ||
}); | ||
``` |
18 changes: 18 additions & 0 deletions
18
docs/archive/current/auth/fortify/exceptions/pass-reset-link-failure.md
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,18 @@ | ||
--- | ||
description: Password Reset Link Failure Exception | ||
sidebarDepth: 0 | ||
--- | ||
|
||
# Password Reset Link Failure | ||
|
||
The `PasswordResetLinkFailure`¹ exception can be used as an alternative to Laravel Fortify's default validation exception, | ||
in situations [requesting a password reset link](https://laravel.com/docs/12.x/fortify#requesting-a-password-reset-link) | ||
fails, e.g. due to invalid user credential. | ||
|
||
The exception results in an HTTP ["200 Ok"](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200) response, rather | ||
than the default ["422 Unprocessable Content"](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422) response. | ||
Doing so can reduce the chance, that an attacker is able to guess whether a user account exists or not. | ||
For more information about such, please see the custom | ||
["failed password reset link" API response](../responses/failed-pass-reset-link.md). | ||
|
||
¹: _Full namespace: `\Aedart\Auth\Fortify\Exceptions\PasswordResetLinkFailure`._ |
61 changes: 61 additions & 0 deletions
61
docs/archive/current/auth/fortify/responses/failed-pass-reset-link.md
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,61 @@ | ||
--- | ||
title: Failed Password Reset Link | ||
description: Failed Password Reset Link API Response | ||
sidebarDepth: 0 | ||
--- | ||
|
||
# Failed Password Reset Link (API Response) | ||
|
||
In an edge case scenario, a ["forgot password"](https://laravel.com/docs/12.x/fortify#requesting-a-password-reset-link) | ||
mechanism can potentially be misused to guess if a user account exists or not. Most commonly, this is done so by | ||
requesting a password reset, to a specified email. When your application responds with a | ||
[successful response](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#successful_responses) for a valid email, | ||
attackers will know that an account exists and proceed to exploitation attempts. | ||
|
||
::: tip Note | ||
The above described edge case scenario is **NOT** specifically tied to Laravel Fortify. Any kind of "reset password" | ||
functionality _can be_ subject to such, if end-users are able to request a reset password link. | ||
|
||
See [Testing for Account Enumeration and Guessable User Account](https://owasp.org/www-project-web-security-testing-guide/stable/4-Web_Application_Security_Testing/03-Identity_Management_Testing/04-Testing_for_Account_Enumeration_and_Guessable_User_Account.html) | ||
for additional details. | ||
::: | ||
|
||
To reduce the chances of revealing the existence of a user account, when requesting a reset link, the | ||
`FailedPasswordResetLinkApiResponse` can be used. Whenever the requested username, e.g. email, does not exist, the | ||
component throws a ["password reset link failure"](../exceptions/pass-reset-link-failure.md) exception, which results in | ||
an HTTP ["200 Ok"](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200) response. An attacker will then no | ||
longer be able to tell the difference between a valid or invalid username. | ||
|
||
::: warning Limitations | ||
The `FailedPasswordResetLinkApiResponse` is intended for API driven login mechanisms, e.g. when your "request reset | ||
password" functionality is implemented via a JSON based API. | ||
::: | ||
|
||
## How to use | ||
|
||
To use the custom API response, register a singleton binding for the `FailedPasswordResetLinkRequestResponse` interface. | ||
|
||
```php | ||
namespace App\Providers; | ||
|
||
use Aedart\Auth\Fortify\Responses\FailedPasswordResetLinkApiResponse; | ||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; | ||
use Laravel\Fortify\Contracts\FailedPasswordResetLinkRequestResponse; | ||
|
||
class AuthServiceProvider extends ServiceProvider | ||
{ | ||
public function boot() | ||
{ | ||
$this->app->singleton( | ||
FailedPasswordResetLinkRequestResponse::class, | ||
FailedPasswordResetLinkApiResponse::class | ||
); | ||
} | ||
} | ||
``` | ||
|
||
## Additional Reading | ||
|
||
* [Forgot Password Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Forgot_Password_Cheat_Sheet.html). | ||
* [Exploring Password Reset Vulnerabilities and Security Best Practices](https://www.vaadata.com/blog/exploring-password-reset-vulnerabilities-and-security-best-practices/) | ||
* [Exploring Reset Password Vulnerabilities: Risks, Exploits, and Prevention Strategies](https://medium.com/@cuncis/exploring-reset-password-vulnerabilities-risks-exploits-and-prevention-strategies-87745b65dd66) |
Oops, something went wrong.