Skip to content

Commit 69ce696

Browse files
authored
Add documentation for Credentials Domain
Document the credentials domain, including core concepts, types, validation, integration with users, lifecycle, and security behavior.
1 parent 0001a0e commit 69ce696

File tree

1 file changed

+115
-0
lines changed

1 file changed

+115
-0
lines changed
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# 🔐 Credentials Domain
2+
3+
Credentials in UltimateAuth define how a user proves their identity.
4+
5+
## 🧠 Core Concept
6+
7+
Authentication is not tied to users directly.
8+
9+
👉 It is performed through credentials.
10+
11+
<br>
12+
13+
## 🔑 What is a Credential?
14+
15+
A credential represents a secret or factor used for authentication.
16+
17+
Examples:
18+
19+
- Password
20+
- OTP (future)
21+
- External providers (future)
22+
23+
<br>
24+
25+
## 🔒 Password Credential
26+
27+
The default credential type is password.
28+
29+
A password credential contains:
30+
31+
- Hashed secret (never raw password)
32+
- Security state (active, revoked, expired)
33+
- Metadata (last used, source, etc.)
34+
35+
👉 Credentials are always stored securely and validated through hashing.
36+
37+
<br>
38+
39+
## ⚙️ Credential Validation
40+
41+
Credential validation is handled by a validator:
42+
43+
- Verifies secret using hashing
44+
- Checks credential usability (revoked, expired, etc.)
45+
46+
👉 Validation is isolated from business logic.
47+
48+
<br>
49+
50+
## 🔗 Integration with Users
51+
52+
Credentials are NOT created directly inside user logic.
53+
54+
Instead:
55+
56+
👉 They are integrated via lifecycle hooks
57+
58+
Example:
59+
60+
- When a user is created → password credential may be created
61+
- When a user is deleted → credentials are removed
62+
63+
👉 This keeps domains decoupled.
64+
65+
<br>
66+
67+
## 🔄 Credential Lifecycle
68+
69+
Credentials support:
70+
71+
- Creation
72+
- Secret change
73+
- Revocation
74+
- Expiration
75+
- Deletion
76+
77+
<br>
78+
79+
## 🔁 Security Behavior
80+
81+
Credential changes trigger security actions:
82+
83+
- Changing password revokes sessions
84+
- Reset flows require verification tokens
85+
- Invalid attempts are tracked
86+
87+
👉 Credentials are tightly coupled with security.
88+
89+
<br>
90+
91+
## 🔑 Reset Flow
92+
93+
Password reset is a multi-step process:
94+
95+
1. Begin reset (generate token or code)
96+
2. Validate token
97+
3. Apply new secret
98+
99+
👉 Reset flow is protected against enumeration and abuse.
100+
101+
<br>
102+
103+
## 🧠 Mental Model
104+
105+
Users define identity.
106+
107+
Credentials define authentication.
108+
109+
## 🎯 Summary
110+
111+
- Credentials handle authentication secrets
112+
- Password is default but extensible
113+
- Integrated via lifecycle hooks
114+
- Strong security guarantees
115+
- Fully extensible for new credential types

0 commit comments

Comments
 (0)