Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { DefaultNamespace } from '../../repositories/NamespaceRepository.js';
import type { RouterOptions } from '../../routes.js';
import { enrichLogger, getLogger, handleError } from '../../util.js';
import { UnauthorizedError } from '../../errors/errors.js';
import { OrganizationRepository } from '../../repositories/OrganizationRepository.js';

export function createFederatedGraphToken(
opts: RouterOptions,
Expand Down Expand Up @@ -71,13 +72,25 @@ export function createFederatedGraphToken(
};
}

const orgRepo = new OrganizationRepository(logger, opts.db, opts.billingDefaultPlanId);
const splitConfigFeature = await orgRepo.getFeature({
organizationId: authContext.organizationId,
featureId: 'split-config-loading',
});

const features: string[] = [];
if (splitConfigFeature?.enabled) {
features.push('split-config-loading');
}

const tokenValue = await signJwtHS256<GraphApiKeyJwtPayload>({
secret: opts.jwtSecret,
token: {
iss: authContext.userId,
federated_graph_id: graph.id,
aud: audiences.cosmoGraphKey, // to distinguish from other tokens
organization_id: authContext.organizationId,
features: features.length > 0 ? features : undefined,
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1420,6 +1420,7 @@ export class OrganizationRepository {
sso: false,
'subgraph-check-extensions': false,
support: false,
'split-config-loading': false,
};

for (const feature of features) {
Expand Down
4 changes: 3 additions & 1 deletion controlplane/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export type FeatureIds =
| 'security'
| 'sso'
| 'subgraph-check-extensions'
| 'support';
| 'support'
| 'split-config-loading';

export type Features = {
[key in FeatureIds]: Feature;
Expand Down Expand Up @@ -498,6 +499,7 @@ export type AuthContext = {
export interface GraphApiKeyJwtPayload extends JWTPayload {
federated_graph_id: string;
organization_id: string;
features?: string[];
}

export interface PluginAccess {
Expand Down
Loading