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: guides/source/security.md
+206-5Lines changed: 206 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,10 +3,11 @@
3
3
Securing Rails Applications
4
4
===========================
5
5
6
-
This manual describes common security problems in web applications and how to avoid them with Rails.
6
+
This guide describes common security problems in web applications and how to avoid them with Rails.
7
7
8
8
After reading this guide, you will know:
9
9
10
+
* How to use the built-in authentication generator.
10
11
* All countermeasures _that are highlighted_.
11
12
* The concept of sessions in Rails, what to put in there and popular attack methods.
12
13
* How just visiting a site can be a security problem (with CSRF).
@@ -29,6 +30,210 @@ The threats against web applications include user account hijacking, bypass of a
29
30
30
31
In order to develop secure web applications you have to keep up to date on all layers and know your enemies. To keep up to date subscribe to security mailing lists, read security blogs, and make updating and security checks a habit (check the [Additional Resources](#additional-resources) chapter). It is done manually because that's how you find the nasty logical security problems.
31
32
33
+
Authentication
34
+
--------------
35
+
36
+
Authentication is often one of the first features implemented in a web
37
+
application. It serves as the foundation for securing user data and is part of
38
+
most modern web applications.
39
+
40
+
Starting with version 8.0, Rails comes with a default authentication generator,
41
+
which provides a solid starting point for securing your application by only
42
+
allowing access to verified users.
43
+
44
+
The authentication generator adds all of the relevant models, controllers,
45
+
views, routes, and migrations needed for basic authentication and password reset
46
+
functionality.
47
+
48
+
To use this feature in your application, you can run `rails generate
49
+
authentication`. Here are all of the files the generator modifies and new files
TIP: You can find all of the details for the Authentication generator in the
230
+
Rails source code. You are encouraged to explore the implementation details and
231
+
not treat authentication as a black box.
232
+
233
+
With the authentication generator configured as above, your application is ready
234
+
for a more secure user authentication and password recovery process in just a
235
+
few steps.
236
+
32
237
Sessions
33
238
--------
34
239
@@ -439,10 +644,6 @@ Another (additional) approach is to store the file names in the database and nam
439
644
User Management
440
645
---------------
441
646
442
-
NOTE: _Almost every web application has to deal with authorization and authentication. Instead of rolling your own, it is advisable to use common plug-ins. But keep them up-to-date, too. A few additional precautions can make your application even more secure._
443
-
444
-
There are a number of authentication plug-ins for Rails available. Good ones, such as the popular [devise](https://github.com/heartcombo/devise) and [authlogic](https://github.com/binarylogic/authlogic), store only cryptographically hashed passwords, not plain-text passwords. Since Rails 3.1 you can also use the built-in [`has_secure_password`](https://api.rubyonrails.org/classes/ActiveModel/SecurePassword/ClassMethods.html#method-i-has_secure_password) method which supports secure password hashing, confirmation, and recovery mechanisms.
445
-
446
647
### Brute-Forcing Accounts
447
648
448
649
NOTE: _Brute-force attacks on accounts are trial and error attacks on the login credentials. Fend them off with rate-limiting, more generic error messages and possibly require to enter a CAPTCHA._
0 commit comments