Giter VIP home page Giter VIP logo

password-validator's Introduction

Passval

This is a simple password validation service. It is designed to provide a REST API where a password is submitted and then it is validated against the following rules:

  • At least 9 characters
  • At least 1 digit
  • At least 1 upper case letter
  • At least 1 lower case letter
  • At least 1 special character
  • Do not contain a repeated character
  • Do not contain whitespace

A special character is a character in the list:

!@#$%^&(){}[]:;<>,.?/~_+-=\|

Tech stack

This service is developed using Springboot and Kotlin. Although that does not have Docker files neither CI files, it is easy to dockerize and run into a CI pipeline.

The project is structured following DDD definitions and Onion Architecture, so it's simple to change just the framework, for example, change Spring for some reactive framework.

Running

To build, please run the command in the root dir:

./mvnw clean install

And then, to start service:

java -jar ./application/target/application-1.0-SNAPSHOT.jar

After that, service will be running at port 9090 and you can access a Swagger UI page at: http://localhost:9090/swagger-ui.html

You can use directly swagger page to test or do a curl request:

curl -X POST "http://localhost:9090/password/validate" -H "accept: application/json" -H "Content-Type: application/x-www-form-urlencoded" -d "password=asd"

This request will return a validation message in the format:

{ "valid": false, "msg": "Nove ou mais caracteres" }

where valid indicates if the input password is valid and msg the proper validation message to help user to understand why password is not valid.

How it works

After a POST of the desired password through the API, this input will be tested against many independent validators. Each validator has a rule like mentioned before. If some of these rules is not matched, then password is not valid.

Each validator has a validation message that explicits why password is invalid. This way is easy to an user to understand why password is invalid. Also it is very easy to use in an UI. Just call API and show message to user.

To create a new validation, just implement PasswordValidator and register into passwordValidators Spring bean.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.