diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 1451c647f658e..d877fcacd2cdd 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -743,7 +743,7 @@ packages/kbn-rule-data-utils @elastic/security-detections-response @elastic/resp x-pack/plugins/rule_registry @elastic/response-ops @elastic/obs-ux-management-team x-pack/plugins/runtime_fields @elastic/kibana-management packages/kbn-safer-lodash-set @elastic/kibana-security -x-pack/test/security_api_integration/plugins/saml_provider @elastic/kibana-security +packages/kbn-saml-provider-plugin @elastic/kibana-security x-pack/test/plugin_api_integration/plugins/sample_task_plugin @elastic/response-ops x-pack/test/task_manager_claimer_update_by_query/plugins/sample_task_plugin_mget @elastic/response-ops test/plugin_functional/plugins/saved_object_export_transforms @elastic/kibana-core diff --git a/package.json b/package.json index bd48650953021..f6b99101aab36 100644 --- a/package.json +++ b/package.json @@ -761,7 +761,7 @@ "@kbn/rule-registry-plugin": "link:x-pack/plugins/rule_registry", "@kbn/runtime-fields-plugin": "link:x-pack/plugins/runtime_fields", "@kbn/safer-lodash-set": "link:packages/kbn-safer-lodash-set", - "@kbn/saml-provider-plugin": "link:x-pack/test/security_api_integration/plugins/saml_provider", + "@kbn/saml-provider-plugin": "link:packages/kbn-saml-provider-plugin", "@kbn/sample-task-plugin": "link:x-pack/test/plugin_api_integration/plugins/sample_task_plugin", "@kbn/sample-task-plugin-update-by-query": "link:x-pack/test/task_manager_claimer_update_by_query/plugins/sample_task_plugin_mget", "@kbn/saved-object-export-transforms-plugin": "link:test/plugin_functional/plugins/saved_object_export_transforms", diff --git a/packages/kbn-saml-provider-plugin/README.md b/packages/kbn-saml-provider-plugin/README.md new file mode 100644 index 0000000000000..6456631124c27 --- /dev/null +++ b/packages/kbn-saml-provider-plugin/README.md @@ -0,0 +1,3 @@ +# @kbn/saml-provider-plugin + +Saml provider plugin for testing purpose diff --git a/x-pack/test/security_api_integration/packages/helpers/saml/saml_tools.ts b/packages/kbn-saml-provider-plugin/helpers/saml_tools.ts similarity index 94% rename from x-pack/test/security_api_integration/packages/helpers/saml/saml_tools.ts rename to packages/kbn-saml-provider-plugin/helpers/saml_tools.ts index b1dd8f851caf0..4cb481622f681 100644 --- a/x-pack/test/security_api_integration/packages/helpers/saml/saml_tools.ts +++ b/packages/kbn-saml-provider-plugin/helpers/saml_tools.ts @@ -1,8 +1,10 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". */ import crypto from 'crypto'; diff --git a/packages/kbn-saml-provider-plugin/index.ts b/packages/kbn-saml-provider-plugin/index.ts new file mode 100644 index 0000000000000..39d5330d678ef --- /dev/null +++ b/packages/kbn-saml-provider-plugin/index.ts @@ -0,0 +1,24 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +import path from 'path'; + +const resourcesPath = path.resolve(__dirname, 'resources'); + +export const pluginPath = path.resolve(__dirname); + +export const IDP_METADATA_PATHS = { + default: path.resolve(pluginPath, 'metadata.xml'), + saml1: path.resolve(resourcesPath, 'idp_metadata.xml'), + saml2: path.resolve(resourcesPath, 'idp_metadata_2.xml'), + neverLogin: path.resolve(resourcesPath, 'idp_metadata_never_login.xml'), + mockIdpPlugin: path.resolve(resourcesPath, 'idp_metadata_mock_idp.xml'), +}; + +export { getLogoutRequest, getSAMLRequestId, getSAMLResponse } from './helpers/saml_tools'; diff --git a/x-pack/test/security_api_integration/plugins/saml_provider/kibana.jsonc b/packages/kbn-saml-provider-plugin/kibana.jsonc similarity index 100% rename from x-pack/test/security_api_integration/plugins/saml_provider/kibana.jsonc rename to packages/kbn-saml-provider-plugin/kibana.jsonc diff --git a/x-pack/test/security_api_integration/plugins/saml_provider/metadata.xml b/packages/kbn-saml-provider-plugin/metadata.xml similarity index 100% rename from x-pack/test/security_api_integration/plugins/saml_provider/metadata.xml rename to packages/kbn-saml-provider-plugin/metadata.xml diff --git a/packages/kbn-saml-provider-plugin/package.json b/packages/kbn-saml-provider-plugin/package.json new file mode 100644 index 0000000000000..89bf276bc5525 --- /dev/null +++ b/packages/kbn-saml-provider-plugin/package.json @@ -0,0 +1,6 @@ +{ + "name": "@kbn/saml-provider-plugin", + "private": true, + "version": "1.0.0", + "license": "Elastic License 2.0 OR AGPL-3.0-only OR SSPL-1.0" +} \ No newline at end of file diff --git a/x-pack/test/security_api_integration/packages/helpers/saml/idp_metadata.xml b/packages/kbn-saml-provider-plugin/resources/idp_metadata.xml similarity index 100% rename from x-pack/test/security_api_integration/packages/helpers/saml/idp_metadata.xml rename to packages/kbn-saml-provider-plugin/resources/idp_metadata.xml diff --git a/x-pack/test/security_api_integration/packages/helpers/saml/idp_metadata_2.xml b/packages/kbn-saml-provider-plugin/resources/idp_metadata_2.xml similarity index 100% rename from x-pack/test/security_api_integration/packages/helpers/saml/idp_metadata_2.xml rename to packages/kbn-saml-provider-plugin/resources/idp_metadata_2.xml diff --git a/x-pack/test/security_api_integration/packages/helpers/saml/idp_metadata_mock_idp.xml b/packages/kbn-saml-provider-plugin/resources/idp_metadata_mock_idp.xml similarity index 100% rename from x-pack/test/security_api_integration/packages/helpers/saml/idp_metadata_mock_idp.xml rename to packages/kbn-saml-provider-plugin/resources/idp_metadata_mock_idp.xml diff --git a/x-pack/test/security_api_integration/packages/helpers/saml/idp_metadata_never_login.xml b/packages/kbn-saml-provider-plugin/resources/idp_metadata_never_login.xml similarity index 100% rename from x-pack/test/security_api_integration/packages/helpers/saml/idp_metadata_never_login.xml rename to packages/kbn-saml-provider-plugin/resources/idp_metadata_never_login.xml diff --git a/x-pack/test/security_api_integration/plugins/saml_provider/server/index.ts b/packages/kbn-saml-provider-plugin/server/index.ts similarity index 60% rename from x-pack/test/security_api_integration/plugins/saml_provider/server/index.ts rename to packages/kbn-saml-provider-plugin/server/index.ts index 865240e32e9f0..30d47b1a6e091 100644 --- a/x-pack/test/security_api_integration/plugins/saml_provider/server/index.ts +++ b/packages/kbn-saml-provider-plugin/server/index.ts @@ -1,8 +1,10 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". */ import type { CloudSetup } from '@kbn/cloud-plugin/server'; diff --git a/x-pack/test/security_api_integration/plugins/saml_provider/server/init_routes.ts b/packages/kbn-saml-provider-plugin/server/init_routes.ts similarity index 87% rename from x-pack/test/security_api_integration/plugins/saml_provider/server/init_routes.ts rename to packages/kbn-saml-provider-plugin/server/init_routes.ts index f9e84caca0531..2d22cb136ca6e 100644 --- a/x-pack/test/security_api_integration/plugins/saml_provider/server/init_routes.ts +++ b/packages/kbn-saml-provider-plugin/server/init_routes.ts @@ -1,15 +1,14 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". */ import type { CoreSetup, PluginInitializerContext } from '@kbn/core/server'; -import { - getSAMLRequestId, - getSAMLResponse, -} from '@kbn/security-api-integration-helpers/saml/saml_tools'; +import { getSAMLRequestId, getSAMLResponse } from '../helpers/saml_tools'; import type { PluginSetupDependencies } from '.'; diff --git a/packages/kbn-saml-provider-plugin/tsconfig.json b/packages/kbn-saml-provider-plugin/tsconfig.json new file mode 100644 index 0000000000000..5e3d4bf264dee --- /dev/null +++ b/packages/kbn-saml-provider-plugin/tsconfig.json @@ -0,0 +1,21 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "target/types", + "types": [ + "jest", + "node" + ] + }, + "include": [ + "**/*.ts", + ], + "exclude": [ + "target/**/*" + ], + "kbn_references": [ + "@kbn/dev-utils", + "@kbn/cloud-plugin", + "@kbn/core", + ] +} diff --git a/tsconfig.base.json b/tsconfig.base.json index 4471cb1bc6754..65b04932bbd0b 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -1480,8 +1480,8 @@ "@kbn/runtime-fields-plugin/*": ["x-pack/plugins/runtime_fields/*"], "@kbn/safer-lodash-set": ["packages/kbn-safer-lodash-set"], "@kbn/safer-lodash-set/*": ["packages/kbn-safer-lodash-set/*"], - "@kbn/saml-provider-plugin": ["x-pack/test/security_api_integration/plugins/saml_provider"], - "@kbn/saml-provider-plugin/*": ["x-pack/test/security_api_integration/plugins/saml_provider/*"], + "@kbn/saml-provider-plugin": ["packages/kbn-saml-provider-plugin"], + "@kbn/saml-provider-plugin/*": ["packages/kbn-saml-provider-plugin/*"], "@kbn/sample-task-plugin": ["x-pack/test/plugin_api_integration/plugins/sample_task_plugin"], "@kbn/sample-task-plugin/*": ["x-pack/test/plugin_api_integration/plugins/sample_task_plugin/*"], "@kbn/sample-task-plugin-update-by-query": ["x-pack/test/task_manager_claimer_update_by_query/plugins/sample_task_plugin_mget"], diff --git a/x-pack/test/api_integration/deployment_agnostic/default_configs/stateful.config.base.ts b/x-pack/test/api_integration/deployment_agnostic/default_configs/stateful.config.base.ts index bd423762255a5..7275911b5a706 100644 --- a/x-pack/test/api_integration/deployment_agnostic/default_configs/stateful.config.base.ts +++ b/x-pack/test/api_integration/deployment_agnostic/default_configs/stateful.config.base.ts @@ -22,6 +22,7 @@ import { import path from 'path'; import { REPO_ROOT } from '@kbn/repo-info'; import { STATEFUL_ROLES_ROOT_PATH } from '@kbn/es'; +import { IDP_METADATA_PATHS, pluginPath as samlIdPPlugin } from '@kbn/saml-provider-plugin'; import { dockerImage } from '../../../fleet_api_integration/config.base'; import { DeploymentAgnosticCommonServices, services } from '../services'; @@ -61,15 +62,6 @@ export function createStatefulTestConfig { @@ -49,16 +50,6 @@ export default async () => { }, }; - // "Fake" SAML provider - const idpPath = resolve( - __dirname, - '../../test/security_api_integration/plugins/saml_provider/metadata.xml' - ); - const samlIdPPlugin = resolve( - __dirname, - '../../test/security_api_integration/plugins/saml_provider' - ); - const jwksPath = require.resolve('@kbn/security-api-integration-helpers/oidc/jwks.json'); return { @@ -79,7 +70,7 @@ export default async () => { }, esTestCluster: { from: 'serverless', - files: [idpPath, jwksPath], + files: [IDP_METADATA_PATHS.default, jwksPath], serverArgs: [ 'xpack.security.authc.realms.file.file1.order=-100', `xpack.security.authc.realms.native.native1.enabled=false`, diff --git a/x-pack/test_serverless/tsconfig.json b/x-pack/test_serverless/tsconfig.json index ed9a78fde0f6f..7e422bf99dbd4 100644 --- a/x-pack/test_serverless/tsconfig.json +++ b/x-pack/test_serverless/tsconfig.json @@ -98,5 +98,6 @@ "@kbn/core-saved-objects-import-export-server-internal", "@kbn/security-plugin-types-common", "@kbn/ai-assistant-common", + "@kbn/saml-provider-plugin", ] } diff --git a/yarn.lock b/yarn.lock index d8d511ad70965..e642229dd6376 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6216,7 +6216,7 @@ version "0.0.0" uid "" -"@kbn/saml-provider-plugin@link:x-pack/test/security_api_integration/plugins/saml_provider": +"@kbn/saml-provider-plugin@link:packages/kbn-saml-provider-plugin": version "0.0.0" uid ""