martenframework / marten

The pragmatic web framework.
https://martenframework.com
MIT License
424 stars 24 forks source link

Add support for authentication #71

Closed ellmetha closed 1 year ago

ellmetha commented 1 year ago

Description

Marten should provide an easy way to fire up new projects with a basic authentication flow already set up. To do so:

Marten Auth shard

The new marten-auth shard should provide the necessary logic allowing to authenticate users and validate associated passwords, while also supporting standard password reset flows. The shard should provide a very basic abstract User model, and it should be intended that this model is subclassed in projects wishing to enable authentication.

The responsibilities that are envisioned for this shard are listed below:

The rationale behind only providing an abstract User model is that that way, projects can really own their user models: they can easily add new fields to them and generate migrations if they need to, and they don't depend on a third-party app for such "core" models. Projects could even choose to stop using the marten-auth shard after a while if they need to adapt the authentication further, but at least the shard would provide a good (and convenient) starting point that projects needing authentication could rely on.

Integration in Marten

A new --with-auth option should be added to the new management command. When set, this option should result in the generated project to:

Implementation