|
| 1 | +# UnityAuth |
| 2 | + |
| 3 | +UnityAuth is a comprehensive authentication and authorization service built with modern microservices architecture. It provides JWT-based authentication, user management, and a web-based administration interface. |
| 4 | + |
| 5 | +## Local Development QuickStart |
| 6 | + |
| 7 | +To launch and be a pure consumer of the auth service, you can use the docker compose from the root: |
| 8 | + |
| 9 | +```sh |
| 10 | +docker-compose -f docker-compose.local.yml up |
| 11 | +``` |
| 12 | + |
| 13 | +This will start: |
| 14 | + |
| 15 | +- **UnityAuth API** on port http://localhost:8081 |
| 16 | +- **Frontend UI** on port http://localhost:3001 |
| 17 | +- **MySQL Database** for data persistence |
| 18 | + |
| 19 | +You can log in with these accounts. |
| 20 | +**Password for all the following accounts is 'test'** |
| 21 | + |
| 22 | +- **Unity Administrator ** `[email protected]` |
| 23 | +- **Tenant Administrator ** `[email protected]` |
| 24 | +- **Libre311 Administrator ** `[email protected]` |
| 25 | +- **Libre311 Request Manager ** `[email protected]` |
| 26 | +- **Libre311 Jurisdiction Administrator ** `[email protected]` |
| 27 | +- **Libre311 Jurisdiction Request Manager ** `[email protected]` |
| 28 | +- **Stl sub-tenant admin ** `[email protected]` |
| 29 | + |
| 30 | +## Project Structure |
| 31 | + |
| 32 | +This repository contains three main subprojects: |
| 33 | + |
| 34 | +### 1. UnityAuth (Main Service) |
| 35 | + |
| 36 | +**Location:** `/UnityAuth/` |
| 37 | +**Technology:** Java 21 + Micronaut Framework |
| 38 | + |
| 39 | +The core authentication service that provides: |
| 40 | + |
| 41 | +- JWT token generation and validation |
| 42 | +- User authentication and authorization |
| 43 | +- RESTful API endpoints for authentication operations |
| 44 | +- Database integration with MySQL |
| 45 | +- JWK (JSON Web Key) management for token signing |
| 46 | +- Flyway database migrations |
| 47 | + |
| 48 | +**Key Features:** |
| 49 | + |
| 50 | +- Micronaut-based microservice architecture |
| 51 | +- JWT security with configurable key rotation |
| 52 | +- BCrypt password hashing |
| 53 | +- Database connection pooling with HikariCP |
| 54 | +- Reactive programming support with Reactor |
| 55 | + |
| 56 | +### 2. AuthGenHash (Utility Tool) |
| 57 | + |
| 58 | +**Location:** `/AuthGenHash/` |
| 59 | +**Technology:** Java 17 + Micronaut + PicoCLI |
| 60 | + |
| 61 | +A command-line utility for generating secure password hashes compatible with the UnityAuth service. |
| 62 | + |
| 63 | +**Purpose:** |
| 64 | + |
| 65 | +- Generate BCrypt password hashes for administrative users |
| 66 | +- Secure password handling (interactive mode prevents history logging) |
| 67 | +- Standalone tool for initial system setup and user management |
| 68 | + |
| 69 | +**Usage:** |
| 70 | + |
| 71 | +```bash |
| 72 | +cd AuthGenHash |
| 73 | +./gradlew shadowJar |
| 74 | +java -jar build/libs/AuthGenHash-0.1-all.jar -p |
| 75 | +``` |
| 76 | + |
| 77 | +### 3. Frontend (Web Administration Interface) |
| 78 | + |
| 79 | +**Location:** `/frontend/` |
| 80 | +**Technology:** SvelteKit + TypeScript + Tailwind CSS |
| 81 | + |
| 82 | +A modern web application providing administrative interface for the UnityAuth service. |
| 83 | + |
| 84 | +**Features:** |
| 85 | + |
| 86 | +- User authentication and session management |
| 87 | +- User administration and management |
| 88 | +- Tenant management capabilities |
| 89 | +- Settings configuration |
| 90 | +- Responsive design with Tailwind CSS |
| 91 | +- TypeScript for type safety |
| 92 | +- Comprehensive testing with Playwright and Vitest |
| 93 | + |
| 94 | +**Key Technologies:** |
| 95 | + |
| 96 | +- SvelteKit for the web framework |
| 97 | +- TypeScript for type safety |
| 98 | +- Tailwind CSS for styling |
| 99 | +- Playwright for end-to-end testing |
| 100 | +- Vitest for unit testing |
| 101 | +- ESLint and Prettier for code quality |
| 102 | + |
| 103 | +## Architecture Overview |
| 104 | + |
| 105 | +The system follows a microservices architecture: |
| 106 | + |
| 107 | +1. **Database Layer:** MySQL database for persistent storage |
| 108 | +2. **API Layer:** UnityAuth service provides REST APIs |
| 109 | +3. **Frontend Layer:** SvelteKit web application |
| 110 | +4. **Utility Layer:** AuthGenHash for administrative tasks |
| 111 | + |
| 112 | +## Client Integration |
| 113 | + |
| 114 | +To integrate with the UnityAuth service, add this configuration to your client application's `application.yaml`: |
| 115 | + |
| 116 | +```yaml |
| 117 | +security: |
| 118 | + enabled: true |
| 119 | + token: |
| 120 | + enabled: true |
| 121 | + jwt: |
| 122 | + enabled: true |
| 123 | + signatures: |
| 124 | + jwks: |
| 125 | + unity: |
| 126 | + url: ${AUTH_JWKS:`http://localhost:8081/keys`} |
| 127 | +``` |
| 128 | +
|
| 129 | +## Security Configuration |
| 130 | +
|
| 131 | +The service uses JSON Web Keys (JWK) for token signing. To generate primary and secondary keys: |
| 132 | +
|
| 133 | +1. Visit <https://mkjwk.org/> |
| 134 | +2. Generate JSON Web Keys |
| 135 | +3. Set environment variables: |
| 136 | + - `JWK_PRIMARY`: Primary signing key |
| 137 | + - `JWK_SECONDARY`: Secondary signing key for rotation |
| 138 | + |
| 139 | +## Development Environment |
| 140 | + |
| 141 | +### Prerequisites |
| 142 | + |
| 143 | +- Java 17 or higher |
| 144 | +- Node.js 18 or higher |
| 145 | +- Docker and Docker Compose |
| 146 | +- MySQL 8.0 (if running locally) |
| 147 | + |
| 148 | +### Individual Service Development |
| 149 | + |
| 150 | +#### UnityAuth Service |
| 151 | + |
| 152 | +```bash |
| 153 | +cd UnityAuth |
| 154 | +./gradlew run |
| 155 | +``` |
| 156 | + |
| 157 | +#### Frontend Development |
| 158 | + |
| 159 | +```bash |
| 160 | +cd frontend |
| 161 | +npm install |
| 162 | +npm run dev |
| 163 | +``` |
| 164 | + |
| 165 | +#### AuthGenHash Utility |
| 166 | + |
| 167 | +```bash |
| 168 | +cd AuthGenHash |
| 169 | +./gradlew shadowJar |
| 170 | +java -jar build/libs/AuthGenHash-0.1-all.jar -p |
| 171 | +``` |
0 commit comments