You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: authentication.md
+18-22Lines changed: 18 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,10 +51,12 @@ Also, you should verify that your `users` (or equivalent) table contains a nulla
51
51
<aname="authentication-quickstart"></a>
52
52
## Authentication Quickstart
53
53
54
+
> {note} This portion of the documentation discusses authenticating users via the [Laravel Jetstream](https://jetstream.laravel.com) package, which includes UI scaffolding to help you get started quickly. If you would like to integrate with Laravel's authentication systems directly, check out the documentation on [manually authenticating users](#authenticating-users).
55
+
54
56
<aname="included-routing"></a>
55
57
### Routing
56
58
57
-
Laravel's `laravel/jetstream` package provides a quick way to scaffold all of the routesand views you need for authentication using a few simple commands:
59
+
Laravel's `laravel/jetstream` package provides a quick way to scaffold all of the routes, views, and other backend logic needed for authentication using a few simple commands:
58
60
59
61
composer require laravel/jetstream
60
62
@@ -66,25 +68,25 @@ Laravel's `laravel/jetstream` package provides a quick way to scaffold all of th
66
68
67
69
This command should be used on fresh applications and will install a layout view, registration and login views, as well as routes for all authentication end-points. A `/dashboard` route will also be generated to handle post-login requests to your application's dashboard.
68
70
69
-
To learn more about Jetstream, please visit the official [Jetstream documentation](https://jetstream.laravel.com).
70
-
71
71
#### Creating Applications Including Authentication
72
72
73
73
If you are starting a brand new application and would like to include the authentication scaffolding, you may use the `--jet` directive when creating your application via the Laravel Installer. This command will create a new application with all of the authentication scaffolding compiled and installed:
74
74
75
75
laravel new kitetail --jet
76
76
77
+
> {tip} To learn more about Jetstream, please visit the official [Jetstream documentation](https://jetstream.laravel.com).
78
+
77
79
<aname="included-views"></a>
78
80
### Views
79
81
80
82
As mentioned in the previous section, the `laravel/jetstream` package's `php artisan jetstream:install` command will create all of the views you need for authentication and place them in the `resources/views/auth` directory.
81
83
82
-
Jetstream will also create a `resources/views/layouts` directory containing a base layout for your application. All of these views use the Tailwind CSS framework, but you are free to customize them however you wish.
84
+
Jetstream will also create a `resources/views/layouts` directory containing a base layout for your application. All of these views use the [Tailwind CSS](https://tailwindcss.com) framework, but you are free to customize them however you wish.
83
85
84
86
<aname="included-authenticating"></a>
85
87
### Authenticating
86
88
87
-
Now that you have routes and views setup for the included authentication controllers, you are ready to register and authenticate new users for your application! You may access your application in a browser since Jetstream's authentication controllers already contain the logic to authenticate existing users and store new users in the database.
89
+
Now that your application has been scaffolded for authentication, you are ready to register and authenticate! You may simply access your application in a browser since Jetstream's authentication controllers already contain the logic to authenticate existing users and store new users in the database.
88
90
89
91
#### Path Customization
90
92
@@ -115,10 +117,10 @@ Alternatively, once a user is authenticated, you may access the authenticated us
115
117
116
118
use Illuminate\Http\Request;
117
119
118
-
class ProfileController extends Controller
120
+
class FlightController extends Controller
119
121
{
120
122
/**
121
-
* Update the user's profile.
123
+
* Get a list of all available flights.
122
124
*
123
125
* @param Request $request
124
126
* @return Response
@@ -144,19 +146,12 @@ To determine if the user is already logged into your application, you may use th
144
146
<aname="protecting-routes"></a>
145
147
### Protecting Routes
146
148
147
-
[Route middleware](/docs/{{version}}/middleware) can be used to only allow authenticated users to access a given route. Laravel ships with an `auth` middleware, which is defined at `Illuminate\Auth\Middleware\Authenticate`. Since this middleware is already registered in your HTTP kernel, all you need to do is attach the middleware to a route definition:
149
+
[Route middleware](/docs/{{version}}/middleware) can be used to only allow authenticated users to access a given route. Laravel ships with an `auth` middleware, which references the `Illuminate\Auth\Middleware\Authenticate` class. Since this middleware is already registered in your HTTP kernel, all you need to do is attach the middleware to a route definition:
148
150
149
-
Route::get('profile', function () {
151
+
Route::get('flights', function () {
150
152
// Only authenticated users may enter...
151
153
})->middleware('auth');
152
154
153
-
If you are using [controllers](/docs/{{version}}/controllers), you may call the `middleware` method from the controller's constructor instead of attaching it in the route definition directly:
154
-
155
-
public function __construct()
156
-
{
157
-
$this->middleware('auth');
158
-
}
159
-
160
155
#### Redirecting Unauthenticated Users
161
156
162
157
When the `auth` middleware detects an unauthorized user, it will redirect the user to the `login`[named route](/docs/{{version}}/routing#named-routes). You may modify this behavior by updating the `redirectTo` function in your `app/Http/Middleware/Authenticate.php` file:
@@ -176,20 +171,21 @@ When the `auth` middleware detects an unauthorized user, it will redirect the us
176
171
177
172
When attaching the `auth` middleware to a route, you may also specify which guard should be used to authenticate the user. The guard specified should correspond to one of the keys in the `guards` array of your `auth.php` configuration file:
178
173
179
-
public function __construct()
180
-
{
181
-
$this->middleware('auth:api');
182
-
}
174
+
Route::get('flights', function () {
175
+
// Only authenticated users may enter...
176
+
})->middleware('auth:api');
183
177
184
178
<aname="login-throttling"></a>
185
179
### Login Throttling
186
180
187
181
If you are using Laravel Jetstream, rate limiting will automatically be applied to login attempts. By default, the user will not be able to login for one minute if they fail to provide the correct credentials after several attempts. The throttling is unique to the user's username / e-mail address and their IP address.
188
182
183
+
> {tip} If you would like to rate limit your own routes, check out the [rate limiting documentation](/docs/{{version}}/routing#rate-limiting).
184
+
189
185
<aname="authenticating-users"></a>
190
186
## Manually Authenticating Users
191
187
192
-
Note that you are not required to use the authentication controllers included with Laravel Jetstream. If you choose to not use this scaffolding, you will need to manage user authentication using the Laravel authentication classes directly. Don't worry, it's a cinch!
188
+
You are not required to use the authentication scaffolding included with Laravel Jetstream. If you choose to not use this scaffolding, you will need to manage user authentication using the Laravel authentication classes directly. Don't worry, it's a cinch!
193
189
194
190
We will access Laravel's authentication services via the `Auth`[facade](/docs/{{version}}/facades), so we'll need to make sure to import the `Auth` facade at the top of the class. Next, let's check out the `attempt` method:
195
191
@@ -272,7 +268,7 @@ If you are "remembering" users, you may use the `viaRemember` method to determin
272
268
273
269
#### Authenticate A User Instance
274
270
275
-
If you need to log an existing user instance into your application, you may call the `login` method with the user instance. The given object must be an implementation of the `Illuminate\Contracts\Auth\Authenticatable`[contract](/docs/{{version}}/contracts). The `App\Models\User` model included with Laravel already implements this interface:
271
+
If you need to log an existing user instance into your application, you may call the `login` method with the user instance. The given object must be an implementation of the `Illuminate\Contracts\Auth\Authenticatable`[contract](/docs/{{version}}/contracts). The `App\Models\User` model included with Laravel already implements this interface. This method of authentication is useful when you already have a valid user instance, such as directly after a user registers with your application:
Copy file name to clipboardExpand all lines: hashing.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@
7
7
<aname="introduction"></a>
8
8
## Introduction
9
9
10
-
The Laravel `Hash`[facade](/docs/{{version}}/facades) provides secure Bcrypt and Argon2 hashing for storing user passwords. If you are using the built-in `LoginController` and `RegisterController` classes that are included with your Laravel application, they will use Bcrypt for registration and authentication by default.
10
+
The Laravel `Hash`[facade](/docs/{{version}}/facades) provides secure Bcrypt and Argon2 hashing for storing user passwords. If you are using the [Laravel Jetstream](https://jetstream.laravel.com) authentication scaffolding, Bcrypt will be used for registration and authentication by default.
11
11
12
12
> {tip} Bcrypt is a great choice for hashing passwords because its "work factor" is adjustable, which means that the time it takes to generate a hash can be increased as hardware power increases.
13
13
@@ -71,7 +71,7 @@ If you are using the Argon2 algorithm, the `make` method allows you to manage th
71
71
72
72
#### Verifying A Password Against A Hash
73
73
74
-
The `check` method allows you to verify that a given plain-text string corresponds to a given hash. However, if you are using the `LoginController`[included with Laravel](/docs/{{version}}/authentication), you will probably not need to use this directly, as this controller automatically calls this method:
74
+
The `check` method allows you to verify that a given plain-text string corresponds to a given hash:
Copy file name to clipboardExpand all lines: migrations.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -60,7 +60,7 @@ When you execute this command, Laravel will write a "schema" file to your `datab
60
60
61
61
You should commit your database schema file to source control so that other new developers on your team may quickly create your application's initial database structure.
62
62
63
-
> {note} Migration squashing is only available for the MySQLand PostgreSQL databases.
63
+
> {note} Migration squashing is only available for the MySQL, PostgreSQL, and SQLite databases.
0 commit comments