Rails 8 Authentication generator docs?

Is there any official documentation for the Rails 8 Authentication generator?

1 Like

The only “doc” I found that in the Rails 8 blog post announcement:

Just run bin/rails generate authentication and you’ll get basic models for Session and User , together with a PasswordsMailer , SessionsController , and an Authentication concern. All you have to bring yourself is a user sign-up flow (since those are usually bespoke to each application). No need to fear rolling your own authentication setup with these basics provided…

I would be nice to have something to introduce it as a starter authentication, and maybe even explain some of the choices, before pushing you out of the nest to make it your own.

There are some docs:

  1. All generators have help docs (rails g authentication --help), but this one is pretty sparse. :laughing:

  2. There is a generators guide (covers --help): Creating and Customizing Rails Generators & Templates — Ruby on Rails Guides

  3. I’ve found the source code to be very readable (but without any explainer comments):

This feels really strange. I don’t think I’ve ever come across a web dev framework that doesn’t have a “Docs” link on the official site. The “Guides” are excellent but they don’t provide full coverage.

1 Like

Rails does too, just not called “Docs”. The API link on the homepage is that “full coverage” framework documentation. They’re very good and cover every (public) Rails method, including those used within the generator templates.

But this generator…weeell :man_shrugging: :face_with_open_eyes_and_hand_over_mouth: , this is a brand new generator, so the --help docs will probably get a small update as folks like yourself dig in, ask questions, learn, and submit PRs to cover the gap.

P.S. If you’re looking for something, I’ve started watching some GoRails videos on it (Rails 7.1 Authentication From Scratch, etc.), and comparing with the authentication-zero generators.

1 Like

Good tips. Thank you!

Hey there. I found this article written by Jaimy Simon. It explains most of the actors and has a couple of diagrams to get your head around the flow.

Also, as @ansonhoyt mentioned, the API reference contains valuable information about the methods used on the generated concerns/code, mainly has_secure_password and authenticate_by

2 Likes

Oh thanks – this is very helpful.

1 Like