Skip to main content

User Service

Purpose

user-service stores profile data separate from authentication data.

Responsibilities

  • Create user profile records during registration
  • Return profile data
  • Update profile data
  • List and delete profiles for admins

Dependencies

  • Port: 8082
  • Database: bookstore_user_db
  • Inbound internal API key from auth-service

REST APIs

MethodPathAuthDescription
GET/api/user/{id}YesGet a user profile by ID
POST/api/user/createInternal API keyCreate profile during registration
GET/api/user/AdminList all profiles
PUT/api/user/update/{id}Admin or selfUpdate profile
DELETE/api/user/{id}Admin, not selfDelete profile
GET/api/user/search?keyword=AdminSearch by first name

Security

Public request matchers:

  • /api/user/create

Controller rules:

  • getAll, search, delete: hasRole('ADMIN')
  • update: admin or same user
  • self-delete is blocked with #id.toString() != authentication.name

Database table

users

  • id
  • user_id
  • first_name
  • last_name
  • email
  • phone_number
  • date_of_birth
  • address
  • created_at
  • updated_at

Entity relationship

Profile creation during registration

Notes

auth-service and user-service each have their own user table. That is intentional in the current design:

  • auth-service owns credentials and roles
  • user-service owns profile fields

Error handling

  • Missing internal API key -> AuthorizationDeniedException
  • Missing profile -> service-level not-found exception