Skip to content

Commit df609ac

Browse files
committed
feat(profile): Handle company field
1 parent b16a124 commit df609ac

5 files changed

Lines changed: 29 additions & 1 deletion

File tree

CONTRIBUTING.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Thank you for your interest in contributing to ioserver-oidc! This document cove
99
- [Architecture rules](#architecture-rules)
1010
- [Component model](#component-model)
1111
- [TypeScript requirements](#typescript-requirements)
12+
- [Development standards](#development-standards)
1213
- [Naming conventions](#naming-conventions)
1314
- [Test suite](#test-suite)
1415
- [Running tests](#running-tests)
@@ -75,6 +76,17 @@ Rules:
7576
- The `OidcConfig` interface is the single source of truth for configuration shape — add new options there first, then propagate to `buildConfig()` and the middlewares
7677
- Tests use `tsconfig.test.json` which extends the base config with looser `module`/`moduleResolution` settings to support top-level `await` in test files
7778

79+
### Development standards
80+
81+
- **Language**: All code (source, comments, documentation, interfaces, variable/function names) must be written in **English**. No exceptions.
82+
- **Single responsibility**: Each class must have one clear responsibility. Prefer multiple small focused classes over a single large one.
83+
- **File size**:
84+
- Target: **≤ 500 lines** per file
85+
- Allowed exception: up to **1 000 lines** for complex business logic where further splitting would harm readability
86+
- Documentation files (`.md`) have no hard limit but should remain concise
87+
- **No implicit `any`**: Enforced by `strict` + `noImplicitAny`. Every exported symbol must be fully typed; use `unknown` with type-guards at boundaries.
88+
- **PR hygiene**: Zero TypeScript errors and zero ESLint warnings before opening a pull request.
89+
7890
### Naming conventions
7991

8092
| Element | Convention |

src/OidcHttpMiddleware.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ export class OidcHttpMiddleware extends BaseMiddleware {
117117
(request as Record<string, unknown>)["roles"] = oidcCtx.roles;
118118
(request as Record<string, unknown>)["permissions"] = oidcCtx.permissions;
119119
(request as Record<string, unknown>)["features"] = oidcCtx.features;
120+
if (oidcCtx.org_id !== undefined) {
121+
(request as Record<string, unknown>)["org_id"] = oidcCtx.org_id;
122+
}
120123
};
121124
}
122125

src/OidcSocketMiddleware.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ export class OidcSocketMiddleware extends BaseMiddleware {
108108
socket.roles = oidcCtx.roles;
109109
socket.permissions = oidcCtx.permissions;
110110
socket.features = oidcCtx.features;
111+
if (oidcCtx.org_id !== undefined) {
112+
socket.org_id = oidcCtx.org_id;
113+
}
111114

112115
// ── 6. Register with session manager (if available) ──────────────
113116
if (typeof appHandle["session"]?.registerSocket === "function") {

src/jwks.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ export async function verifyOidcToken(
9191
// Primary role: first element of the roles array, fallback "user"
9292
const userRole = roles[0] ?? "user";
9393

94-
return {
94+
const org_id = typeof p["org_id"] === "string" ? p["org_id"] : undefined;
95+
96+
const ctx: OidcUserContext = {
9597
userId: sub, // will be replaced by DB id after findOrCreate in middleware
9698
sub,
9799
email: typeof p["email"] === "string" ? p["email"] : null,
@@ -101,4 +103,6 @@ export async function verifyOidcToken(
101103
permissions,
102104
features,
103105
};
106+
if (org_id !== undefined) ctx.org_id = org_id;
107+
return ctx;
104108
}

src/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,10 @@ export interface OidcUserContext {
111111
* user has no active subscription.
112112
*/
113113
features: OidcFeatures;
114+
115+
/**
116+
* Active organization ID from the `org_id` JWT claim.
117+
* Present when the `org` scope was requested and the user has an active organization.
118+
*/
119+
org_id?: string;
114120
}

0 commit comments

Comments
 (0)