跪拜 Guibai
← All articles
Backend · Java · Open Source

A Single Dependency Gives Any Spring Boot App a Login Page

By 小风筝 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Internal tools and staging deployments often ship without any auth because wiring a login page is disproportionately expensive. A single-dependency, zero-code login gate removes that friction, making it practical to put a password in front of anything.

Summary

Adding a login page to a small internal tool or monitoring dashboard usually means hand-coding forms, picking an Ajax library, wiring a template engine, and building backend interceptors — a two-day detour for a one-afternoon project. Sa-Token-Quick-Login collapses that work into a single dependency. Drop it into any Spring Boot app, and unauthenticated requests get redirected to a functional login page backed by configurable credentials.

The plugin ships as part of the Sa-Token ecosystem and can also be packaged as a standalone fat jar. That jar doubles as a static-file server: point it at a local directory with `--sa.dir`, and it serves the contents behind a login gate. Credentials, page title, auto-generated passwords, and even the auth check itself are all toggleable via command-line flags or YAML.

It is deliberately not customizable. The trade-off is speed: for internal dashboards, staging environments, or quick demos that need a basic access barrier, the plugin removes the entire login build step.

Takeaways
Adding `sa-token-quick-login` to a Spring Boot project instantly provides a login page — no frontend code, no template engine configuration.
Default credentials are `sa / 123456`; both can be changed in YAML or via command-line arguments.
An `auto=true` setting generates random credentials on each startup and prints them to the console.
The plugin can be packaged as a standalone jar that serves static files from a specified local directory behind the login gate.
Authentication can be disabled entirely (`auth=false`), turning the jar into a plain static-file server.
Http Basic authentication is supported as an alternative to the form-based login page.
Spring Boot 3.x and 4.x require the corresponding `sa-token-spring-boot3-starter` or `sa-token-spring-boot4-starter`; the quick-login plugin itself stays the same.
Conclusions

The plugin makes an explicit trade-off: zero customizability for zero integration cost. That positions it not as a general-purpose auth module but as a stopgap for situations where any login barrier is better than none.

Packaging the login gate as a standalone jar that also serves static files turns it into a deployable wrapper — you can drop it in front of any static site without touching the site's code.

The design acknowledges that for many small internal tools, the real cost of auth is not the security logic but the frontend plumbing; removing that plumbing changes the default from 'no auth' to 'auth by default'.

Concepts & terms
Sa-Token
An open-source Java permission framework handling login, role-based access, SSO, OAuth2, JWT, and API signing across monoliths and microservice gateways.
Http Basic Authentication
A simple HTTP authentication scheme where credentials are sent as a base64-encoded `username:password` pair in the request header; supported by the plugin as an alternative to the form-based login page.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗