diff --git a/CLAUDE.md b/CLAUDE.md index a1d2948..d90c43e 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -18,6 +18,30 @@ There is a reverse proxy rewrite rule in place. To call any API endpoint from th - API endpoint URLs should be: `playground.shiny.space/api/yourendpointhere` - Example: `/randomnumber` endpoint becomes `/api/randomnumber` +## Authentication +The setup uses Caddy with Authelia for authentication: +- Caddy acts as reverse proxy and checks with Authelia before allowing access to protected pages +- When authenticated, Authelia adds headers to requests that reach the Go API +- The Go API can read these headers to get user information + +### Authentication Headers from Authelia +The following headers are available in authenticated requests: +- `Remote-User`: Username of the authenticated user +- `Remote-Name`: Display name of the user +- `Remote-Email`: Email address of the user +- `Remote-Groups`: User's group memberships + +### Authentication API Endpoint +- `/api/auth/user` (GET) - Returns user information and all headers for debugging +- Protected pages can use JavaScript to fetch this endpoint to get current user info +- Returns JSON with username, name, email, groups, and complete headers object + +### Authentication Test Page +- `account.html` - Test page that requires authentication to access +- Displays user information by calling `/api/auth/user` +- Shows both structured user info and raw headers for debugging +- Configure Caddy to require authentication for this page to test the setup + ## Development To rebuild the Go API after making changes: - Run `go build -o api` in the project directory diff --git a/account.html b/account.html new file mode 100644 index 0000000..4698695 --- /dev/null +++ b/account.html @@ -0,0 +1,77 @@ + + +
+ + +Your authenticated user information:
+ +