What it is
The module that decides who may call each route. You write the rules, called policies: who may do what to which record. Auth runs them before your handler and refuses a request unless a rule lets it through. Around that it supplies sessions kept in a store, API keys, bearer tokens, sign-in through an identity provider, and password hashing.
Should you use it
What it is not
- An accounts system. Sign-up, password reset, recovery and second factors are your application's.
- An identity provider. It signs users in through one and never issues tokens of its own.
- The rules themselves. It enforces what you write and cannot tell whether a rule is the right one.
When to reach for it
- A route should not be open to everyone.
- Different users may see different records.
- Other services call yours with API keys or tokens.
What good looks like
- Every route declares its access, the public ones included.
- Rules live in policies, not scattered through handlers.
- A user's sessions end when their password changes or their account is disabled.
- Sign-in answers every failure the same way, so nobody learns which accounts exist.