Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
shengzhang_
sa-token
提交
51b76f07
sa-token
项目概览
shengzhang_
/
sa-token
通知
68
Star
16
Fork
4
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
sa-token
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
51b76f07
编写于
3月 02, 2021
作者:
shengzhang_
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
起草[记住我]模式开发文档
上级
0b32a1f5
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
30 addition
and
43 deletion
+30
-43
sa-token-demo-springboot/src/main/java/com/pj/test/GlobalException.java
...springboot/src/main/java/com/pj/test/GlobalException.java
+3
-2
sa-token-demo-springboot/src/main/java/com/pj/test/TestController.java
...-springboot/src/main/java/com/pj/test/TestController.java
+1
-14
sa-token-demo-springboot/src/main/java/com/pj/test/TestService.java
...emo-springboot/src/main/java/com/pj/test/TestService.java
+0
-25
sa-token-doc/doc/_sidebar.md
sa-token-doc/doc/_sidebar.md
+1
-0
sa-token-doc/doc/more/common-questions.md
sa-token-doc/doc/more/common-questions.md
+6
-2
sa-token-doc/doc/static/login-view.png
sa-token-doc/doc/static/login-view.png
+0
-0
sa-token-doc/doc/use/remember-me.md
sa-token-doc/doc/use/remember-me.md
+19
-0
未找到文件。
sa-token-demo-springboot/src/main/java/com/pj/test/GlobalException.java
浏览文件 @
51b76f07
...
...
@@ -14,6 +14,7 @@ import com.pj.util.AjaxJson;
import
cn.dev33.satoken.exception.NotLoginException
;
import
cn.dev33.satoken.exception.NotPermissionException
;
import
cn.dev33.satoken.exception.NotRoleException
;
import
cn.dev33.satoken.stp.StpUtil
;
/**
* 全局异常处理
...
...
@@ -21,10 +22,10 @@ import cn.dev33.satoken.exception.NotRoleException;
@RestControllerAdvice
// 可指定包前缀,比如:(basePackages = "com.pj.admin")
public
class
GlobalException
{
// 在
每个控制器
之前触发的操作
// 在
当前类每个方法进入
之前触发的操作
@ModelAttribute
public
void
get
(
HttpServletRequest
request
)
throws
IOException
{
StpUtil
.
checkPermission
(
"user:add"
);
}
...
...
sa-token-demo-springboot/src/main/java/com/pj/test/TestController.java
浏览文件 @
51b76f07
...
...
@@ -5,7 +5,6 @@ import java.util.List;
import
javax.servlet.http.HttpServletResponse
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
...
...
@@ -232,18 +231,6 @@ public class TestController {
}
@Autowired
TestService
TestService
;
// 测试AOP注解鉴权: http://localhost:8081/test/testAOP
@RequestMapping
(
"testAOP"
)
public
AjaxJson
testAOP
()
{
System
.
out
.
println
(
"testAOP"
);
TestService
.
getList
();
return
AjaxJson
.
getSuccess
();
}
// 测试 浏览器访问: http://localhost:8081/test/test
@RequestMapping
(
"test"
)
public
AjaxJson
test
(
HttpServletResponse
response
)
{
...
...
@@ -253,7 +240,7 @@ public class TestController {
// StpUtil.setLoginId(10001, new SaLoginModel().setIsTempCookie(true));
// StpUtil.getLoginId();
return
AjaxJson
.
getSuccess
();
return
AjaxJson
.
getSuccess
(
"访问成功"
);
}
// 测试 浏览器访问: http://localhost:8081/test/test2
...
...
sa-token-demo-springboot/src/main/java/com/pj/test/TestService.java
已删除
100644 → 0
浏览文件 @
0b32a1f5
package
com.pj.test
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.springframework.stereotype.Service
;
import
cn.dev33.satoken.annotation.SaCheckLogin
;
/**
* 用来测试AOP注解鉴权
* @author kong
*
*/
@Service
public
class
TestService
{
@SaCheckLogin
public
List
<
String
>
getList
()
{
System
.
out
.
println
(
"getList"
);
return
new
ArrayList
<
String
>();
}
}
sa-token-doc/doc/_sidebar.md
浏览文件 @
51b76f07
...
...
@@ -19,6 +19,7 @@
-
[
花式token
](
/use/token-style
)
-
[
框架配置
](
/use/config
)
-
[
会话治理
](
/use/search-session
)
<!-- - [记住我模式](/use/remember-me) -->
-
**进阶**
-
[
集群、分布式
](
/senior/dcs
)
...
...
sa-token-doc/doc/more/common-questions.md
浏览文件 @
51b76f07
...
...
@@ -49,7 +49,6 @@
可能是404了,SpringBoot环境下如果访问接口404后,会被重定向到
`/error`
,然后被再次拦截,如果是其它原因,欢迎加群反馈
### 权限可以做成动态的吗?
权限本来就是动态的,只有jwt那种模式才是非动态的
...
...
@@ -71,9 +70,14 @@
步骤:先在配置文件里将
`tokenSessionCheckLogin`
配置为
`false`
,然后通过
`StpUtil.getTokenSession()`
获取Session
### 我只使用header来传输token,还需要打开Cookie模式吗?
不需要,如果只使用header来传输token,可以在配置文件关闭Cookie模式,例:
`isReadCookie=false`
### 还是有不明白到的地方?
请在
`github`
提交
`issues`
,或者加入qq群交流(群链接在
[
首页
](
README?id=交流群
)
)
### 我能为这个框架贡献代码吗?
**可以**
,请参照首页的提交pr步骤 ,
[
贡献代码
](
README?id=贡献代码
)
\ No newline at end of file
**可以**
,请参照首页的提交pr步骤 ,
[
贡献代码
](
README?id=贡献代码
)
sa-token-doc/doc/static/login-view.png
0 → 100644
浏览文件 @
51b76f07
6.8 KB
sa-token-doc/doc/use/remember-me.md
0 → 100644
浏览文件 @
51b76f07
# [记住我]模式
---
如下图所示,一般网站的登录界面都会有一个 [ 记住我 ] 按钮,当你勾选它后,即时你关闭浏览器再次打开网站,也依然会处于登录状态,无须重复验证密码
![
../static/login-view.png
](
../static/login-view.png
)
那么在sa-token中,如何做到 [ 记住我 ] 功能呢?
### 在sa-token中实现记住我功能
sa-token的登录授权,默认就是
`记住我`
模式,为了实现
`非记住我`
模式, 你需要做一些适配
要
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录