-
Notifications
You must be signed in to change notification settings - Fork 554
Add validation for admin password reset config updates. #6664
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
base: master
Are you sure you want to change the base?
Add validation for admin password reset config updates. #6664
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6664 +/- ##
============================================
+ Coverage 48.20% 48.35% +0.14%
- Complexity 16407 16468 +61
============================================
Files 1830 1833 +3
Lines 109630 111852 +2222
Branches 20646 21035 +389
============================================
+ Hits 52849 54083 +1234
- Misses 49552 50451 +899
- Partials 7229 7318 +89
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
PR builder started |
PR builder completed |
PR builder started |
PR builder completed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving the pull request based on the successful pr build https://github.com/wso2/product-is/actions/runs/14266111360
if(isMultipleConfigsEnabled(configs)) { | ||
throw IdPManagementUtil.handleClientException( | ||
IdPManagementConstants.ErrorMessage.ERROR_CODE_INVALID_CONNECTOR_CONFIGURATION, | ||
"Enabling admin forced password reset option while other options are enabled is not allowed"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are only allowing to enable only one config for a given time and returning email link enabled when all configs are disabled, do we need to add additional validation to ensure that user not disabling all configs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we can do that validation at this level, let's validate from here and return proper client error. Otherwise as we do the correction, it might looks the previous action didn't committed properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added from e91aa1e
@@ -598,7 +598,7 @@ CREATE TABLE IF NOT EXISTS IDP_METADATA ( | |||
DISPLAY_NAME VARCHAR(255), | |||
TENANT_ID INTEGER DEFAULT -1, | |||
PRIMARY KEY (ID), | |||
CONSTRAINT IDP_METADATA_CONSTRAINT UNIQUE (IDP_ID, NAME), | |||
-- CONSTRAINT IDP_METADATA_CONSTRAINT UNIQUE (IDP_ID, NAME), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this constraint since with the config correction get call tries to update the admin forced password email link config to true while mocked IDP properties are passed rather than the real IDP properties from the database.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds validations for admin password reset configuration updates to ensure that only one of the possible options (Email Link, Email OTP, Offline, SMS OTP) is enabled at a time, and provides automatic correction when all are disabled. Key changes include the introduction of new validation methods in IdPManagementUtil, updates to test cases in IdPManagementUtilTest, and corresponding constant and DAO modifications to support the new logic.
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
components/idp-mgt/org.wso2.carbon.idp.mgt/src/test/java/org/wso2/carbon/idp/mgt/util/IdPManagementUtilTest.java | Added tests and helper methods for validating admin password reset configurations; contains a variable naming typo. |
components/idp-mgt/org.wso2.carbon.idp.mgt/src/main/java/org/wso2/carbon/idp/mgt/util/IdPManagementUtil.java | Introduced new validation methods for admin password reset options. |
components/idp-mgt/org.wso2.carbon.idp.mgt/src/main/java/org/wso2/carbon/idp/mgt/util/IdPManagementConstants.java | Added new constants for the admin password reset configurations. |
components/idp-mgt/org.wso2.carbon.idp.mgt/src/main/java/org/wso2/carbon/idp/mgt/dao/IdPManagementDAO.java | Updated DAO logic to read the new admin reset configurations and to auto-correct them if necessary. |
Files not reviewed (1)
- components/idp-mgt/org.wso2.carbon.idp.mgt/src/test/resources/dbscripts/h2.sql: Language not supported
Comments suppressed due to low confidence (1)
components/idp-mgt/org.wso2.carbon.idp.mgt/src/main/java/org/wso2/carbon/idp/mgt/dao/IdPManagementDAO.java:6241
- [nitpick] For consistency with other parts of the code, consider using the predefined TRUE_STRING constant instead of String.valueOf(true) when setting the property value.
adminForcedPasswordResetProperty.setValue(String.valueOf(true));
...rg.wso2.carbon.idp.mgt/src/test/java/org/wso2/carbon/idp/mgt/util/IdPManagementUtilTest.java
Outdated
Show resolved
Hide resolved
|
Purpose
Related issues
Approach
Recovery.AdminPasswordReset.RecoveryLink
Recovery.AdminPasswordReset.OTP
Recovery.AdminPasswordReset.Offline
Recovery.AdminPasswordReset.SMSOTP
After merge
[1] https://github.com/wso2-extensions/identity-governance/blob/381c5fffa0d694db0fdecdb1ec17aab40a1adb42/components/org.wso2.carbon.identity.governance/src/main/java/org/wso2/carbon/identity/governance/IdentityGovernanceServiceImpl.java#L76