Open-source authentication and authorization infrastructure built on OIDC and OAuth 2.1, with multi-tenancy, enterprise SSO and RBAC for SaaS and AI apps.
dromara/Sa-Token
A Java authentication and authorization framework covering login, permissions, SSO, OAuth2, JWT and API signing for Spring and other web stacks.
Open-source alternative to:Spring Security
Apache Shiro
- Stars
- 19,111
- Forks
- 2,911
- Open issues
- 123
- Last commit
- 22 days ago
What is it?
Sa-Token is a Java framework for handling authentication and authorization in web applications. It provides login sessions, role and permission checks, forced logout, and session management, with annotation-based or route-based enforcement. The core API is a short static call such as StpUtil.login(userId) followed by StpUtil.checkLogin().
Beyond basic login, the project bundles single sign-on in three deployment modes (same domain, cross domain, and cross Redis), an OAuth2 server supporting the authorization code, implicit, password and client credentials grants, and microservice gateway checks for Gateway, ShenYu and Zuul. It also includes JWT integration, API Key authorization, API parameter signing, Http Basic and Digest authentication, and account banning.
Integration packages cover Spring Boot 2 and 3/4, Spring WebFlux, Solon and JFinal, with Redis available as a persistence layer. Official demos and documentation are provided in Chinese.
Key features
- 01Login sessions with multi-device, single-device and mutually exclusive login modes
- 02Annotation and route-based permission and role checks
- 03Single sign-on in three modes, plus single logout
- 04OAuth2 server supporting four standard grant types
- 05JWT integration and API Key authorization
- 06API parameter signing to prevent tampering and replay
Use cases
- Adding login and role-based access control to a Spring Boot backend
- Building single sign-on across several internal web systems
- Protecting APIs at a microservice gateway
- Issuing OAuth2 tokens from your own Java service
Quick start
- 1
Add the Spring Boot starter dependency to pom.xml
- 2
Log a user in with one static call
StpUtil.login(10001); - 3
Protect an endpoint so only logged-in clients can access it
StpUtil.checkLogin();
Things to know
- The README is written mainly in Chinese, with full documentation hosted at sa-token.com.
- Java-only; other languages are covered by separate community ports with their own maintenance status.
In collections
Topics
FAQ
- What is Sa-Token?
- A Java authentication and authorization framework covering login, permissions, SSO, OAuth2, JWT and API signing for Spring and other web stacks. Sa-Token is a Java framework for handling authentication and authorization in web applications. It provides login sessions, role and permission checks, forced logout, and session management, with annotation-based or route-based enforcement. The core API is a short static call such as StpUtil.login(userId) followed by StpUtil.checkLogin().
- Is Sa-Token free to use? What license does it have?
- Sa-Token is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
- Is Sa-Token still maintained?
- Actively maintained. The last commit to Sa-Token was on Oct 16, 2026.
- What can I use Sa-Token for?
- Adding login and role-based access control to a Spring Boot backend Building single sign-on across several internal web systems Protecting APIs at a microservice gateway Issuing OAuth2 tokens from your own Java service
- How do I install Sa-Token?
- Add the Spring Boot starter dependency to pom.xml Log a user in with one static call: StpUtil.login(10001); Protect an endpoint so only logged-in clients can access it: StpUtil.checkLogin();
- Where can I get Sa-Token?
- The source code and installation instructions are on GitHub: https://github.com/dromara/Sa-Token
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
Open-source single sign-on and identity provider server in Java, supporting CAS, SAML2, OAuth2, OpenID Connect and multifactor authentication.
A lightweight, Rust-based Identity Provider for Single Sign-On via OpenID Connect, OAuth 2, and PAM, with a strong focus on passkeys.
A framework-agnostic authentication and authorization framework for TypeScript, with a plugin system for features like 2FA and multi-tenancy.
Open-source identity provider for SSO, supporting SAML, OAuth2/OIDC, LDAP and RADIUS, self-hostable from small labs to large clusters.
Self-hosted, Keycloak-compatible identity provider written in Rust, shipped as a single binary with OIDC, OAuth2, DPoP and CIBA support.