Commit 9d01ffd
committed
feat: unify /ai/v1 auth onto NativeAuth + Android session-expiry handling
Two OSS-side changes that unblock a NativeAuth (Quire Cloud) deployment
end-to-end, without the deprecated AI HMAC token mode.
Server — /ai/v1/* delegates to the primary AuthBackend under native auth:
- Add BackendAiAuthenticator, which maps the configured AuthBackend's
AuthUser to an AiPrincipal (subject="native:<id>", tenant_id="local",
auth_mode="native"). create_app() builds it when
auth_backend=native + ai_auth_mode=basic.
- Remove the old crash guard that forbade that combination — it is now the
supported native-AI path. ai_auth_mode=token is unchanged and remains for
its X-2 deprecation window. CalibreWeb Basic default is byte-for-byte
unchanged.
- Extend AiPrincipal.auth_mode with "native"; update README + docstrings.
Android — Bearer session expiry + re-auth signal (NativeAuth has no refresh
endpoint, so the client surfaces re-auth rather than silently refreshing):
- Persist expires_at end-to-end: AccountCredentials.Bearer.expiresAtEpochMs
(+ isExpiredAt), stored in CalibreCredentialStore, parsed from the login
response in ConnectServerViewModel.
- CalibreCredentialStore.needsReauth StateFlow, raised by notifyUnauthorized()
(a 401 on a same-origin Bearer request, via AccountAuthInterceptor's new
non-mutating onBearerUnauthorized callback) and checkSessionExpiry();
reset on save/clear; pre-expired sessions start raised on cold launch.
- AppNavGraph routes to the connect screen when the signal flips. The
interceptor stays a non-retrying Interceptor (no credential mutation from
the network layer).
Tests: server suite green (added native-seam unit + integration coverage);
Android auth + opds unit tests and assembleDebug green.1 parent c04196f commit 9d01ffd
16 files changed
Lines changed: 671 additions & 83 deletions
File tree
- app/src/main/java/io/theficos/ereader/ui
- onboarding
- auth/src
- main/java/io/theficos/ereader/auth
- test/java/io/theficos/ereader/auth
- data/opds/src
- main/java/io/theficos/ereader/data/opds
- test/java/io/theficos/ereader/data/opds
- server
- quire_server
- api
- core
- tests
- integration
- unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
62 | 75 | | |
63 | 76 | | |
64 | 77 | | |
| |||
Lines changed: 26 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
112 | 113 | | |
113 | 114 | | |
114 | 115 | | |
115 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
116 | 122 | | |
117 | 123 | | |
118 | 124 | | |
| |||
181 | 187 | | |
182 | 188 | | |
183 | 189 | | |
184 | | - | |
185 | | - | |
| 190 | + | |
| 191 | + | |
186 | 192 | | |
187 | 193 | | |
188 | 194 | | |
189 | 195 | | |
190 | | - | |
| 196 | + | |
191 | 197 | | |
192 | 198 | | |
193 | 199 | | |
| |||
204 | 210 | | |
205 | 211 | | |
206 | 212 | | |
207 | | - | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
208 | 224 | | |
209 | | - | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
210 | 229 | | |
211 | 230 | | |
212 | 231 | | |
| |||
221 | 240 | | |
222 | 241 | | |
223 | 242 | | |
224 | | - | |
| 243 | + | |
225 | 244 | | |
226 | 245 | | |
227 | 246 | | |
| |||
Lines changed: 31 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
56 | 73 | | |
57 | 74 | | |
58 | 75 | | |
59 | 76 | | |
| 77 | + | |
60 | 78 | | |
61 | 79 | | |
62 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
63 | 92 | | |
64 | | - | |
| 93 | + | |
| 94 | + | |
65 | 95 | | |
66 | 96 | | |
Lines changed: 92 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
55 | 62 | | |
56 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
57 | 81 | | |
58 | 82 | | |
59 | 83 | | |
| |||
119 | 143 | | |
120 | 144 | | |
121 | 145 | | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
122 | 153 | | |
123 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
124 | 160 | | |
125 | 161 | | |
126 | 162 | | |
| |||
131 | 167 | | |
132 | 168 | | |
133 | 169 | | |
| 170 | + | |
134 | 171 | | |
135 | 172 | | |
136 | 173 | | |
137 | 174 | | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
138 | 210 | | |
139 | 211 | | |
140 | 212 | | |
| |||
144 | 216 | | |
145 | 217 | | |
146 | 218 | | |
| 219 | + | |
147 | 220 | | |
148 | 221 | | |
149 | 222 | | |
| |||
162 | 235 | | |
163 | 236 | | |
164 | 237 | | |
| 238 | + | |
165 | 239 | | |
166 | 240 | | |
167 | 241 | | |
| |||
175 | 249 | | |
176 | 250 | | |
177 | 251 | | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
178 | 257 | | |
179 | 258 | | |
180 | 259 | | |
| |||
187 | 266 | | |
188 | 267 | | |
189 | 268 | | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
190 | 272 | | |
191 | 273 | | |
192 | 274 | | |
| |||
227 | 309 | | |
228 | 310 | | |
229 | 311 | | |
230 | | - | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
231 | 320 | | |
232 | 321 | | |
233 | 322 | | |
| |||
245 | 334 | | |
246 | 335 | | |
247 | 336 | | |
| 337 | + | |
248 | 338 | | |
249 | 339 | | |
250 | 340 | | |
0 commit comments