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 conditional authentication functions for dynamic password migration #158

Merged

Conversation

ThaminduDilshan
Copy link
Contributor

@ThaminduDilshan ThaminduDilshan commented Apr 22, 2024

Purpose

Currently the approach to migrate users from external systems into WSO2 identity server is to export the user profiles from the existing systems and import into WSO2 Identity Server using the SCIM APIs. However with that method, it is not possible to import the hashed user passwords and have to trigger password resets for each user in the new system. This is not a preferred approach in many cases and need to provide a way to dynamically update user passwords on the fly.

Goals

Provide a way to dynamically update user passwords on the fly for the migrating users.

Approach

This can be achieved using a conditional authentication script. This PR introduces two conditional authentication functions to be used as helper functions for password migration processes. The functions will be as follows.

  1. resolveMultiAttributeLoginIdentifier

    Function to resolve username from the provided login identifier when multi attribute login is enabled in the organization.

    Parameters:

    @param {String} loginIdentifier - User provided login identifier.
    @param {String} tenantDomain - Tenant domain/ organization name.
    @return {String} The resolved username.

    Sample usage:

    var username = resolveMultiAttributeLoginIdentifier(loginIdentifier, tenantDomain);
  2. updateUserPassword

    Function to update the user password.

    Parameters:

    @param {JsAuthenticatedUser} user - User object.
    @param {String} newPassword - New user password.
    @param {Map<String, Object>} eventHandlers - (Optional) An optional map of callback event handlers.

    Sample usage:

    updateUserPassword(user, "newPassword");
    
    updateUserPassword(user, "newPassword", {
        onSuccess: function(context) {
            Log.info("Password updated successfully.");
        },
        onFail: function(context) {
            Log.info("Password update failed.");
        }
    });

Related issue

User stories

Summary of user stories addressed by this change>

Release note

Brief description of the new feature or bug fix as it will appear in the release notes

Documentation

Link(s) to product documentation that addresses the changes of this PR. If no doc impact, enter “N/A” plus brief explanation of why there’s no doc impact

Training

Link to the PR for changes to the training content in https://github.com/wso2/WSO2-Training, if applicable

Certification

Type “Sent” when you have provided new/updated certification questions, plus four answers for each question (correct answer highlighted in bold), based on this change. Certification questions/answers should be sent to [email protected] and NOT pasted in this PR. If there is no impact on certification exams, type “N/A” and explain why.

Marketing

Link to drafts of marketing content that will describe and promote this feature, including product page changes, technical articles, blog posts, videos, etc., if applicable

Automation tests

  • Unit tests

    Code coverage information

  • Integration tests

    Details about the test cases and coverage

Security checks

Samples

Provide high-level details about the samples related to this feature

Related PRs

List any other related PRs

Migrations (if applicable)

Describe migration steps and platforms on which migration has been tested

Test environment

List all JDK versions, operating systems, databases, and browser/versions on which this feature/fix was tested

Learning

Describe the research phase and any blog posts, patterns, libraries, or add-ons you used to solve the problem.

@CLAassistant
Copy link

CLAassistant commented Apr 22, 2024

CLA assistant check
All committers have signed the CLA.

@ThaminduDilshan ThaminduDilshan marked this pull request as draft April 22, 2024 06:19
@ThaminduDilshan
Copy link
Contributor Author

ThaminduDilshan commented May 9, 2024

Unit test issue/ build is fixed with #160

@ThaminduDilshan ThaminduDilshan force-pushed the thamindu-pw-mig-utils branch from 0fb3fe8 to 0a67d64 Compare May 10, 2024 10:57
@ThaminduDilshan ThaminduDilshan force-pushed the thamindu-pw-mig-utils branch from 0a67d64 to f952fc5 Compare May 13, 2024 11:47
@ThaminduDilshan ThaminduDilshan marked this pull request as ready for review May 14, 2024 04:15
@jenkins-is-staging
Copy link

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

@jenkins-is-staging
Copy link

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

Copy link

@jenkins-is-staging jenkins-is-staging left a 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/9163077211

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.

4 participants