vt-middleware / passay

Password policy enforcement for Java.
http://www.passay.org
Other
275 stars 63 forks source link

Generate regex for combination of Rules. #113

Closed mahesh1996 closed 4 years ago

mahesh1996 commented 4 years ago

The library should have an option to generate regex containing a set of rules. This will help to generate regex which can be used for client-side validation also.

dfish3r commented 4 years ago

You'll have to elaborate on this request. There is an AllowedRegexRule and IllegalRegexRule, both of which expose the Pattern they are using.

mahesh1996 commented 4 years ago

Yes AllowedRegexRule and IllegalRegexRule both generate Pattern but consider the below scenario. There is a system in which a person can create a set of rules (e.g combination of LengthRule and AllowedCharacterRule ) from UI but hasn't knowledge of Regex. Now whenever in any place in UI I want to apply this rule from client-side validation, I need regex. So if Passay allows generating regex of the set of rules then I can directly provide Regex to UI and then can validate accordingly.

Right now UI also has to implement a set of Rules provided by Passay for such scenario.

Please revert If I am missing anything.

dfish3r commented 4 years ago

Even if I was confident I could generate a regular expression for some set of rules in Java, I wouldn't be confident that same expression would be functionally the same in JavaScript. Also note that many rules can't be expressed as regular expressions, so any implementation would have to use a subset of the available rules.

The typical approach right now is to expose your password validation as a RESTful endpoint that returns JSON and use that endpoint for validation in your client code.

dfish3r commented 4 years ago

No feedback from reporter. Feel free to reopen this for further discussion.