feat(learning-auth): expose auth mode in profile and default advanced to jwt

This commit is contained in:
likingcode
2026-03-09 02:11:49 +08:00
parent 3c208651b9
commit f846616e0b
5 changed files with 9 additions and 3 deletions

View File

@@ -16,11 +16,15 @@ public class LearningProfileInfo {
@Value("${app.enabled-modules:ioc,aop,mybatis,transaction,users}")
private String[] enabledModules;
@Value("${auth.type:none}")
private String authType;
@GetMapping("/api/profile")
public Map<String, Object> profileInfo() {
return Map.of(
"profile", activeProfile,
"enabledModules", Arrays.asList(enabledModules)
"enabledModules", Arrays.asList(enabledModules),
"authType", authType
);
}
}

View File

@@ -26,7 +26,7 @@ spring:
# 鉴权方案选择: none / jwt / satoken
auth:
type: ${AUTH_TYPE:none} # none | jwt | satoken
type: ${AUTH_TYPE:jwt} # none | jwt | satoken
jwt:
secret: ${JWT_SECRET:your-secret-key}
expiration: ${JWT_EXPIRATION:86400000} # 24小时

View File

@@ -15,6 +15,7 @@ app:
auth:
type: none
learning-note: "learn 模式默认不开启鉴权,专注 Spring 核心学习"
cache:
type: caffeine

View File

@@ -260,7 +260,7 @@
const res = await fetch('/api/profile');
const data = await res.json();
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) {
document.getElementById('profileBanner').textContent = '当前 profile 读取失败,请检查 /api/profile';
}

View File

@@ -80,6 +80,7 @@
<div class="lab">
<h4>🧪 实验任务卡(事务模块)</h4>
<p style="margin-bottom:8px;color:#8c8c8c;">鉴权学习建议learn=none先学核心advanced=jwt/satoken再学安全链路</p>
<ul>
<li>目标:理解事务回滚与 REQUIRES_NEW 差异</li>
<li>步骤1到 transaction.html 创建普通订单rollback=false</li>