日常提交

This commit is contained in:
wu xiangkai
2022-11-02 10:48:09 +08:00
parent 999ef6c2c4
commit 2cbdca091c
3 changed files with 140 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
# Apache Shiro Authentication
## Apache Shiro Authentication简介
Authentication是一个对用户进行身份认证的过程在认证过程中用户需要向应用提供用于证明用户的凭据。
## Apache Authentication概念
### subject
在应用的角度subject即是一个用户
### principals
主体用于标识一个用户可以是username、social security nubmer等
### credentials
凭据,在用户认证过程中用于认证用户的身份,可以是密码、生物识别数据(如指纹、面容等)
### realms
专用于security的dao对象用于和后端的datasource进行沟通。
## Shiro Authentication过程
### Shiro框架的Authentication过程
1. 收集用户的principals和credentials
2. 向应用的认证系统提交用户的principals和credentials
3. 认证结束之后,根据认证结果允许访问、重试访问请求或者阻塞访问
### 收集用户的principals和credentials
可以通过UsernamePasswordToken来存储用户提交的username和password并可以调用UsernamePasswordToken.rememberMe方法来启用Shiro的“remember-me”功能。
```java
//Example using most common scenario:
//String username and password. Acquire in
//system-specific manner (HTTP request, GUI, etc)
UsernamePasswordToken token = new UsernamePasswordToken( username, password );
//”Remember Me” built-in, just do this:
token.setRememberMe(true);
```
### 将收集的principals和credentials提交给认证系统
在收集完用户的principals和credentials之后需要将其提交给应用的认证系统。
在Shiro中代表认证系统的是Realm其从存放安全数据的datasource中获取数据并且