Skip to main content

Backend Development

The Identity Backend is built with Laravel 12 and FrankenPHP (Octane), providing a high-performance authentication and authorization API.

Technology Stack

  • Framework: Laravel 12
  • Server: FrankenPHP + Laravel Octane
  • Database: PostgreSQL (via CloudNative-PG)
  • Cache: Redis
  • Queue: RabbitMQ
  • Auth: Laravel Sanctum + Passport (OAuth2)

Project Structure

app/
├── Http/
│ ├── Controllers/
│ │ ├── Auth/ # Authentication controllers
│ │ ├── Admin/ # Admin panel controllers
│ │ └── Api/ # API controllers
│ ├── Middleware/ # Custom middleware
│ └── Requests/ # Form requests / validation
├── Models/ # Eloquent models
├── Services/ # Business logic services
├── Policies/ # Authorization policies
└── Events/ # Event classes

Key Models

ModelDescription
UserCore user model with multi-tenant support
TenantTenant/organization model
ApplicationOAuth2 client applications
TrustedDeviceRemembered devices for 2FA
AuditLogAuthentication event log

API Endpoints

All endpoints are prefixed with /api/.

Authentication

  • POST /auth/login - Login with email/password
  • POST /auth/register - Register new user
  • POST /auth/logout - Logout current session
  • POST /auth/2fa/verify - Verify 2FA code
  • POST /auth/pin/verify - Verify PIN code

User Management

  • GET /user - Get current user profile
  • PUT /user/profile - Update profile
  • PUT /user/password - Change password

Admin

  • GET /admin/users - List users (admin only)
  • GET /admin/tenants - List tenants (admin only)
  • POST /admin/tenants - Create tenant

Running Locally

# Install dependencies
composer install

# Run migrations
php artisan migrate

# Start development server
php artisan serve

# Or with Octane (production-like)
php artisan octane:start --server=frankenphp --host=0.0.0.0 --port=8000

Environment Variables

Key environment variables are configured via Kubernetes secrets:

VariableSourceDescription
DB_HOSTpg-credentialsPostgreSQL host
DB_DATABASEpg-credentialsDatabase name
DB_USERNAMEpg-credentialsDatabase user
DB_PASSWORDpg-credentialsDatabase password
RABBITMQ_HOSTrabbitmq-credentialsRabbitMQ host
REDIS_HOSTredis-credentialsRedis host
APP_KEYapp-secretsLaravel application key