V3 proposal: Rethinking Lucia once more #1238
pilcrowonpaper
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
V3 proposal: Rethinking Lucia once more
Based on the relatively positive feedback on #1231, I thought I'd write a more comprehensive proposal/RFC. I have not decided on anything and this is just a concept. Here's the overview:
This will be one of the biggest changes to the project.
Redefining Lucia
Lucia will only handle sessions and related database queries. That's it. It will no longer handle the authentication step (OAuth and password check) and users. For an in depth explanation, see #1231. However, in short, the database adapter model and keys are too limiting for handling various auth methods, especially as each project has different requirements. Removing keys allow simple projects to use a more simple mode, and complex projects to not worry about limitations set by Lucia. I'm also thinking of removing APIs like
createUser()
because they're just redundant considering you're likely using an ORM or query builder.We will still provide APIs for implementing OAuth, specifically creating authorization URLs, validating authorization codes, and getting the provider user. We will also provide APIs to hash passwords using recommended algorithms/settings. We will also provide guides/docs on it.
Updated API
Overall, the API will be dramatically simplified:
Adapter API
The adapter API also gets dramatically simplified:
For adapters for session/memory storage, I'm thinking something like this could work:
Using Oslo
Oslo should be the best companion package for Lucia since it provides APIs for:
This does bring a slight change to the
session
table:idle_expires
andactive_expires
will be replaced by a singleexpires
column.id
string
user_id
string
expires
number
OAuth package
The new OAuth package will not be an integration. It will just provide APIs for creating authorization URLs, validating codes, and fetching the provider user:
Maybe a shadcn-like copy-paste approach might be better though.
Migration
See #1231 (comment) for a what possible migration may look like.
Code examples
OAuth (basic)
Multiple OAuth providers
Username & password
Beta Was this translation helpful? Give feedback.
All reactions