Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Mock IDP login page and role switcher #172257

Merged
merged 51 commits into from
Jan 12, 2024

Conversation

thomheymann
Copy link
Contributor

@thomheymann thomheymann commented Nov 30, 2023

Follow up to #170852

Summary

Adds login page and role switcher for development-only identity provider.

Screenshots

Login page

Screenshot 2023-11-30 at 10 33 34

Role switcher

Screenshot 2023-12-02 at 15 22 43

Testing

SAML is only supported by ES when running in SSL mode.

  1. To test the mock identity provider run a serverless project in SSL mode using:
yarn es serverless --ssl
yarn start --serverless=es --ssl
  1. Then access Kibana and login in using "Continue as Test User".

@thomheymann thomheymann marked this pull request as ready for review November 30, 2023 23:58
@thomheymann thomheymann requested review from a team as code owners November 30, 2023 23:58
@thomheymann thomheymann added the release_note:skip Skip the PR/issue when compiling release notes label Dec 1, 2023
Comment on lines +50 to +55
/**
* To respond with HTML page bootstrapping Kibana application without retrieving user-specific information.
* **Note:**
* - Your client-side JavaScript bundle will only be loaded on an anonymous page if `plugin.enabledOnAnonymousPages` is enabled in your plugin's `kibana.jsonc` manifest file.
* - You will also need to register the route serving your anonymous app with the `coreSetup.http.anonymousPaths` service in your plugin's client-side `setup` method.
* */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can feel the pain and suffering in this comment addition 😄

@@ -97,6 +97,7 @@ pageLoadAssetSize:
mapsEms: 26072
metricsDataAccess: 73287
ml: 82187
mockIdpPlugin: 30000
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind if we add a ci:cloud-deploy label? This seems like a gap in the packaging system with a development plugin included in production.

I can see we're skipping the server load but I'm not sure how the client is going to behave.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh..it's not a development plugin but it's pulling in mock-idp-utils which is devOnly. Can you help me understand the workflow in production?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jbudz Both plugins are development-only and are not used in production. The only reason they're broken up into two separate plugins is to avoid cyclic TS projects.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is opts.dev enabled for these QA cloud deployments?

It's not. We're using the same build script we use for releases, i.e. the node scripts/build --release

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pgayvallet Is there any other mechanism in place where Kibana would load in this plugin despite the dev CLI arg not being set?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thomheymann I apologize, I missed the ping. We have one CI script (the SO schema check) that loads Kibana while forcing all plugins to be enabled. but I don't think it would be the issue here.

However, fwiw, I'm not sure the optimizer / bundler ever supported evicting "devOnly" plugins @jbudz?

Having the plugin disabled in production for sure. Not bundling specific plugins into the distributable? AFAIK this was never implemented. I think the bundler will consider all plugins as production code?

Copy link
Contributor

@pgayvallet pgayvallet Dec 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at your PR and at the @kbn/mock-idp-plugin, I'm not sure how we got to the conclusion that this plugin is disabled by default and/or not bundled for production?

The plugin discovery system is now plugged on the package list, so it's not because a plugin in under package instead of /src/plugins or /x-pack/plugins that it will be disabled by default. All packages with a kibana.jsonc file will be considered as a plugin and included in the plugin list automatically (and then loaded).

Also IIRC, the bundler will consider all plugins as production code, meaning that they WILL be included (ignoring, I assume, the devOnly flag that is supposed to work on packages, not plugins)

@jbudz will have to confirm those assumptions of course, bundling/bazel is Operations' territory, not Core's. But if that was the case, the only approach I would think of is to add a configuration to your plugin with a schema forcing it to be disabled for production, like

        enabled: schema.conditional(
          schema.contextRef('dist'),
          true,
          schema.boolean({ defaultValue: false, validate: (raw) => {
              if(raw !== false) { throw "mock idp plugin cannot be enabled in production"}
          } }),
          schema.boolean({ defaultValue: true })
        ),

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, fwiw, I'm not sure the optimizer / bundler ever supported evicting "devOnly" plugins @jbudz?

It's safe to ignore any of my assumptions here. I haven't really been involved with any of the packaging changes. @mistic do you know?

@thomheymann thomheymann added the ci:cloud-deploy Create or update a Cloud deployment label Dec 1, 2023
@jbudz
Copy link
Member

jbudz commented Dec 1, 2023

buildkite test this

@azasypkin azasypkin added ci:cloud-redeploy Always create a new Cloud deployment ci:project-deploy-elasticsearch Create an Elasticsearch Serverless project labels Jan 11, 2024
@azasypkin azasypkin requested a review from a team January 11, 2024 11:55
@azasypkin
Copy link
Member

@elastic/kibana-operations @elastic/kibana-qa @elastic/kibana-security PR is ready for your review!

delanni added a commit to delanni/kibana that referenced this pull request Jan 11, 2024
## Summary
Both cloud and serverless deployments of
elastic#172257 are failing. These are
small additions to help investigation, or fix potential errors.
@@ -255,7 +255,7 @@ export const BuildPackages: Task = {
Path.resolve(pkgDistPath, 'package-map.json'),
JSON.stringify(
packages
.filter((p) => p.isPlugin())
.filter((p) => p.isPlugin() && !p.isDevOnly())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: without this change, @kbn/mock-idp-plugin (dev-only) is included into package-map.json even though it's not actually bundled into the build. Let me know if you have any better ideas how to solve this!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this not going to interfere with other builds?
Is it related to this thread: #172257 (comment)?

@mistic , do you have any opinions on this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@azasypkin I suggest we change that line https://github.com/elastic/kibana/blob/main/src/dev/build/lib/config.ts#L249 with (!p.isPlugin() || (this.pluginFilter(p) && !p.isDevOnly())) instead of adding the check on this line

Copy link
Member

@azasypkin azasypkin Jan 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, @mistic, thanks! Applied your suggestion in f979aa7.

Copy link
Member

@dmlemeshko dmlemeshko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM. Tested locally for all the projects, works perfectly.

Copy link
Contributor

@delanni delanni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ops related changes 👍

@@ -255,7 +255,7 @@ export const BuildPackages: Task = {
Path.resolve(pkgDistPath, 'package-map.json'),
JSON.stringify(
packages
.filter((p) => p.isPlugin())
.filter((p) => p.isPlugin() && !p.isDevOnly())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.filter((p) => p.isPlugin() && !p.isDevOnly())
.filter((p) => p.isPlugin())

@kibana-ci
Copy link
Collaborator

kibana-ci commented Jan 12, 2024

💔 Build Failed

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #24 / Detection Engine API - Update Prebuilt Rules Package @ess @serverless @skipInQA update_prebuilt_rules_package should allow user to install prebuilt rules from scratch, then install new rules and upgrade existing rules from the new package

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
mockIdpPlugin - 43 +43

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/mock-idp-utils - 18 +18
mockIdpPlugin 19 2 -17
total +1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
mockIdpPlugin - 27.8KB +27.8KB

Canvas Sharable Runtime

The Canvas "shareable runtime" is an bundle produced to enable running Canvas workpads outside of Kibana. This bundle is included in third-party webpages that embed canvas and therefor should be as slim as possible.

id before after diff
module count - 5724 +5724
total size - 6.0MB +6.0MB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
mockIdpPlugin - 12.2KB +12.2KB
Unknown metric groups

API count

id before after diff
@kbn/mock-idp-utils - 25 +25
mockIdpPlugin 25 2 -23
total +2

async chunk count

id before after diff
mockIdpPlugin - 1 +1

ESLint disabled line counts

id before after diff
mockIdpPlugin 0 1 +1

Total ESLint disabled count

id before after diff
mockIdpPlugin 0 1 +1

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@azasypkin azasypkin removed ci:cloud-deploy Create or update a Cloud deployment ci:cloud-redeploy Always create a new Cloud deployment ci:project-deploy-elasticsearch Create an Elasticsearch Serverless project labels Jan 12, 2024
@azasypkin azasypkin merged commit 7bee86d into elastic:main Jan 12, 2024
37 of 38 checks passed
@kibanamachine kibanamachine added v8.13.0 backport:skip This commit does not require backporting labels Jan 12, 2024
@legrego
Copy link
Member

legrego commented Jan 13, 2024

Resolves #166340

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:skip Skip the PR/issue when compiling release notes v8.13.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.