A Clojure web application that provides Single Sign-On authentication with Microsoft 365 and GitHub.
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:
- 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
- Java 8 or higher
- Leiningen 2.0 or higher
-
Copy
profiles.clj
and update the OAuth client credentials:microsoft-client-id
andmicrosoft-client-secret
github-client-id
andgithub-client-secret
-
Register OAuth applications:
- Microsoft 365: Register at Azure App Registrations
- Redirect URI:
http://localhost:3000/auth/microsoft/callback
- Redirect URI:
- GitHub: Register at GitHub Developer Settings
- Authorization callback URL:
http://localhost:3000/auth/callback/github
- Authorization callback URL:
- Microsoft 365: Register at Azure App Registrations
# 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
.
;; Start the server
(start)
;; Stop the server
(stop)
;; Restart with code changes
(restart)
# Run all tests
lein test
# Run tests with auto-reload
lein test-refresh
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
DATABASE_URL
: SQLite database path (default:jdbc:sqlite:dev-database.db
)MICROSOFT_CLIENT_ID
: Microsoft OAuth2 client IDMICROSOFT_CLIENT_SECRET
: Microsoft OAuth2 client secretGITHUB_CLIENT_ID
: GitHub OAuth2 client IDGITHUB_CLIENT_SECRET
: GitHub OAuth2 client secretSESSION_SECRET
: Secret key for session encryptionPORT
: Server port (default: 3000)BASE_URL
: Base URL for OAuth callbacks (default:http://localhost:3000
)