Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clients/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ treat differently from an absent field, so pass it only when you mean it.
| --- | --- |
| Session | `read_current_session`, `revoke_current_session` |
| Credentials | `list_personal_api_keys`, `create_personal_api_key`, `replace_personal_api_key`, `revoke_personal_api_key` |
| Organizations | `list_organization_api_keys`, `list_organizations`, `create_organization`, `read_organization`, `update_organization`, `list_organization_members`, `put_organization_member`, `remove_organization_member`, `list_service_users`, `create_service_user`, `update_service_user` |
| Organizations | `list_organization_api_keys`, `list_organizations`, `enroll_organization`, `create_organization`, `read_organization`, `update_organization`, `list_organization_members`, `put_organization_member`, `remove_organization_member`, `list_service_users`, `create_service_user`, `update_service_user` |
| Service-Users | `list_service_user_api_keys`, `create_service_user_api_key`, `replace_service_user_api_key`, `put_service_user_api_key`, `revoke_service_user_api_key` |
| Settings | `list_platform_settings`, `put_platform_setting` |
| Universes | `adopt_universe`, `create_universe`, `update_universe`, `list_universe_grants`, `put_universe_grant`, `remove_universe_grant`, `read_platform_universe`, `read_universe_access_policy`, `put_universe_access_policy` |
Expand Down
3 changes: 3 additions & 0 deletions clients/python/src/lightspeed_ai/_generated.py
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,9 @@ async def call(self, method: Literal['platform/settings/put'], params: Platform.
async def call(self, method: Literal['platform/organizations/list'], params: Platform.PlatformOrganizationsListParams | None = None,
*, headers: HeadersInput | None = None) -> Platform.PlatformOrganizationsListResult: ...
@overload
async def call(self, method: Literal['platform/organizations/enroll'], params: Platform.PlatformOrganizationsEnrollParams,
*, headers: HeadersInput | None = None) -> Platform.PlatformOrganizationsEnrollResult: ...
@overload
async def call(self, method: Literal['platform/organizations/create'], params: Platform.PlatformOrganizationsCreateParams,
*, headers: HeadersInput | None = None) -> Platform.PlatformOrganizationsCreateResult: ...
@overload
Expand Down
6 changes: 6 additions & 0 deletions clients/python/src/lightspeed_ai/_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
'platform/organizations/list': {'method': 'GET',
'path': '/api/v1/platform/organizations',
'helper': {'name': 'listOrganizations'}},
'platform/organizations/enroll': {'method': 'POST',
'path': '/api/v1/organizations/enroll',
'helper': {'name': 'enrollOrganization'}},
'platform/organizations/create': {'method': 'POST',
'path': '/api/v1/platform/organizations',
'helper': {'name': 'createOrganization'}},
Expand Down Expand Up @@ -158,6 +161,9 @@ async def put_platform_setting(self, params: Api.PlatformSettingsPutParams, *, h
async def list_organizations(self, params: Api.PlatformOrganizationsListParams | None = None, *, headers: HeadersInput | None = None) -> Api.PlatformOrganizationsListResult:
return cast(Api.PlatformOrganizationsListResult, await self._invoke('platform/organizations/list', dict(params or {}), headers))

async def enroll_organization(self, params: Api.PlatformOrganizationsEnrollParams, *, headers: HeadersInput | None = None) -> Api.PlatformOrganizationsEnrollResult:
return cast(Api.PlatformOrganizationsEnrollResult, await self._invoke('platform/organizations/enroll', dict(params or {}), headers))

async def create_organization(self, params: Api.PlatformOrganizationsCreateParams, *, headers: HeadersInput | None = None) -> Api.PlatformOrganizationsCreateResult:
return cast(Api.PlatformOrganizationsCreateResult, await self._invoke('platform/organizations/create', dict(params or {}), headers))

Expand Down
13 changes: 13 additions & 0 deletions clients/python/src/lightspeed_ai/platform_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,19 @@ class PlatformOrganizationsListResult(TypedDict):
canCreate: bool


class PlatformOrganizationsEnrollParams(TypedDict):
handle: str
name: str


class PlatformOrganizationsEnrollResult(TypedDict):
organizationId: str
enrolled: bool
"""
True when this request created the organization; false when the workload already belongs to it.
"""


class PlatformOrganizationsCreateParams(TypedDict):
name: str
handle: str
Expand Down
2 changes: 1 addition & 1 deletion clients/typescript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ Native Platform helpers use `client.platform` and typed parameter objects:
| settings | `listPlatformSettings`, `putPlatformSetting` |
| credentials | `listPersonalApiKeys`, `createPersonalApiKey`, `replacePersonalApiKey`, `revokePersonalApiKey` |
| service-users | `listServiceUserApiKeys`, `createServiceUserApiKey`, `putServiceUserApiKey`, `replaceServiceUserApiKey`, `revokeServiceUserApiKey` |
| organizations | `listOrganizations`, `createOrganization`, `readOrganization`, `updateOrganization`, `listOrganizationMembers`, `putOrganizationMember`, `removeOrganizationMember`, `listOrganizationApiKeys`, `listServiceUsers`, `createServiceUser`, `updateServiceUser` |
| organizations | `listOrganizations`, `enrollOrganization`, `createOrganization`, `readOrganization`, `updateOrganization`, `listOrganizationMembers`, `putOrganizationMember`, `removeOrganizationMember`, `listOrganizationApiKeys`, `listServiceUsers`, `createServiceUser`, `updateServiceUser` |
| universes | `adoptUniverse`, `createUniverse`, `readPlatformUniverse`, `updateUniverse`, `listUniverseGrants`, `putUniverseGrant`, `removeUniverseGrant`, `readUniverseAccessPolicy`, `putUniverseAccessPolicy` |

Additional conveniences include `awaitRun`, `readBlobText`, `putBlob`,
Expand Down
10 changes: 10 additions & 0 deletions clients/typescript/schema/platform-http.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,16 @@
"params": "PlatformOrganizationsListParams",
"result": "PlatformOrganizationsListResult"
},
{
"operationId": "platform/organizations/enroll",
"helper": {
"name": "enrollOrganization"
},
"method": "POST",
"path": "/api/v1/organizations/enroll",
"params": "PlatformOrganizationsEnrollParams",
"result": "PlatformOrganizationsEnrollResult"
},
{
"operationId": "platform/organizations/create",
"helper": {
Expand Down
37 changes: 37 additions & 0 deletions clients/typescript/schema/platform.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2044,6 +2044,43 @@
],
"additionalProperties": false
},
"PlatformOrganizationsEnrollParams": {
"type": "object",
"properties": {
"handle": {
"type": "string",
"pattern": "^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$"
},
"name": {
"type": "string",
"minLength": 1,
"maxLength": 120
}
},
"required": [
"handle",
"name"
],
"additionalProperties": false
},
"PlatformOrganizationsEnrollResult": {
"type": "object",
"properties": {
"organizationId": {
"type": "string",
"minLength": 1
},
"enrolled": {
"type": "boolean",
"description": "True when this request created the organization; false when the workload already belongs to it."
}
},
"required": [
"organizationId",
"enrolled"
],
"additionalProperties": false
},
"PlatformOrganizationsCreateParams": {
"type": "object",
"properties": {
Expand Down
4 changes: 4 additions & 0 deletions clients/typescript/src/generated/platform-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const PLATFORM_CLIENT_HELPERS = {
"listPlatformSettings": "platform/settings/list",
"putPlatformSetting": "platform/settings/put",
"listOrganizations": "platform/organizations/list",
"enrollOrganization": "platform/organizations/enroll",
"createOrganization": "platform/organizations/create",
"readOrganization": "platform/organizations/read",
"updateOrganization": "platform/organizations/update",
Expand Down Expand Up @@ -84,6 +85,9 @@ export class PlatformHelpers {
listOrganizations(params: PlatformOperationParams<"platform/organizations/list"> = {}, options: CallOptions = {}): Promise<PlatformOperationResult<"platform/organizations/list">> {
return this.client.call("platform/organizations/list", params, options);
}
enrollOrganization(params: PlatformOperationParams<"platform/organizations/enroll">, options: CallOptions = {}): Promise<PlatformOperationResult<"platform/organizations/enroll">> {
return this.client.call("platform/organizations/enroll", params, options);
}
createOrganization(params: PlatformOperationParams<"platform/organizations/create">, options: CallOptions = {}): Promise<PlatformOperationResult<"platform/organizations/create">> {
return this.client.call("platform/organizations/create", params, options);
}
Expand Down
19 changes: 19 additions & 0 deletions clients/typescript/src/generated/platform-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,25 @@ export interface PlatformOrganizationsListResult {
}[];
canCreate: boolean;
}
/**
* This interface was referenced by `PlatformApi`'s JSON-Schema
* via the `definition` "PlatformOrganizationsEnrollParams".
*/
export interface PlatformOrganizationsEnrollParams {
handle: string;
name: string;
}
/**
* This interface was referenced by `PlatformApi`'s JSON-Schema
* via the `definition` "PlatformOrganizationsEnrollResult".
*/
export interface PlatformOrganizationsEnrollResult {
organizationId: string;
/**
* True when this request created the organization; false when the workload already belongs to it.
*/
enrolled: boolean;
}
/**
* This interface was referenced by `PlatformApi`'s JSON-Schema
* via the `definition` "PlatformOrganizationsCreateParams".
Expand Down
5 changes: 5 additions & 0 deletions clients/typescript/src/generated/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface PlatformOperationMap {
"platform/settings/list": { params: T.PlatformSettingsListParams; result: T.PlatformSettingsListResult };
"platform/settings/put": { params: T.PlatformSettingsPutParams; result: T.PlatformSettingsPutResult };
"platform/organizations/list": { params: T.PlatformOrganizationsListParams; result: T.PlatformOrganizationsListResult };
"platform/organizations/enroll": { params: T.PlatformOrganizationsEnrollParams; result: T.PlatformOrganizationsEnrollResult };
"platform/organizations/create": { params: T.PlatformOrganizationsCreateParams; result: T.PlatformOrganizationsCreateResult };
"platform/organizations/read": { params: T.PlatformOrganizationsReadParams; result: T.PlatformOrganizationsReadResult };
"platform/organizations/update": { params: T.PlatformOrganizationsUpdateParams; result: T.PlatformOrganizationsUpdateResult };
Expand Down Expand Up @@ -99,6 +100,10 @@ export const PLATFORM_OPERATIONS = {
"method": "GET",
"path": "/api/v1/platform/organizations"
},
"platform/organizations/enroll": {
"method": "POST",
"path": "/api/v1/organizations/enroll"
},
"platform/organizations/create": {
"method": "POST",
"path": "/api/v1/platform/organizations"
Expand Down
66 changes: 66 additions & 0 deletions docs/documentation/deployment/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,72 @@ and review [API keys and service access](../access-and-security/api-keys-and-ser
The [Platform environment settings](../reference/environment-variables.md#platform-backend)
cover sign-in, session lifetimes, and API key expiry.

## Enroll organizations with workload identity

A pipeline can use a short-lived OIDC bearer token to create one shared
organization and act as its Admin service user. Mount a YAML file on each
Platform replica, set `LIGHTSPEED_PLATFORM_FEDERATION_FILE` to its path,
and restart Platform. Use the same file on every replica. Without this
setting, workload federation is off.

This example allows the `apply` ServiceAccount in namespaces starting with
`team-` to enroll up to 50 organizations across the rule. Choose an audience
specific to this deployment and project it into the pipeline pod's token.
Restrict who can run workloads as those ServiceAccounts.

```yaml
issuers:
- name: cluster
issuer: https://oidc.example.com/clusters/prod/
audiences: [lightspeed-platform-prod]
algorithms: [RS256]
maxTokenLifetimeSeconds: 3600
clockSkewSeconds: 60
keys:
discoveryUrl: https://kubernetes.default.svc/.well-known/openid-configuration
jwksUrl: https://kubernetes.default.svc/openid/v1/jwks
caFile: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
enrollment:
- issuer: cluster
subjectPattern: "system:serviceaccount:team-*:apply"
maxOrganizations: 50
handlePattern: "^team-[a-z0-9-]+$"
organization: { universeQuota: null }
serviceUser: { name: deployer, role: admin }
```

Set `issuer` to the exact token `iss`, including any trailing slash. Omit
`keys` to use the issuer's public discovery document and its `jwks_uri`.
For offline verification, use `keys: { jwksFile: /etc/lightspeed/jwks.json }`.
For Kubernetes API discovery as shown above, Platform's own mounted token
must be accepted by the API server and have permission to read discovery
and signing keys. Platform rereads the CA and fetch credential on refresh.
Each replica caches keys for an hour, refreshes on an unknown key ID at most
once per 30 seconds, and accepts previously fetched keys during an outage
for up to 24 hours from their last successful refresh.

Send the workload token as an `Authorization: Bearer` credential with
`POST /api/v1/organizations/enroll` and a JSON body such as
`{"handle":"team-research","name":"Research"}`. Platform uses the first rule
whose issuer and full subject match. In a subject pattern, `*` matches any
substring. The issuer and subject pattern identify the rule for quota
accounting. A null universe quota follows the shared organization default.

| HTTP result | Meaning |
| --- | --- |
| `201` | Platform created the organization, its Admin service user, and the credential. The response contains `organizationId` and `enrolled: true`. |
| `200` | The workload already belongs to this organization. A retry returns the same ID and `enrolled: false`. |
| `401` | The workload token failed verification or the binding is inactive. |
| `403` | The workload or requested handle falls outside enrollment policy, or the credential's restrictions deny the operation. |
| `409` | The handle is taken, the workload already belongs to or enrolled another organization, or the rule is at capacity. |

After enrollment, present a current workload token on ordinary Platform
API requests. Disabling the service user or removing its binding takes
effect on the next request. Its enrollment continues to occupy a rule slot
until the organization is deleted. The Platform audit records the issuer
and subject for enrollment and federated authentication.

## Secure the Temporal connection

Every runtime process opens its own connection to the
Expand Down
1 change: 1 addition & 0 deletions docs/documentation/reference/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ acceptance checks, follow [Company sign-in (SSO)](../access-and-security/single-
| `LIGHTSPEED_PLATFORM_API_KEY_MAX_EXPIRY_DAYS` | Unset | Maximum key lifetime. Unset means no maximum, and keys may be created without expiry when chosen explicitly; set, it also refuses keys without expiry. Both expiry settings accept 1–3650 days. |
| `LIGHTSPEED_PLATFORM_SESSION_IDLE_DAYS` | `30` | Local browser and CLI session inactivity lifetime, from 1 to 365 days. |
| `LIGHTSPEED_PLATFORM_SESSION_MAX_DAYS` | `90` | Absolute local browser and CLI session lifetime, from 1 to 3,650 days. Company sign-in uses its own admission window. |
| `LIGHTSPEED_PLATFORM_FEDERATION_FILE` | Unset | Path to the YAML [workload federation and enrollment policy](../deployment/configuration.md#enroll-organizations-with-workload-identity), read at Platform startup. |
| `LIGHTSPEED_PLATFORM_OIDC_ISSUER` | Unset | Exact OIDC issuer. Setting any OIDC variable enables configuration validation; incomplete configuration fails startup. HTTPS is required except loopback HTTP for development. |
| `LIGHTSPEED_PLATFORM_OIDC_DISCOVERY_URL` | `<issuer>/.well-known/openid-configuration` | Metadata URL override, including providers with a separate discovery path. Must describe the exact issuer. HTTPS except loopback HTTP. |
| `LIGHTSPEED_PLATFORM_OIDC_CLIENT_ID` | Required with OIDC | Confidential application client ID. |
Expand Down
3 changes: 3 additions & 0 deletions platform/backend/src/api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { runtimeHttpRoutes, problem } from "./runtime-http.js";
import type { MiddlewareHandler } from "hono";
import { authenticateRequest, CredentialRateLimit } from "./authentication.js";
import { enrollmentRoutes } from "./routes/enrollment.js";
import { platformRoutes } from "./routes/platform.js";
import { credentialRoutes } from "./credential-routes.js";
import { sessionRoutes } from "./session-routes.js";
Expand Down Expand Up @@ -41,6 +42,8 @@ export function buildApp(ctx: AppContext) {
// bearer tokens).
app.on(["GET", "POST"], "/api/auth/*", (c) => ctx.auth.handler(c.req.raw));

if (ctx.env.federation) app.route("/", enrollmentRoutes(ctx.db, ctx.env.federation));

const authenticated: MiddlewareHandler<{ Variables: ApiVariables }> = async (c, next) => {
const admission = await authenticateRequest(ctx, c.req.raw);
const browserOnly = c.req.path.startsWith("/api/ui/");
Expand Down
Loading