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 API client functions for RecoveryAPI V2 and on demand migration for new configs. #5744

Conversation

RushanNanayakkara
Copy link
Contributor

@RushanNanayakkara RushanNanayakkara commented Jun 13, 2024

Proposed changes in this pull request

-Adds the API client functions for RecoveryAPI V2.

  • Add on demand migration implementation for newly introduced configs under "SMS OTP For Password Recovery" feature.
  • Other improvements required for the same feature.

Related Issues

Related PRs

When should this PR be merged

Should be merged along with all other related PRs for the feature since there are inter dependencies.

Follow up actions

  • Test if users who have had the password recovery option enabled have the feature enabled after the version upgrade.

Checklist (for reviewing)

General

  • Is this PR explained thoroughly? All code changes must be accounted for in the PR description.
  • Is the PR labeled correctly?

Functionality

  • Are all requirements met? Compare implemented functionality with the requirements specification.
  • Does the UI work as expected? There should be no Javascript errors in the console; all resources should load. There should be no unexpected errors. Deliberately try to break the feature to find out if there are corner cases that are not handled.

Code

  • Do you fully understand the introduced changes to the code? If not ask for clarification, it might uncover ways to solve a problem in a more elegant and efficient way.
  • Does the PR introduce any inefficient database requests? Use the debug server to check for duplicate requests.
  • Are all necessary strings marked for translation? All strings that are exposed to users via the UI must be marked for translation.

Tests

  • Are there sufficient test cases? Ensure that all components are tested individually; models, forms, and serializers should be tested in isolation even if a test for a view covers these components.
  • If this is a bug fix, are tests for the issue in place? There must be a test case for the bug to ensure the issue won’t regress. Make sure that the tests break without the new code to fix the issue.
  • If this is a new feature or a significant change to an existing feature? has the manual testing spreadsheet been updated with instructions for manual testing?

Security

  • Confirm this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets.
  • Are all UI and API inputs run through forms or serializers?
  • Are all external inputs validated and sanitized appropriately?
  • Does all branching logic have a default case?
  • Does this solution handle outliers and edge cases gracefully?
  • Are all external communications secured and restricted to SSL?

Documentation

  • Are changes to the UI documented in the platform docs? If this PR introduces new platform site functionality or changes existing ones, the changes should be documented.
  • Are changes to the API documented in the API docs? If this PR introduces new API functionality or changes existing ones, the changes must be documented.
  • Are reusable components documented? If this PR introduces components that are relevant to other developers (for instance a mixin for a view or a generic form) they should be documented in the Wiki.

@jenkins-is-staging
Copy link

PR builder started
Link: https://github.com/wso2/product-is/actions/runs/9547516936

@jenkins-is-staging
Copy link

PR builder completed
Link: https://github.com/wso2/product-is/actions/runs/9547516936
Status: failure

@jenkins-is-staging
Copy link

PR builder started
Link: https://github.com/wso2/product-is/actions/runs/9557845940

@jenkins-is-staging
Copy link

PR builder completed
Link: https://github.com/wso2/product-is/actions/runs/9557845940
Status: failure

Comment on lines +272 to +274
final String localVarAccept = apiClient.selectHeaderAccept(
new String[]{FrameworkConstants.ContentTypes.TYPE_APPLICATION_JSON});
final String localVarContentType = apiClient.selectHeaderContentType(
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really need to define two different variables for localVarAccept and localVarContentType?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Imo having these two in two variables makes the code clearer opposed to having this inside the parameter list of invokeAPI function call.


// Enable all recovery options when Recovery.Notification.Password.Enable value is set as enabled.
// This keeps functionality consistent with previous API versions for migrating customers.
idpProperties.stream().filter(idp -> idp.getName().equals(EMAIL_LINK_PASSWORD_RECOVERY_PROPERTY)).findFirst()
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we switch the attributes order in with equals method to prevent possible null pointers

Copy link
Contributor

Choose a reason for hiding this comment

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

Check other places as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed with f5e241a

@@ -121,6 +121,14 @@ public class IdPManagementDAO {
private static final Log log = LogFactory.getLog(IdPManagementDAO.class);

private static final String OPENID_IDP_ENTITY_ID = "IdPEntityId";
private static final String NOTIFICATION_PASSWORD_ENABLE_PROPERTY
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we move these variables to a constant class and refer every places these are used. I can see few places where we have defined these as private variables.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved to IdPManagementConstants with f5e241a

import static org.wso2.carbon.idp.mgt.util.IdPManagementConstants.PRESERVE_LOCALLY_ADDED_CLAIMS;

public class IdPManagementUtil {

private static final Log log = LogFactory.getLog(IdPManagementUtil.class);

private static final String RECOVERY_NOTIFICATION_PASSWORD_PROPERTY = "Recovery.Notification.Password.Enable";
Copy link
Contributor

Choose a reason for hiding this comment

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

We should move these to a common constant class

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved to IdPManagementConstants with f5e241a

private static final String RECOVERY_NOTIFICATION_PASSWORD_PROPERTY = "Recovery.Notification.Password.Enable";
private static final String EMAIL_LINK_PASSWORD_RECOVERY_PROPERTY
= "Recovery.Notification.Password.emailLink.Enable";
private static final String SMS_OTP_PASSWORD_RECOVERY_PROPERTY = "Recovery.Notification.Password.smsOtp.Enable";
Copy link
Contributor

Choose a reason for hiding this comment

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

Have we added these configs to identity.xml, identity.xml.j2 and default.json files?

Copy link
Contributor Author

@RushanNanayakkara RushanNanayakkara Jun 19, 2024

Choose a reason for hiding this comment

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

No. These are governance configs which are stored in the database as resident IDP properties.

@Override
public String toString() {

return "class RecoveryResponse {\n" +
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use the approach use in other response classes to implement this toString method? using a StringBuilder

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed with 8132e60

@@ -4080,4 +4080,10 @@
</CacheInvalidator>
{% endif %}

<ConfigSwitching>
Copy link
Contributor

Choose a reason for hiding this comment

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

As a practice, we add these configs to identity.xml file as well. Shall we add this to identity.xml file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed with 8132e60

@RushanNanayakkara RushanNanayakkara merged commit 0db8132 into wso2:master Jun 25, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants