Files
osirose-new/auth-service
raven a8755bd3de Add comprehensive documentation and unit tests
Documentation:
- Add detailed README files for all services (auth, character, database, launcher, packet, utils, world)
- Create API documentation for the database service with detailed endpoint specifications
- Document database schema and relationships
- Add service architecture overviews and configuration instructions

Unit Tests:
- Implement comprehensive test suite for database repositories (user, character, session)
- Add gRPC service tests for database interactions
- Create tests for packet service components (bufferpool, connection, packets)
- Add utility service tests (health check, logging, load balancer, redis cache, service discovery)
- Implement auth service user tests
- Add character service tests

Code Structure:
- Reorganize test files into a more consistent structure
- Create a dedicated tests crate for integration testing
- Add test helpers and mock implementations for easier testing
2025-04-09 13:29:53 -04:00
..

Authentication Service

The Authentication Service is responsible for user authentication, session validation, and account management in the MMORPG server architecture.

Overview

The Authentication Service provides gRPC endpoints for:

  • User login and logout
  • Session validation and refresh

It communicates with the external database service to verify user credentials and manage sessions.

Architecture

The service is built using the following components:

  • gRPC Server: Exposes authentication endpoints
  • Database Client: Communicates with the database service for user data
  • Session Client: Manages user sessions
  • Password Hashing: Securely handles password verification

Note

: User registration and password reset functionality are handled by an external system.

Service Endpoints

The Authentication Service exposes the following gRPC endpoints:

Login

Authenticates a user and creates a new session.

rpc Login(LoginRequest) returns (LoginResponse);

Logout

Terminates a user session.

rpc Logout(LogoutRequest) returns (Empty);

ValidateToken

Validates a JWT token.

rpc ValidateToken(ValidateTokenRequest) returns (ValidateTokenResponse);

ValidateSession

Validates a session ID.

rpc ValidateSession(ValidateSessionRequest) returns (ValidateSessionResponse);

RefreshSession

Refreshes an existing session.

rpc RefreshSession(ValidateSessionRequest) returns (RefreshSessionResponse);

Configuration

The service can be configured using environment variables:

  • LISTEN_ADDR: The address to listen on (default: "0.0.0.0")
  • SERVICE_PORT: The port to listen on (default: "50051")
  • LOG_LEVEL: Logging level (default: "info")

Running the Service

Local Development

cargo run

Docker

docker build -t auth-service .
docker run -p 50051:50051 auth-service

Integration with External Systems

The Authentication Service integrates with:

  • Database Service: For user data storage and retrieval
  • Session Service: For session management
  • External Auth System: The service is designed to work with an external authentication system (better-auth) that manages the database schema and user accounts