Skip to content

Auth Service ‐ API Reference

Vikas Singh edited this page Sep 16, 2025 · 3 revisions

🔐 Auth Service

Authentication & authorization microservice for the Spring Microservices Shop Application.
All protected endpoints use cookie-based authentication – tokens are issued as HTTP-only cookies.

API Endpoints Overview

Method Endpoint Description Auth Required
POST /signup Register a new user
POST /signin Authenticate user and issue auth cookie
POST /refresh-token Refresh access token (using cookie)
POST /verify Verify email/phone with OTP
GET /role Get roles of the current user
POST /resend-otp Resend OTP for verification
POST /forgot-password Initiate password reset (send OTP/link)
POST /reset-password Reset password using OTP
POST /change-password Change password (current → new, via cookie)
GET /me Get profile of the current user

API Reference

Signup

POST /signup

Request Body:

{
  "username": "johndoe",
  "name": "John Doe",
  "email": "[email protected]",
  "password": "Password123!",
  "role": "USER"
}

Signin

POST /signin

Request Body:

{
  "username": "johndoe",
  "password": "Password123!"
}

Response: HTTP-only cookie with token.

Refresh Token

POST /refresh-token

Refreshes access token using the auth cookie.

✅ Cookie required. No request body.

Verify Account

POST /verify

Request Body:

{
  "username": "johndoe",
  "verificationCode": "123456"
}

Resend OTP

POST /resend-otp

Request Body:

{
  "email": "[email protected]"
}

Forgot Password

POST /forgot-password

Request Body:

{
  "email": "[email protected]"
}

Reset Password

POST /reset-password

Request Body:

{
  "email": "[email protected]",
  "verificationCode": "123456",
  "newPassword": "NewPassword123!"
}

Change Password

POST /change-password

✅ Cookie required.

Request Body:

{
  "currentPassword": "Password123!",
  "newPassword": "NewPassword123!"
}

Get Roles

GET /role

✅ Cookie required. No request parameters.

Response Example:

{
  "roles": ["USER", "ADMIN"]
}

Get Current User

GET /me

✅ Cookie required. No request parameters.

Response Example:

{
  "id": "12345",
  "username": "johndoe",
  "name": "John Doe",
  "email": "[email protected]",
  "roles": ["USER"]
}

Author

Vikas Singh