caspian-utils 0.1.26 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/docs/auth.md +7 -6
- package/dist/docs/components.md +281 -213
- package/dist/docs/core-runtime-map.md +4 -4
- package/dist/docs/fetch-data.md +19 -1
- package/dist/docs/project-structure.md +62 -62
- package/dist/docs/pulsepoint-runtime-map.md +63 -17
- package/dist/docs/pulsepoint.md +183 -5
- package/package.json +1 -1
package/dist/docs/auth.md
CHANGED
|
@@ -119,7 +119,7 @@ Important behavior from the current implementation:
|
|
|
119
119
|
- `token_auto_refresh` only changes behavior when the request lifecycle calls `auth.refresh_session()`. In the installed `auth.py`, the flag alone does not refresh expiry by itself.
|
|
120
120
|
- The framework `AuthSettings` dataclass defaults `is_all_routes_private=True`, but the project example above explicitly changes that to `False`.
|
|
121
121
|
- In generated app-owned starter config, `src/lib/auth/auth_config.py` starts with `is_all_routes_private=False`, so routes are public by default until the app chooses stricter route protection.
|
|
122
|
-
- `public_routes`, `auth_routes`, `private_routes`, and `role_based_routes` are exact
|
|
122
|
+
- `public_routes`, `auth_routes`, `private_routes`, and `role_based_routes` are matched as route **scopes**, not exact paths, in the installed `Auth` methods. An entry covers the path itself *and* everything nested under it, so `/admin` also matches `/admin/users`. Segment boundaries are respected (`/admin` does not match `/administration`), and dynamic segments work (`/orders/[id]` matches `/orders/42` and below). Root `/` is the one exception: it matches only `/`, so listing it in `public_routes` does not make the whole site public. Verify the exact rule in `_route_scope_matches_request` before relying on an entry to protect or expose a subtree.
|
|
123
123
|
- `private_routes` matters only when `is_all_routes_private=False`.
|
|
124
124
|
- `role_based_routes` currently expects `PATH -> [ROLES]`, not role names keyed to paths the other way around.
|
|
125
125
|
- `role_identifier` defaults to `role`, and the current `auth.sign_in(...)` flow also normalizes `userRole` into `role` when possible.
|
|
@@ -189,7 +189,7 @@ The installed auth code reads several values from `.env` when explicit values ar
|
|
|
189
189
|
- App-owned startup helpers may also validate `AUTH_SECRET` and refuse production startup when the value is missing or still on a default placeholder.
|
|
190
190
|
- `AUTH_COOKIE_NAME` backs `AuthSettings.cookie_name`.
|
|
191
191
|
- `SESSION_LIFETIME_HOURS` controls `SessionMiddleware.max_age` in the current `main.py` bootstrap.
|
|
192
|
-
- `APP_ENV
|
|
192
|
+
- `APP_ENV` selects the environment, resolved **fail-closed** by `casp.runtime_security.is_production_environment()`: only an explicit development value (`dev`, `development`, `local`, `staging`, `test`, `testing`) turns the development relaxations on, so an unset or misspelled value is treated as production. Production enables secure session cookies and the `Secure` flag on the CSRF cookie.
|
|
193
193
|
- `CASPIAN_BROWSER_SYNC_PORT` can override the development cookie scope suffix used by the current `main.py` bootstrap.
|
|
194
194
|
- `GOOGLE_CLIENT_ID`, `GOOGLE_CLIENT_SECRET`, and `GOOGLE_REDIRECT_URI` back `GoogleProvider`.
|
|
195
195
|
- `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET` back `GithubProvider`.
|
|
@@ -249,11 +249,11 @@ The current `main.py` also wires the session middleware directly, and some apps
|
|
|
249
249
|
|
|
250
250
|
```python
|
|
251
251
|
from starlette.middleware.sessions import SessionMiddleware
|
|
252
|
-
from casp.runtime_security import get_session_secret
|
|
252
|
+
from casp.runtime_security import get_session_secret, is_production_environment
|
|
253
253
|
|
|
254
254
|
|
|
255
255
|
SESSION_LIFETIME_HOURS = int(os.getenv("SESSION_LIFETIME_HOURS", 7))
|
|
256
|
-
IS_PRODUCTION =
|
|
256
|
+
IS_PRODUCTION = is_production_environment()
|
|
257
257
|
|
|
258
258
|
|
|
259
259
|
app.add_middleware(
|
|
@@ -344,7 +344,7 @@ The current installed methods are:
|
|
|
344
344
|
| `auth.is_authenticated()` | Check current auth state | Returns `False` when the payload is missing, malformed, or expired, and clears invalid session data. |
|
|
345
345
|
| `auth.get_payload()` | Read the signed-in payload | Returns the stored dict payload, or wraps non-dict payloads as `{"value": data}`. |
|
|
346
346
|
| `auth.refresh_session()` | Extend expiration | Only updates expiry when `token_auto_refresh=True`. |
|
|
347
|
-
| `auth.check_role(user, allowed_roles)` | Check RBAC access | Reads the configured role field
|
|
347
|
+
| `auth.check_role(user, allowed_roles)` | Check RBAC access | Reads the configured role field (a single role or a list of them) and grants access on any overlap. |
|
|
348
348
|
|
|
349
349
|
Sign-in example:
|
|
350
350
|
|
|
@@ -715,7 +715,8 @@ In the installed implementation:
|
|
|
715
715
|
|
|
716
716
|
- `auth.check_role(...)` reads `user[role_identifier]` when the payload is a dict.
|
|
717
717
|
- If you pass a plain string instead of a dict, that string is treated as the role directly.
|
|
718
|
-
- `
|
|
718
|
+
- That field may hold a single role or a list/tuple/set of them, so a user who is both `editor` and `auditor` passes a check for either. Access is granted when the user's roles and the allowed roles intersect.
|
|
719
|
+
- `role_based_routes` keys are matched as route *scopes*, not exact paths: `get_required_roles(path)` ranks every matching key by specificity and returns the most specific one. A key therefore also covers nested paths (`/admin` gates `/admin/users`), and dynamic segments such as `/orders/[id]` match. A static key wins over a dynamic one, which wins over a catch-all.
|
|
719
720
|
- The installed payload normalization helps when your Prisma include returns a `userRole` object and you want a plain `role` field in the session payload.
|
|
720
721
|
|
|
721
722
|
## OAuth Providers
|