feat(learning-auth): expose auth mode in profile and default advanced to jwt
This commit is contained in:
@@ -16,11 +16,15 @@ public class LearningProfileInfo {
|
|||||||
@Value("${app.enabled-modules:ioc,aop,mybatis,transaction,users}")
|
@Value("${app.enabled-modules:ioc,aop,mybatis,transaction,users}")
|
||||||
private String[] enabledModules;
|
private String[] enabledModules;
|
||||||
|
|
||||||
|
@Value("${auth.type:none}")
|
||||||
|
private String authType;
|
||||||
|
|
||||||
@GetMapping("/api/profile")
|
@GetMapping("/api/profile")
|
||||||
public Map<String, Object> profileInfo() {
|
public Map<String, Object> profileInfo() {
|
||||||
return Map.of(
|
return Map.of(
|
||||||
"profile", activeProfile,
|
"profile", activeProfile,
|
||||||
"enabledModules", Arrays.asList(enabledModules)
|
"enabledModules", Arrays.asList(enabledModules),
|
||||||
|
"authType", authType
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ spring:
|
|||||||
|
|
||||||
# 鉴权方案选择: none / jwt / satoken
|
# 鉴权方案选择: none / jwt / satoken
|
||||||
auth:
|
auth:
|
||||||
type: ${AUTH_TYPE:none} # none | jwt | satoken
|
type: ${AUTH_TYPE:jwt} # none | jwt | satoken
|
||||||
jwt:
|
jwt:
|
||||||
secret: ${JWT_SECRET:your-secret-key}
|
secret: ${JWT_SECRET:your-secret-key}
|
||||||
expiration: ${JWT_EXPIRATION:86400000} # 24小时
|
expiration: ${JWT_EXPIRATION:86400000} # 24小时
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ app:
|
|||||||
|
|
||||||
auth:
|
auth:
|
||||||
type: none
|
type: none
|
||||||
|
learning-note: "learn 模式默认不开启鉴权,专注 Spring 核心学习"
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
type: caffeine
|
type: caffeine
|
||||||
|
|||||||
@@ -260,7 +260,7 @@
|
|||||||
const res = await fetch('/api/profile');
|
const res = await fetch('/api/profile');
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
const enabled = (data.enabledModules || []).join(', ');
|
const enabled = (data.enabledModules || []).join(', ');
|
||||||
document.getElementById('profileBanner').textContent = `当前 profile: ${data.profile} | 已启用模块: ${enabled}`;
|
document.getElementById('profileBanner').textContent = `当前 profile: ${data.profile} | 鉴权模式: ${data.authType || 'none'} | 已启用模块: ${enabled}`;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
document.getElementById('profileBanner').textContent = '当前 profile 读取失败,请检查 /api/profile';
|
document.getElementById('profileBanner').textContent = '当前 profile 读取失败,请检查 /api/profile';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,6 +80,7 @@
|
|||||||
|
|
||||||
<div class="lab">
|
<div class="lab">
|
||||||
<h4>🧪 实验任务卡(事务模块)</h4>
|
<h4>🧪 实验任务卡(事务模块)</h4>
|
||||||
|
<p style="margin-bottom:8px;color:#8c8c8c;">鉴权学习建议:learn=none(先学核心),advanced=jwt/satoken(再学安全链路)</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>目标:理解事务回滚与 REQUIRES_NEW 差异</li>
|
<li>目标:理解事务回滚与 REQUIRES_NEW 差异</li>
|
||||||
<li>步骤1:到 transaction.html 创建普通订单(rollback=false)</li>
|
<li>步骤1:到 transaction.html 创建普通订单(rollback=false)</li>
|
||||||
|
|||||||
Reference in New Issue
Block a user