Skip to content

CitizenMedia-TW/auth-service

Repository files navigation

auth-service

  • RESTful APIs running on localhost:8085
  • gRPC API running on localhost:50050

RESTful APIs

Login

POST /login/google (Login with Google)
Body (application/json)
key required data type description
idToken true string Id token from Google
Responses
http code content-type response
200 application/json {"name": "username", "email": "user@ex.com", "avatar": "http://avatar.com", "refreshToken": "refreshToken"}
401, 500 text/plain N/A
Cookie Setup

Upon successful login, a cookie named accessToken will be set with HttpOnly and Secure flag.

POST /login/credentials (Login with credentials)
Body (application/json)
key required data type description
mail true string N/A
pass true string N/A
Responses
http code content-type response
200 application/json {"name": "username", "email": "user@ex.com", "avatar": "http://avatar.com", "refreshToken": "refreshToken"}
401 text/plain N/A
Cookie Setup

Upon successful login, a cookie named accessToken will be set with HttpOnly and Secure flag.

Register

POST /register (Register with mail and password)
Body (application/json)
key required data type description
name true string N/A
email true string N/A
password true string N/A
avatar false string Avatar's image URL
Responses
http code content-type response
200 text/plain N/A
401, 500 text/plain N/A

Refresh Token

POST /refresh (Generate a new refresh token)
Body (application/json)
key required data type description
refreshToken true string N/A
Responses
http code content-type response
200 application/json {"name": "username", "email": "user@ex.com", "avatar": "http://avatar.com", "refreshToken": "refreshToken"}
400, 401, 500 text/plain N/A
Cookie Setup

Upon successful refresh, a cookie named accessToken will be set with HttpOnly and Secure flag.

gRPC APIs

The auth-service also expose the functionality the generate and verify the JWT tokens.

Verify

GET /verify (Verify a existing JWT token)
Request Type
key required data type description
token true string Starts with Bearer<space>
Response Type
// Stringified string (Use `JSON.parse()` to parse the string):
{"UserMail":"dev@dev.com","UserName":"dev","exp":1722324402,"iat":1722238002}
key data type description
claims string Stringified JSON data (Empty string if it's expired)
expired bool N/A
Error Code
status code response
UNKNOWN 2, INTERNAL 13 Invalid token
INTERNAL 13 Marchal failed

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages