1
0
mirror of synced 2026-05-22 14:43:15 +00:00

fefactor(oauth2): 将认证流程回调从 SaOAuth2ServerConfig 转移到 SaOAuth2Strategy

This commit is contained in:
click33
2025-05-11 14:52:15 +08:00
parent c4e34704d5
commit 9f52c4d399
7 changed files with 62 additions and 51 deletions
+2 -2
View File
@@ -12,7 +12,7 @@
@Autowired
public void configOAuth2Server(SaOAuth2ServerConfig oauth2Server) {
// 配置:未登录时返回的View
oauth2Server.notLoginView = ()->{
SaOAuth2Strategy.instance.notLoginView = ()->{
return new ModelAndView("xxx.html");
};
}
@@ -66,7 +66,7 @@ public SaResult ss(String name, String pwd) {
@Autowired
public void configOAuth2Server(SaOAuth2ServerConfig oauth2Server) {
// 配置:授权确认视图
oauth2Server.confirmView = (clientId, scopes)->{
SaOAuth2Strategy.instance.confirmView = (clientId, scopes)->{
Map<String, Object> map = new HashMap<>();
map.put("clientId", clientId);
map.put("scope", scopes);
+3 -3
View File
@@ -143,7 +143,7 @@ public class SaOAuth2ServerController {
// oauth2Server.addClient(...)
// 配置:未登录时返回的View
oauth2Server.notLoginView = () -> {
SaOAuth2Strategy.instance.notLoginView = () -> {
String msg = "当前会话在OAuth-Server端尚未登录,请先访问"
+ "<a href='/oauth2/doLogin?name=sa&pwd=123456' target='_blank'> doLogin登录 </a>"
+ "进行登录之后,刷新页面开始授权";
@@ -151,7 +151,7 @@ public class SaOAuth2ServerController {
};
// 配置:登录处理函数
oauth2Server.doLoginHandle = (name, pwd) -> {
SaOAuth2Strategy.instance.doLoginHandle = (name, pwd) -> {
if("sa".equals(name) && "123456".equals(pwd)) {
StpUtil.login(10001);
return SaResult.ok();
@@ -160,7 +160,7 @@ public class SaOAuth2ServerController {
};
// 配置:确认授权时返回的 view
oauth2Server.confirmView = (clientId, scopes) -> {
SaOAuth2Strategy.instance.confirmView = (clientId, scopes) -> {
String scopeStr = SaFoxUtil.convertListToString(scopes);
String yesCode =
"fetch('/oauth2/doConfirm?client_id=" + clientId + "&scope=" + scopeStr + "', {method: 'POST'})" +