SSO Web Application

A Clojure web application that provides Single Sign-On authentication with Microsoft 365 and GitHub.

Kiro Review

This was generated with AWS Kiro. Code gen initially looks fairly fast, but with lots of trial and error. It emits a lot of syntax errors (e.g. it frequently does not know the comment syntax, so edits break the code). It tries to run a REPL, but does not interact with it: it just hangs. Fixing compile errors consume a lot of retries, perhaps due to the terse error messages from the Clojure compiler (EOF while reading, start at line 367 does not offer too much help). Eventually it ran out of quota, pausing the work until the next day.

Then, the next day I asked it to complete the tasks. Which it did through more trial and error. Except it finished with the test suite all red. So I asked it to fix that. Again. And Again. And again. Then it ran out of quota again, pausing the work until the next day.

Clojure is useless as a target language. The other target languages in this series work much better.

This is part of an experiment with multiple version generated from the same specification:

Features

  • OAuth2 authentication with Microsoft 365 and GitHub
  • User session management
  • SQLite database for user persistence
  • Server-side rendered HTML with Hiccup templates
  • Secure session handling with CSRF protection

Development Setup

Prerequisites

  • Java 8 or higher
  • Leiningen 2.0 or higher

Configuration

  1. Copy profiles.clj and update the OAuth client credentials:

    • microsoft-client-id and microsoft-client-secret
    • github-client-id and github-client-secret
  2. Register OAuth applications:

Running the Application

# Install dependencies
lein deps

# Start the development server
lein repl
user=> (start)

# Or run directly
lein run

The application will be available at http://localhost:3000.

Development REPL

;; Start the server
(start)

;; Stop the server
(stop)

;; Restart with code changes
(restart)

Testing

# Run all tests
lein test

# Run tests with auto-reload
lein test-refresh

Project Structure

src/sso_web_app/
├── core.clj        # Application entry point and server lifecycle
├── routes.clj      # HTTP route definitions
├── auth.clj        # OAuth2 authentication logic
├── db.clj          # Database operations
├── templates.clj   # HTML template generation
└── middleware.clj  # Custom middleware

dev/
└── user.clj        # Development utilities

resources/
└── logback.xml     # Logging configuration

Environment Variables

  • DATABASE_URL: SQLite database path (default: jdbc:sqlite:dev-database.db)
  • MICROSOFT_CLIENT_ID: Microsoft OAuth2 client ID
  • MICROSOFT_CLIENT_SECRET: Microsoft OAuth2 client secret
  • GITHUB_CLIENT_ID: GitHub OAuth2 client ID
  • GITHUB_CLIENT_SECRET: GitHub OAuth2 client secret
  • SESSION_SECRET: Secret key for session encryption
  • PORT: Server port (default: 3000)
  • BASE_URL: Base URL for OAuth callbacks (default: http://localhost:3000)