Skip to content

Commit b3eb242

Browse files
authored
Add flow-based authentication documentation
Introduced a comprehensive guide on flow-based authentication, detailing its principles, processes, and benefits compared to traditional token-based systems.
1 parent 0fcc366 commit b3eb242

File tree

1 file changed

+198
-0
lines changed

1 file changed

+198
-0
lines changed
Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
# 🔄 Flow-Based Authentication
2+
UltimateAuth is not cookie-based or token-based.
3+
4+
👉 It is **flow-based**.
5+
6+
<br>
7+
8+
## 🔑 What Does “Flow-Based” Mean?
9+
In traditional systems, authentication is treated as:
10+
11+
- A cookie
12+
- A JWT token
13+
14+
Once issued, the system simply checks:
15+
16+
> “Is this token valid?”
17+
18+
<br>
19+
20+
UltimateAuth takes a different approach:
21+
22+
👉 Authentication is a **series of controlled flows**, not a static artifact.
23+
24+
<br>
25+
26+
## 🧭 Authentication as Flows
27+
Every authentication operation is an explicit flow:
28+
29+
- **Login**
30+
- **Logout**
31+
- **Validate**
32+
- **Refresh**
33+
- **Re-authentication**
34+
35+
Each flow:
36+
37+
- Is initiated intentionally
38+
- Is processed on the server
39+
- Produces a controlled result
40+
41+
<br>
42+
43+
## 🔁 Example: Login Flow
44+
Instead of:
45+
46+
> “Generate a token and store it”
47+
48+
UltimateAuth does:
49+
```
50+
Login Request
51+
→ Validate credentials
52+
→ Resolve Root
53+
→ Resolve or create Chain
54+
→ Create Session
55+
→ Issue authentication grant
56+
```
57+
58+
👉 Login is not a single step — it is a **managed process**
59+
60+
<br>
61+
62+
## 🔄 Example: Refresh Flow
63+
Traditional systems:
64+
65+
> Refresh = issue new token
66+
67+
UltimateAuth:
68+
```
69+
Refresh Request
70+
→ Validate session
71+
→ Check security constraints
72+
→ Apply policies (if any)
73+
→ Optionally rotate tokens
74+
→ Update session state (if needed)
75+
```
76+
77+
👉 The server decides what actually happens
78+
79+
<br>
80+
81+
## 🔍 Example: Validate Flow
82+
On each request:
83+
```
84+
Incoming Request
85+
→ Extract session/token
86+
→ Validate session
87+
→ Check chain (device context)
88+
→ Verify root security version
89+
→ Build auth state
90+
```
91+
92+
👉 Validation is not just “token valid?”
93+
94+
<br>
95+
96+
## ⚠️ Why Token-Based Thinking Falls Short
97+
Token-based systems assume:
98+
99+
- The token contains truth
100+
- The server trusts the token
101+
102+
This leads to:
103+
104+
- Weak revocation
105+
- No device awareness
106+
- Limited control
107+
108+
<br>
109+
110+
## ✅ UltimateAuth Approach
111+
UltimateAuth treats tokens as:
112+
113+
👉 **transport artifacts**, not sources of truth
114+
115+
The real authority is:
116+
117+
- Root
118+
- Chain
119+
- Session
120+
121+
<br>
122+
123+
## 🧠 Key Idea
124+
> Tokens carry data
125+
> Flows enforce rules
126+
127+
<br>
128+
129+
## 🔐 Server-Controlled by Design
130+
131+
All flows are:
132+
133+
- Executed on the server
134+
- Evaluated against policies
135+
- Subject to security constraints
136+
137+
👉 The client does not control authentication state
138+
139+
<br>
140+
141+
## ⚙️ Flow Examples in Code
142+
143+
Using `IUAuthClient`:
144+
145+
```csharp
146+
await UAuthClient.Flows.LoginAsync(request);
147+
await UAuthClient.Flows.RefreshAsync();
148+
await UAuthClient.Flows.LogoutAsync();
149+
```
150+
👉 Each method represents a server-driven flow
151+
152+
<br>
153+
154+
## 🧩 How This Changes Development
155+
Instead of thinking:
156+
157+
❌ “I need to manage tokens”
158+
159+
You think:
160+
161+
✅ “I need to trigger flows”
162+
163+
<br>
164+
165+
## 📌 Benefits of Flow-Based Authentication
166+
### ✔ Predictable Behavior
167+
- Every action is explicit and controlled.
168+
169+
### ✔ Better Security
170+
- No blind token trust
171+
- Server-side validation
172+
- Policy-driven decisions
173+
174+
### ✔ Extensibility
175+
Flows can be extended with:
176+
177+
- MFA
178+
- Risk-based checks
179+
- Custom policies
180+
181+
### ✔ Consistent Across Clients
182+
Same flows work for:
183+
- Blazor Server
184+
- WASM (PKCE)
185+
- APIs
186+
187+
<br>
188+
189+
## 🧠 Mental Model
190+
If you remember one thing:
191+
192+
👉 Authentication is not a token — it is a process
193+
194+
## ➡️ Next Step
195+
196+
Now that you understand flows:
197+
198+
👉 Continue to Auth Modes

0 commit comments

Comments
 (0)