Fix dynamic sign-in options: remove stale default and improve validation#6180
Fix dynamic sign-in options: remove stale default and improve validation#6180cwperks wants to merge 2 commits into
Conversation
- Remove hardcoded [BASIC] default for sign_in_options, use empty list - Add @JsonInclude(NON_EMPTY) so empty sign_in_options is not persisted - Fix getNewSignInOptions to validate against authenticator types instead of domain names - Fix enum resolution to accept BASIC, basic, and basicauth formats - Add integration test verifying persistence behavior Signed-off-by: Craig Perkins <cwperx@amazon.com>
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
Description
This PR improves the dynamic sign-in options feature by fixing validation logic and removing a stale default that prevented the frontend from correctly determining available authentication methods.
Changes
1. Remove hardcoded
sign_in_optionsdefault (ConfigV7.java)Changed the default from
[BASIC]to an empty list and added@JsonInclude(NON_EMPTY)so the field is not serialized when empty. Previously,[BASIC]was persisted to the security index on every cluster bootstrap, even if no admin explicitly configured sign-in options. This caused the frontend to always see["BASIC"]and override theopensearch_dashboards.ymlauth type configuration.With this change:
sign_in_optionspersisted at init time["BASIC"]continues to be read back as before2. Fix
getNewSignInOptionsvalidation (MultiTenancyConfigApiAction.java)The previous validation had two issues:
"basic_internal_auth_domain".contains("basicauth")), which was brittle and dependent on naming conventionsDashboardSignInOption.valueOf(option)which requires the exact Java enum constant name, rejecting valid inputs like"basic"or"basicauth"The new validation:
http_authenticator.type) from enabled auth domainsBASIC), the option value (basic), or the frontend identifier (basicauth)3. Updated tests
ConfigV7Test— Updated to handle absentsign_in_optionsfield when emptyMultiTenancyConfigApiTest— Updated initial assertion to expect empty array; updated error message assertion for invalid optionsSignInOptionsPersistenceTest(new) — Integration test verifying thatsign_in_optionsis not persisted on bootstrap or unrelated config updates, and is only persisted after explicit PUTIssues Resolved
opensearch-project/security-dashboards-plugin#1573
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.