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

UserSettingsService setup() method should not be called after start() has been initiated #155949

Closed
kc13greiner opened this issue Apr 26, 2023 · 1 comment · Fixed by #170172
Closed
Assignees
Labels
enhancement New value added to drive a business result Feature:Security/User Profile Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more!

Comments

@kc13greiner
Copy link
Contributor

As a best practice, Core Services' setup() functions should not be called after start() has been initiated.

In the Security Plugin setup() function, a promise is created that provides the Core UserSettingsService setup() method with a UserProfileSettingsClient after the UserProfileService has started. This is not a proper design

The UserSettingsService should be provided with a client during setup, and then that client is passed the required start services after start() has been initiated.

@kc13greiner kc13greiner added Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! enhancement New value added to drive a business result labels Apr 26, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-security (Team:Security)

@kc13greiner kc13greiner self-assigned this Sep 12, 2023
kc13greiner added a commit that referenced this issue Nov 2, 2023
#170172)

## Summary

Closes #155949

The Security Plugin provides a UserProfileSettings client to the core
UserSettingsService on Setup.

With the first implementation of Dark Mode, the client was not set until
the security UserSettingService was started, which violates the
setup/start contract best practices.

Now the client is provided during security plugin setup and the security
UserSettingService will be set on start.

## Testing

Dark Mode should still work as it did before:

- Login as elastic
- Navigate to User Profile by clicking the Avatar menu > Edit Profile
- Choose Dark Mode, Save, and Refresh

- Bonus test: double check Adv. Settings Dark Mode vs User Profiles Dark
Mode
kibanamachine pushed a commit to kibanamachine/kibana that referenced this issue Nov 2, 2023
elastic#170172)

## Summary

Closes elastic#155949

The Security Plugin provides a UserProfileSettings client to the core
UserSettingsService on Setup.

With the first implementation of Dark Mode, the client was not set until
the security UserSettingService was started, which violates the
setup/start contract best practices.

Now the client is provided during security plugin setup and the security
UserSettingService will be set on start.

## Testing

Dark Mode should still work as it did before:

- Login as elastic
- Navigate to User Profile by clicking the Avatar menu > Edit Profile
- Choose Dark Mode, Save, and Refresh

- Bonus test: double check Adv. Settings Dark Mode vs User Profiles Dark
Mode

(cherry picked from commit 195ef3d)
kibanamachine referenced this issue Nov 2, 2023
…in Setup (#170172) (#170429)

# Backport

This will backport the following commits from `main` to `8.11`:
- [Allow UserProfileSettingsClient to be created on Security Plugin
Setup (#170172)](#170172)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT
[{"author":{"name":"Kurt","email":"kc13greiner@users.noreply.github.com"},"sourceCommit":{"committedDate":"2023-11-02T14:51:43Z","message":"Allow
UserProfileSettingsClient to be created on Security Plugin Setup
(#170172)\n\n## Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/155949\r\n\r\nThe Security
Plugin provides a UserProfileSettings client to the
core\r\nUserSettingsService on Setup.\r\n\r\nWith the first
implementation of Dark Mode, the client was not set until\r\nthe
security UserSettingService was started, which violates
the\r\nsetup/start contract best practices.\r\n\r\nNow the client is
provided during security plugin setup and the
security\r\nUserSettingService will be set on start.\r\n\r\n##
Testing\r\n\r\nDark Mode should still work as it did before:\r\n\r\n-
Login as elastic\r\n- Navigate to User Profile by clicking the Avatar
menu > Edit Profile\r\n- Choose Dark Mode, Save, and Refresh\r\n\r\n-
Bonus test: double check Adv. Settings Dark Mode vs User Profiles
Dark\r\nMode","sha":"195ef3dc2bd08fad54a0ea8278abffb4f39d39bc","branchLabelMapping":{"^v8.12.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["chore","Team:Security","release_note:skip","Feature:Security/User
Profile","v8.12.0","v8.11.1"],"number":170172,"url":"https://github.com/elastic/kibana/pull/170172","mergeCommit":{"message":"Allow
UserProfileSettingsClient to be created on Security Plugin Setup
(#170172)\n\n## Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/155949\r\n\r\nThe Security
Plugin provides a UserProfileSettings client to the
core\r\nUserSettingsService on Setup.\r\n\r\nWith the first
implementation of Dark Mode, the client was not set until\r\nthe
security UserSettingService was started, which violates
the\r\nsetup/start contract best practices.\r\n\r\nNow the client is
provided during security plugin setup and the
security\r\nUserSettingService will be set on start.\r\n\r\n##
Testing\r\n\r\nDark Mode should still work as it did before:\r\n\r\n-
Login as elastic\r\n- Navigate to User Profile by clicking the Avatar
menu > Edit Profile\r\n- Choose Dark Mode, Save, and Refresh\r\n\r\n-
Bonus test: double check Adv. Settings Dark Mode vs User Profiles
Dark\r\nMode","sha":"195ef3dc2bd08fad54a0ea8278abffb4f39d39bc"}},"sourceBranch":"main","suggestedTargetBranches":["8.11"],"targetPullRequestStates":[{"branch":"main","label":"v8.12.0","labelRegex":"^v8.12.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/170172","number":170172,"mergeCommit":{"message":"Allow
UserProfileSettingsClient to be created on Security Plugin Setup
(#170172)\n\n## Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/155949\r\n\r\nThe Security
Plugin provides a UserProfileSettings client to the
core\r\nUserSettingsService on Setup.\r\n\r\nWith the first
implementation of Dark Mode, the client was not set until\r\nthe
security UserSettingService was started, which violates
the\r\nsetup/start contract best practices.\r\n\r\nNow the client is
provided during security plugin setup and the
security\r\nUserSettingService will be set on start.\r\n\r\n##
Testing\r\n\r\nDark Mode should still work as it did before:\r\n\r\n-
Login as elastic\r\n- Navigate to User Profile by clicking the Avatar
menu > Edit Profile\r\n- Choose Dark Mode, Save, and Refresh\r\n\r\n-
Bonus test: double check Adv. Settings Dark Mode vs User Profiles
Dark\r\nMode","sha":"195ef3dc2bd08fad54a0ea8278abffb4f39d39bc"}},{"branch":"8.11","label":"v8.11.1","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Kurt <kc13greiner@users.noreply.github.com>
delanni pushed a commit to delanni/kibana that referenced this issue Nov 6, 2023
elastic#170172)

## Summary

Closes elastic#155949

The Security Plugin provides a UserProfileSettings client to the core
UserSettingsService on Setup.

With the first implementation of Dark Mode, the client was not set until
the security UserSettingService was started, which violates the
setup/start contract best practices.

Now the client is provided during security plugin setup and the security
UserSettingService will be set on start.

## Testing

Dark Mode should still work as it did before:

- Login as elastic
- Navigate to User Profile by clicking the Avatar menu > Edit Profile
- Choose Dark Mode, Save, and Refresh

- Bonus test: double check Adv. Settings Dark Mode vs User Profiles Dark
Mode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New value added to drive a business result Feature:Security/User Profile Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants