Skip to main content

Auth Service

Purpose

Identity and access management — user registration, authentication, JWT issuance, and session management.

Responsibilities

  • User registration and login
  • JWT access/refresh token issuance
  • Password hashing (bcrypt)
  • Token refresh and revocation
  • Role assignment

Non-Responsibilities

  • Customer profile data (Customer Service)
  • KYC verification (Customer Service)
  • Authorization decisions on resources (downstream services)

APIs

MethodEndpointAuthDescription
POST/api/v1/auth/registerPublicRegister new user
POST/api/v1/auth/loginPublicAuthenticate, return JWT
POST/api/v1/auth/refreshRefresh tokenIssue new access token
POST/api/v1/auth/logoutBearerRevoke refresh token
GET/api/v1/auth/meBearerCurrent user info

Database

TableKey ColumnsDescription
usersid, email, password_hash, statusUser accounts
rolesid, nameRole definitions
user_rolesuser_id, role_idRole assignments
refresh_tokensid, user_id, token_hash, expires_atActive sessions

Kafka

Produces: AuditEventCreated Consumes: None Partition key: user_id

Dependencies

Sync: Customer Service (link user to customer) Async: Audit events

Failure Handling

  • DB down → 503, no auth possible
  • Brute force → account lockout after N failures
  • Token leak → refresh token rotation

Scaling

Stateless compute, horizontal scaling. DB connection pool sizing critical.

Security

bcrypt password hashing. JWT signed with RS256. Rate limit login endpoint.

Observability

Metrics: auth_login_total, auth_login_failures, auth_token_issued. Traces: login flow.