Hi Vikash,
About the properties, not sure have you done it or not, but you need to make sure your properties are uncommented:
This won't work:
# cas.authn.pm.enabled=true
Need to do this:
cas.authn.pm.enabled=true
The password management features of CAS are rather modest, and alternatively should the functionality provide inadequate for your policy, you may always redirect CAS to use a separate and standalone application that is fully in charge of managing the account password and associated flows.
What the above implies is that:
- CAS only provide very simple and basic password management,
- and anything more complex then that, should probably handle outside of CAS.
From your previous comment, I found that your requirement are probably similar to what CAS natively provides, but just barely.
Let's us go through what CAS can provide, see if that fix you:
If you configured everything correctly, you should be able to see this:
There should be a reset your password button.
Clicking on it, will bring you to this page
Entering the proper username (in my case, casuser), you can get a email.
Click on the link, and user can get back to CAS and enter their defined question here:
And then user can change password:
Back to the original login page, and if you can click on the Forgot your username? button, you can get back your username.
Also, I have some bug in the demo, I can actually finial the last step of resetting password and sending username.... However i can tell you that was done before, so probably some of my other feature broke my demo ._.
Let's compare that to your requirement:
1) User first set some security ques for himself/herself upon providng username and password. (That step seems to be done during the provision of account, not in CAS, but as you can see if you do have the question setup, it can be used for verification during password reset)
2) We have two options like forgot password? and forgot username? (As you can see in the above demo, both can be done)
As for my example, my demo above is built using CAS 6 and MySQL, so not sure if all will be totally compatible in CAS 5 and LDAP.
Nonetheless, here's my info:
cas.yml:
cas.authn.jdbc.query:
- user: root
password: ThisIsThePasswordForRoot
driverClass: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://${PROTOCOL_PASSWORD_MANAGEMENT_JDBC}/${PROTOCOL_PASSWORD_MANAGEMENT_JDBC}
sql: SELECT * FROM pm_table_accounts WHERE userid=?
fieldPassword: password
#No password encoding
passwordEncoder.type: NONE
enabled: true
# Allow any password
policyPattern: ^.*
reset.securityQuestionsEnabled: true
autoLogin: true
reset.mail:
text: CAS Password Management JDBC Path is %s
subject: Testing Password Management JDBC
jdbc:
user: root
password: ThisIsThePasswordForRoot
driverClass: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://${PROTOCOL_PASSWORD_MANAGEMENT_JDBC}/${PROTOCOL_PASSWORD_MANAGEMENT_JDBC}
sqlSecurityQuestions: SELECT question, answer FROM pm_table_questions WHERE userid=?
sqlFindEmail: SELECT email FROM pm_table_accounts WHERE userid=?
# Actually no phone setup, so set this to null
sqlFindPhone: SELECT NULL FROM pm_table_accounts WHERE userid=?
sqlFindUser: SELECT userid FROM pm_table_accounts WHERE email=?
sqlChangePassword: UPDATE pm_table_accounts SET password=? WHERE userid=?
autocommit: true
#No password encoding
passwordEncoder.type: NONE
The SQL for MySQL:
DROP TABLE IF EXISTS pm_table_accounts;
DROP TABLE IF EXISTS pm_table_questions;
CREATE TABLE pm_table_accounts (
id INT NOT NULL AUTO_INCREMENT ,
userid varchar(255) NOT NULL,
password varchar(255) NOT NULL,
email varchar(255) NOT NULL,
primary key (id)
);
CREATE TABLE pm_table_questions (
id INT NOT NULL AUTO_INCREMENT ,
userid VARCHAR(255) NOT NULL,
question VARCHAR(255) NOT NULL,
answer VARCHAR(255) NOT NULL,
primary key (id)
);
INSERT INTO pm_table_accounts (userid, password, email)
VALUES
INSERT INTO pm_table_questions (userid, question, answer)
VALUES
('casuser', 'What fruit is best fruit?', 'Mellon'),
('password-management-jdbc', 'Just type something', 'something');
See if the above help you...
Cheers!
- Andy