You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This project is a minimal web application designed to visually demonstrate the difference between guest and authenticated user access to backend services using OpenID Connect (OIDC). It serves as a practical example and base implementation for integrating standard OIDC authentication flows in a modern web stack.
8
+
9
+
**Key Features:**
10
+
11
+
***Guest vs. Authenticated Views:** Clearly shows different UI states and data access based on whether the user is logged in or browsing as a guest.
12
+
***OIDC Integration:** Implements standard OIDC Authorization Code flow with PKCE for secure authentication against an OIDC provider (configured for Zitadel).
13
+
***Frontend-Backend Interaction:** Features a React frontend that interacts with a Spring Boot backend API.
14
+
***Protected Resources:** Includes a public API endpoint accessible to everyone and a private endpoint requiring authentication.
15
+
***Session Management:** Demonstrates handling of authentication tokens and session persistence across browser refreshes.
16
+
17
+
**Technology Stack:**
18
+
19
+
***Backend:** Java 21, Spring Boot 3.4.4, Spring Security 6 (Resource Server), Maven
This project was developed with a specific goal: **to create an enterprise-grade, reusable authentication package using a fully automated AI-native coding workflow.**
26
+
27
+
***Goal:** The primary objective was to build a robust foundation for OIDC authentication that adheres to modern best practices, achieves high test coverage (≥80%), includes comprehensive documentation, and can be readily adapted for real-world enterprise projects. A secondary goal was to establish and refine a clear, repeatable workflow for AI-driven software development using VScode and Roo Code.
28
+
***Process:**
29
+
* The initial Product Requirements Document (PRD), Architecture Guidelines, Coding Guidelines, and High-Level Plan were drafted using an AI assistant (o3).
30
+
* From that point, the entire implementation followed a strictly automated flow defined in `.clinerules` and `.roomodes`, executed by Roo Code.
31
+
* While highly automated, the workflow incorporated deliberate human review checkpoints at key stages (e.g., after planning subtasks for each implementation step). This ensured alignment and allowed for course correction where needed, keeping the human developer in control.
32
+
***AI Models Used:** The core coding tasks were performed by Large Language Models, specifically Anthropic's Sonnet 3.7 and Google's Gemini Pro (preview-03-25). While both were effective, the code generated by Gemini Pro was often preferred, though it came at a higher operational cost.
33
+
***Outcome:** The development process achieved a high degree of automation (estimated at 97%+), successfully producing the target application according to the predefined specifications and quality gates. It validated the AI-native workflow as a viable approach for building quality software components efficiently.
6
34
7
35
## Prerequisites
8
36
@@ -16,13 +44,15 @@ This is a monorepo containing:
16
44
17
45
-`backend/`: Spring Boot 3.4.4 application (Java 21)
18
46
-`frontend/`: React 19 application with TypeScript, Vite, and Tailwind CSS
47
+
-`docs/`: Project documentation, including PRD, architecture, guidelines, and implementation plans.
19
48
20
49
## Getting Started
21
50
22
51
### Backend
23
52
24
53
```bash
25
54
cd backend
55
+
# Ensure .env file is configured (see Environment Variables section)
26
56
./mvnw spring-boot:run
27
57
```
28
58
@@ -33,6 +63,7 @@ The backend will start on http://localhost:8080.
33
63
```bash
34
64
cd frontend
35
65
pnpm install
66
+
# Ensure .env file is configured (see Environment Variables section)
36
67
pnpm dev
37
68
```
38
69
@@ -50,7 +81,7 @@ The frontend implements a caching mechanism for the public health check endpoint
50
81
51
82
## Environment Variables
52
83
53
-
This project uses environment variables for configuration, particularly for OIDC authentication details needed from Step 7 onwards. Template files are provided:
84
+
This project uses environment variables for configuration, particularly for OIDC authentication details. Template files are provided:
54
85
55
86
-`.env.example` (at the project root, for backend configuration)
56
87
-`frontend/.env.example` (in the frontend directory, for frontend configuration)
@@ -77,7 +108,7 @@ To run the application with OIDC authentication enabled, you need to configure t
77
108
78
109
- `VITE_ZITADEL_ISSUER_URI`: The URI of your Zitadel instance.
79
110
- `VITE_ZITADEL_CLIENT_ID`: The Client ID of your Zitadel application.
80
-
- `VITE_ZITADEL_SCOPES`: The OIDC scopes required by the application (e.g., `openid profile email`).
111
+
- `VITE_ZITADEL_SCOPES`: The OIDC scopes required by the application (e.g., `openid profile email private.read`).
81
112
82
113
Additionally, ensure your Zitadel client application is configured with the following settings:
83
114
@@ -144,11 +175,11 @@ The coverage thresholds are configured to require at least 80% coverage for stat
144
175
145
176
- The backend uses Spotless for code formatting. Run `./mvnw spotless:apply` to format the code.
146
177
- The frontend uses ESLint and Prettier for linting and formatting. Run `pnpm lint` and `pnpm format` to lint and format the code.
147
-
- Pre-commit hooks are set up to ensure code quality before commits.
178
+
- Pre-commit hooks are set up using `lint-staged` and `husky`to ensure code quality before commits.
148
179
149
180
## API Endpoints
150
181
151
-
### Health Check
182
+
### Health Check (Public)
152
183
153
184
```bash
154
185
curl -X GET http://localhost:8080/api/v1/public/health
@@ -160,20 +191,19 @@ Example response:
160
191
"message": "Service up"
161
192
}
162
193
163
-
### Testing Private Endpoint
164
-
165
-
To test the private endpoint, you need a valid JWT access token obtained from your OIDC provider (e.g., Zitadel). This token must contain the necessary claims or roles (like `AUTH_USER`) that the backend expects.
194
+
### Private Info (Requires Authentication)
166
195
167
196
```bash
168
-
# Replace <your_jwt_token> with a valid access token
197
+
# Replace <your_jwt_token> with a valid access token obtained via OIDC login
"info": "This is private information for authenticated users."
204
+
"info": "This is private information for authenticated users.",
205
+
"email": "user@example.com"
176
206
}
177
207
```
178
208
179
-
You can obtain a test token from the Zitadel console or by using an OIDC client tool after authenticating.
209
+
You can obtain a test token by logging into the frontend application, which stores the access token. You can inspect network requests or use browser developer tools to find the token.
0 commit comments