Skip to content

vladislav-bordiug/GoAuthentication

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Authentication service

Environment variables

Variables are stored in .env file.

  • DATABASE_URL - PostgresSQL database URL
  • SECRET_KEY - secret key for JWT token generation
  • SERVER_IP - server IP in ListenAndServe
  • SERVER_PORT server port in ListenAndServe
  • MAILTRAP_USERNAME - username from Mailtrap
  • MAILTRAP_PASSWORD - password from Mailtrap
  • FROM_EMAIL - the email we use to send emails in Mailtrap

Deployment

Dockerfile for server, server and database are deployed with docker-compose.yml.

Module tests

Tests are in database_test.go, services_test.go and handlers_test.go.

80%+ coverage.

img.png

Documentation

Documentation is in docs.go, swagger.json and swagger.yaml.

Routes

  • /create - the CreateTokens handler generates JWT access and refresh tokens using user's email and guid.
  • /refresh - the RefreshTokens handler refreshes access and refresh tokens using the refresh token received in the X-Refresh-Token header.

Database

Database stores:

  • token id (the same for access and refresh tokens)
  • bcrypt hash of JWT refresh token sign
  • status (used, unused, blocked and so on).

Sending email when the user changes IP

When the IP address changes, the email is sent via Mailtrap. img_1.png

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published