wso2 / product-is

Welcome to the WSO2 Identity Server source code! For info on working with the WSO2 Identity Server repository and contributing code, click the link below.
http://wso2.github.io/
Apache License 2.0
746 stars 724 forks source link

Add a sample code of custom random password generator for the Ask password documentation. #2501

Open ashensw opened 6 years ago

ashensw commented 6 years ago

When you try to create a user with Ask password option, Identity Server will create a random password for that user using the extension class org.wso2.carbon.user.mgt.common.DefaultPasswordGenerator, until the user configures a new password. So when you enable a Password Policy [1] it might give an error if the generated random password violates the policy that you have defined in your configurations.

To overcome that issue you can write a custom random password generator which does not violate your password policy. I have attached sample code (wso2-sample-custom-password-generator.zip) of a custom password generator for your reference. And do the following steps to use your custom password generator for ask password option.

  1. Build the custom password generator source and get the com.wso2.password.policy-1.0.0.jar file.
  2. Copy the jar file into /repository/components/lib directory.
  3. Start the server.
  4. Then you need to configure your custom password generator class form the management console in order to use it instead of DefaultPasswordGenerator. Please do the following steps.

Then you should be able to create a new user with ask password option without any issue.

Add the above sample for Ask password documentation [2].

[1] https://docs.wso2.com/display/IS541/Password+Patterns [2] https://docs.wso2.com/display/IS541/Creating+Users+using+the+Ask+Password+Option

hauntingEcho commented 5 years ago

it looks like this was already added to the codebase here. However, I wasn't able to find any mention of custom password generators in the documentation

hauntingEcho commented 5 years ago

possibly superseded by #4600