Create different methods to authenticate a user.
- create a connection to the DB.
- check user credentials match.
- thrid party connection.
- return user with roles and permissions.
Methods: isAuthtenticated.
-
DB credentials.
-
Google oAuth2 keys
-
login POST:
receive the credentials base64 format in basic Auth headers.
-
refresh_token POST:
Generate a new token and refresh token using the old refresh token
-
logout DELETE:
Remove the token and refresh token
-
google oAuth2
get google authorization and save the token an refresh token. continue our flow to exchange the token. to refresh token verify again with google.
-
Token extractor.
get the token from Authorization Header
-
Toke verification
verify the token to be valid.
https://github.com/sindresorhus/np https://www.npmjs.com/package/go-auth-library
Doc: https://app.gitbook.com/@ventura/s/docs/microservices/go-auth-lib