Skip to content

Commit 96feb4e

Browse files
flash1293claude
andcommitted
Consolidate project type alias maps and fix es→elasticsearch for UIAM
Move projectTypeToAlias map from kbn-mock-idp-plugin into kbn-mock-idp-utils as the single source of truth, addressing review feedback. Also fix the UIAM normalization to map 'es' to 'elasticsearch' instead of 'search'. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 9f490b6 commit 96feb4e

3 files changed

Lines changed: 21 additions & 14 deletions

File tree

packages/kbn-mock-idp-plugin/server/plugin.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ import {
2222
STATEFUL_ROLES_ROOT_PATH,
2323
} from '@kbn/es';
2424
import type { ServerlessProductTier } from '@kbn/es/src/utils';
25-
import { createSAMLResponse, MOCK_IDP_LOGIN_PATH, MOCK_IDP_LOGOUT_PATH } from '@kbn/mock-idp-utils';
25+
import {
26+
createSAMLResponse,
27+
MOCK_IDP_LOGIN_PATH,
28+
MOCK_IDP_LOGOUT_PATH,
29+
projectTypeToAlias,
30+
} from '@kbn/mock-idp-utils';
2631
import { getSAMLRequestId } from '@kbn/mock-idp-utils/src/utils';
2732

2833
import type { ConfigType } from './config';
@@ -39,14 +44,6 @@ const createSAMLResponseSchema = schema.object({
3944
url: schema.string(),
4045
});
4146

42-
// BOOKMARK - List of Kibana project types
43-
const projectToAlias = new Map<string, string>([
44-
['observability', 'oblt'],
45-
['security', 'security'],
46-
['search', 'es'],
47-
['workplaceai', 'workplaceai'],
48-
]);
49-
5047
const tierSpecificRolesFileExists = (filePath: string): boolean => {
5148
try {
5249
return existsSync(filePath);
@@ -56,8 +53,8 @@ const tierSpecificRolesFileExists = (filePath: string): boolean => {
5653
};
5754

5855
const readServerlessRoles = (projectType: string, productTier?: ServerlessProductTier) => {
59-
if (projectToAlias.has(projectType)) {
60-
const alias = projectToAlias.get(projectType)!;
56+
if (projectTypeToAlias.has(projectType)) {
57+
const alias = projectTypeToAlias.get(projectType)!;
6158

6259
const tierSpecificRolesResourcePath =
6360
productTier && resolve(SERVERLESS_ROLES_ROOT_PATH, alias, productTier, 'roles.yml');

src/platform/packages/private/kbn-mock-idp-utils/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,5 @@ export {
4747
getSAMLRequestId,
4848
createUiamSessionTokens,
4949
createUiamOAuthAccessToken,
50+
projectTypeToAlias,
5051
} from './utils';

src/platform/packages/private/kbn-mock-idp-utils/src/utils.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,11 +292,20 @@ export function generateCosmosDBApiRequestHeaders(
292292
};
293293
}
294294

295-
// Normalizes Kibana CLI project type aliases (e.g. 'oblt', 'es') to the canonical
296-
// ES project type names used in UIAM tokens and ES serverless configuration.
295+
// Kibana project type names mapped to CLI aliases used for role file paths.
296+
export const projectTypeToAlias = new Map<string, string>([
297+
['observability', 'oblt'],
298+
['security', 'security'],
299+
['search', 'es'],
300+
['workplaceai', 'workplaceai'],
301+
]);
302+
303+
// Normalizes CLI aliases (e.g. 'oblt', 'es') to the canonical project type names
304+
// used in UIAM tokens and ES serverless configuration.
305+
// Note: 'es' maps to 'elasticsearch' for UIAM (not 'search' which is the Kibana solution name).
297306
const projectTypeAliases = new Map<string, string>([
298307
['oblt', 'observability'],
299-
['es', 'search'],
308+
['es', 'elasticsearch'],
300309
]);
301310

302311
const normalizeProjectType = (projectType: string): string =>

0 commit comments

Comments
 (0)