Skip to content

A microservice built in Go, using the framework Chi to validate passwords.

License

Notifications You must be signed in to change notification settings

vitorvasc/password-validator-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Password Validator API

This REST API was built in Go using the Chi framework. This is a simple microservice that provides a RESTful API endpoint that can validate passwords based on a set of predefined rules.

Table of Contents

Features

  • RESTful API endpoint for password validation (/v1/users/password-validation).
  • Modular rule-based validation system.
  • Easy to extend and create new rules for validation.

Sequence Diagram

sequencediagram.org

sequencediagram.org

Available validators

The application provides validators for the following rules:

API Usage

Validate password

Valid password

Request:

POST /v1/users/validate-password
Content-Type: application/json

{
    "password": "YourPwd123!"
}

cURL:

curl --location 'http://localhost:8080/v1/users/validate-password' \
    --header 'Content-Type: application/json' \
    --data '{
        "password": "YourPwd123!"  
    }'

Response:

{
    "valid": true,
    "errors": []
}

Invalid password

Request:

POST /v1/users/validate-password
Content-Type: application/json

{
    "password": "YourPassword123!"    
}

cURL:

curl --location 'http://localhost:8080/v1/users/validate-password' \
    --header 'Content-Type: application/json' \
    --data '{
        "password": "YourPassword123!"      
    }'

Response:

{
    "valid": false,
    "errors": [
        "must not contain repeated characters"
    ]
}

Running the application

Requirements

  • Go 1.23.0 or higher
  • (optional) Docker

Installation

To install the application, follow these steps:

  1. Clone the repository
git clone https://github.om/vitorvasc/password-validator-api.git
  1. Run the application
go run cmd/api/main/main.go

The server will start on port 8080 by default.

Testing

  • Run the tests:
go test -v ./...
  • Run the tests with coverage:
go test -v ./... -cover

Contributing

Feel free to submit issues, fork the repository and create pull requests for any improvements.

About

A microservice built in Go, using the framework Chi to validate passwords.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages