diff --git a/doc/auth/2fa.md b/doc/auth/2fa.md new file mode 100644 index 0000000..ef087b4 --- /dev/null +++ b/doc/auth/2fa.md @@ -0,0 +1,68 @@ +# 2fa + +Abailable endpoints: +- POST `/2fa` +- POST `/2fa/verify` +- DELETE `/2fa` + +Common return: +- 500 with response +```json +{ + "error": "Internal server error" +} +``` + +## POST `/2fa` + +Used to enable 2fa (need to verify after to confirm) + +Inputs: just need a valid JWT cookie + +Returns: +- 200 +```json +{ + "secret": "" + "otpauthUrl": "" +} +``` + +## POST `/2fa/verify` + +Used to confirm 2fa + +Inputs: a valid JWT in cookie and +```json +{ + "token": "" +} +``` + +Returns: +- 200 +```json +{ + "msg": "2FA verified successfully" +} +``` +- 401 || 400 || 404 +```json +{ + "error": "" +} +``` + +## DELETE `/2fa` + +Used to remove 2fa + +Inputs: a valid JWT in cookie + +Returns: +- 200 +```json +{ + "msg": "TOTP removed" +} +``` diff --git a/doc/auth/login.md b/doc/auth/login.md new file mode 100644 index 0000000..76945d3 --- /dev/null +++ b/doc/auth/login.md @@ -0,0 +1,65 @@ +# Login + +Abailable endpoints: +- POST `/login` +- GET `/login/google` +- GET `/login/google/callback` + +Common return: +- 500 with response +```json +{ + "error": "Internal server error" +} +``` + +## POST `/login` + +Used to login + +Input needed : +```json +{ + "user": "", + "password": "" +} +``` + +Can return: +- 200 with response and cookie in header +```json +{ + "msg": "Login successfully" +} +``` +- 400 with response +```json +{ + "error": "" +} +``` + +## GET `/login/google` + +Used to redirect the user to the login page for google auth + +Always return: +- redirect to the google auth url + +## GET `/login/google/callback` + +Used to get the callback from google and confirm the login + +Can return: +- 400 with response +```json +{ + "error": "" +} +``` +- 200 with response and cookie in header +```json +{ + "msg": "Login successfully" +} +``` diff --git a/doc/auth/me.md b/doc/auth/me.md new file mode 100644 index 0000000..4c907e2 --- /dev/null +++ b/doc/auth/me.md @@ -0,0 +1,5 @@ +GET `/me` + +Inputs : just need the JWT cookie + +Returns the user of the account diff --git a/doc/auth/register.md b/doc/auth/register.md new file mode 100644 index 0000000..55caca5 --- /dev/null +++ b/doc/auth/register.md @@ -0,0 +1,65 @@ +# Register + +Available endpoints: +- POST `/register` +- GET `/register/google` +- GET `/register/google/callback` + +Common return: +- 500 with response +```json +{ + "error": "Internal server error" +} +``` + +## POST `/register` + +Used to register + +Input needed : +```json +{ + "user": "", + "password": "" +} +``` + +Can return: +- 200 with response and cookie in header +```json +{ + "msg": "Register successfully" +} +``` +- 400 with response +```json +{ + "error": "" +} +``` + +## GET `/register/google` + +Used to redirect to the google auth page + +Always return: +- redirect to the google auth url + +## GET `/register/google/callback` + +Used to get the callback from google and register + +Can return: +- 400 with response +```json +{ + "error": "" +} +``` +- 200 with response and cookie in header +```json +{ + "msg": "Register successfully" +} +```