Skip to content

Batch-944-Adam-Ranieri/af-auth-service

 
 

Repository files navigation

af-auth-service

Microservice responsible for authenticating jwts and for the creation of new users.

Environment Variables

Need to add a .env file in this directory or set in you system environment variables if being done locally. It should include: `

  • AF_SECRET=[INSERT YOUR OWN SECRET HERE]
  • AF_EMAIL_SECRET=[PASSWORD FOR THE EMAIL TO BE USED]
  • AssignForceAuth=[DATABASE URL HERE]
  • AssignForceSalt=[YOUR KEY WORD HERE FOR PASSWORD HASHING] `

Routes, Requests, and Responses

User Registration (POST)

uri: /register

Expected body:

{
  "email": "email",
  "role": "admin | trainer"
}

This route creates a new user in the database with the status of "pending" from the request body. Returns a JSON with a user in the format of:

{
    "userId": id,
    "email": "email",
    "password": null,
    "status": "status",
    "role": "role"
}

Resolve (GET)

uri: /resolve

This route will retrive all users with the status of "pending". Returns a JSON with a set of users in the format of:

{
    "userId": id,
    "email": "email",
    "password": null,
    "status": "status",
    "role": "role"
}

Approve/Deny (PATCH)

uri: /resolve/{userId}

Expected body:

{
  "userId":id,
  "email":"email",
  "status":"status",
  "role": "role"
}

This route will change the user's status accordingly. Returns a user JSON in the format of:

{
    "userId": id,
    "email": "email",
    "password": "hashed password",
    "status": "status",
    "role": "role"
}

Set password (PATCH)

uri: /password

Expected body:

{
    "userId": id,
    "email": "email",
    "password": "password that they wish to set",
}

This route will set set the user's password. Returns a user JSON in the format of:

{
    "userId": id,
    "email": "email",
    "password": "hashed password",
    "status": "status",
    "role": "role"
}

Login (POST)

uri: /login

Expected body:

{
  "email":"email",
  "password":"password"
}

This route will return a JWT if the email and password are correct. Returns a JWT in the form of a string.

Verify (POST)

uri: /verify

A JWT string is expected in the body.

This is simply to verify if the provied JWT is valid. Returns a user JSON in the format of:

{
    "id": id,
    "email": "email",
    "role": "role"
}

Contributors

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 98.0%
  • Dockerfile 2.0%