Skip to content

Commit e99eed5

Browse files
committed
Docker for easier local dev
1 parent ceb1578 commit e99eed5

27 files changed

+509
-169
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
/.idea/
44
/.micronaut/
55
/build/
6+
AuthGenHash/bin

AuthGenHash/.sdkmanrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Enable auto-env through the sdkman_auto_env config
2+
# Add key=value pairs of SDKs to use below
3+
java=21.0.4-tem

AuthGenHash/build.gradle

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
plugins {
2-
id("com.github.johnrengelman.shadow") version "8.1.1"
3-
id("io.micronaut.application") version "4.2.1"
2+
id("com.gradleup.shadow") version "${shadowVersion}"
3+
id("io.micronaut.application") version "${micronautPluginVersion}"
4+
id("io.micronaut.test-resources") version "${micronautPluginVersion}"
5+
id("io.micronaut.aot") version "${micronautPluginVersion}"
46
}
57

68
version = "0.1"
@@ -27,8 +29,8 @@ application {
2729
mainClass.set("io.unityfoundation.auth.AuthGenHashCommand")
2830
}
2931
java {
30-
sourceCompatibility = JavaVersion.toVersion("17")
31-
targetCompatibility = JavaVersion.toVersion("17")
32+
sourceCompatibility = JavaVersion.toVersion("21")
33+
targetCompatibility = JavaVersion.toVersion("21")
3234
}
3335

3436

AuthGenHash/gradle.properties

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
micronautVersion=4.2.4
1+
# Java
2+
javaVersion=21
3+
# Micronaut
4+
micronautVersion=4.8.2
5+
micronautPluginVersion=4.5.3
6+
shadowVersion=8.3.6
-19.5 KB
Binary file not shown.

AuthGenHash/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

AuthGenHash/gradlew

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

AuthGenHash/gradlew.bat

Lines changed: 12 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FrontendDockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Build the frontend and serve with nginx
2-
FROM node:18
2+
FROM node:24 AS builder
33

44
COPY frontend frontend
55
WORKDIR frontend
66
RUN npm install && npm run build
77

88
FROM nginx:1.24.0-alpine
99

10-
COPY --from=0 /frontend/build /usr/share/nginx/html
10+
COPY --from=builder /frontend/build /usr/share/nginx/html
1111
COPY nginx-default.conf /etc/nginx/conf.d/default.conf

README.md

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
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

Comments
 (0)