What is an SA-token?
Sa-token is a JavaWeb lightweight authorization framework with a very simple API call. How simple is it? Using login authentication as an example, you just need to:
// Write the account ID of the current session at login
StpUtil.setLoginId(10001);
// Then call the following API wherever the login needs to be verified - this code throws a 'NotLoginException' if the current session is not logged in
StpUtil.checkLogin();
Copy the code
No complex packaging! No configuration! With these two simple calls, you can easily complete system login authentication!
At present, the framework has integrated many features: login verification, authorization verification, Session Session, kicking people offline, integrated Redis, front and back separation, simulation of others’ accounts, multi-account system, annotation authentication, token, automatic renewal, Spring integration…
The API show
StpUtil.setLoginId(10001); // Marks the id of the current session login account
StpUtil.getLoginId(); // Obtain the id of the current session login account
StpUtil.isLogin(); // Gets whether the current session is logged in, returning true or false
StpUtil.logout(); // The current session is logged out
StpUtil.logoutByLoginId(10001); // Log out of the session with account 10001
StpUtil.hasRole("super-admin"); // Checks whether the current account contains the specified role id. Returns true or false
StpUtil.hasPermission("user:add"); // Check whether the current account has specified permissions. Return true or false
StpUtil.getSession(); // Get the Session of the current account ID
StpUtil.getSessionByLoginId(10001); // Obtain the Session whose id is 10001
StpUtil.getTokenValueByLoginId(10001); // Obtain the token value of account 10001
Copy the code
V1.8.0 Update logs
- Optimization: Optimize source code comments
- Fix: fix some document typos
- Fix: Fix project folder name error
- Optimization: Improved document color matching, more comfortable code presentation
- Added: Provided
sa-token
integrationredis
的spring-boot-starter
plan[key] - New: Added integration
redis
When, in order tojackson
As a serialization scheme[key] - New: Added the function of clearing expired data periodically by default in the DAO layer [Important]
- New: New
The exclusive session token
, more flexible session management[key] - New: Added the configuration specified in obtain
The exclusive session token
Is required to log in - New: Automatic session creation without token, perfect compatibility
token-session
Session model![key] - Modified: The permission code must be String
- Optimization: Annotation validation mode changed from Boolean attribute to enumeration mode
- Delete:
StpUtil
Remove some verbose apis to keep the API clean - New: Added role authentication (role authentication and permission authentication are separated) [Major]
- Optimization: Remove
StpUtil.kickoutByLoginId()
API,logoutByLoginId
Instead of - Upgrade: The open source agreement is changed to
Apache-2.0
Official website: sa-token.dev33.cn/