Skip to content

Commit bd7de43

Browse files
committed
updated README
1 parent c97886d commit bd7de43

File tree

1 file changed

+43
-13
lines changed

1 file changed

+43
-13
lines changed

README.md

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,36 @@
1-
# Auth‑vs‑Guest Demo Web App
1+
# AI-Developed OIDC Auth Demo (React + Spring Boot)
22

3-
A minimal web application that visually demonstrates the difference between guest and authenticated access to backend services.
3+
[![CI](https://github.com/rhofkens/oidc-auth-react-springboot-demo/actions/workflows/ci.yml/badge.svg)](https://github.com/rhofkens/oidc-auth-react-springboot-demo/actions/workflows/ci.yml)
44

5-
[![CI](https://github.com/[your-username]/oidc-auth-react-springboot-demo/actions/workflows/ci.yml/badge.svg)](https://github.com/[your-username]/oidc-auth-react-springboot-demo/actions/workflows/ci.yml)
5+
## What This Project Does
6+
7+
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
20+
* **Frontend:** React 19, TypeScript, Vite, Tailwind CSS, shadcn/ui, oidc-client-ts
21+
* **Authentication:** OIDC (Authorization Code + PKCE), JWT validation
22+
23+
## Why and How This Project Was Developed
24+
25+
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.
634

735
## Prerequisites
836

@@ -16,13 +44,15 @@ This is a monorepo containing:
1644

1745
- `backend/`: Spring Boot 3.4.4 application (Java 21)
1846
- `frontend/`: React 19 application with TypeScript, Vite, and Tailwind CSS
47+
- `docs/`: Project documentation, including PRD, architecture, guidelines, and implementation plans.
1948

2049
## Getting Started
2150

2251
### Backend
2352

2453
```bash
2554
cd backend
55+
# Ensure .env file is configured (see Environment Variables section)
2656
./mvnw spring-boot:run
2757
```
2858

@@ -33,6 +63,7 @@ The backend will start on http://localhost:8080.
3363
```bash
3464
cd frontend
3565
pnpm install
66+
# Ensure .env file is configured (see Environment Variables section)
3667
pnpm dev
3768
```
3869

@@ -50,7 +81,7 @@ The frontend implements a caching mechanism for the public health check endpoint
5081

5182
## Environment Variables
5283

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:
5485

5586
- `.env.example` (at the project root, for backend configuration)
5687
- `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
77108

78109
- `VITE_ZITADEL_ISSUER_URI`: The URI of your Zitadel instance.
79110
- `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`).
81112

82113
Additionally, ensure your Zitadel client application is configured with the following settings:
83114

@@ -144,11 +175,11 @@ The coverage thresholds are configured to require at least 80% coverage for stat
144175

145176
- The backend uses Spotless for code formatting. Run `./mvnw spotless:apply` to format the code.
146177
- 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.
148179

149180
## API Endpoints
150181

151-
### Health Check
182+
### Health Check (Public)
152183

153184
```bash
154185
curl -X GET http://localhost:8080/api/v1/public/health
@@ -160,20 +191,19 @@ Example response:
160191
"message": "Service up"
161192
}
162193
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)
166195
167196
```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
169198
curl -H "Authorization: Bearer <your_jwt_token>" http://localhost:8080/api/v1/private/info
170199
```
171200
172201
Example response (if authorized):
173202
```json
174203
{
175-
"info": "This is private information for authenticated users."
204+
"info": "This is private information for authenticated users.",
205+
"email": "user@example.com"
176206
}
177207
```
178208
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

Comments
 (0)