Skip to content

Commit 58ac644

Browse files
fix: 修复 PASETO 密钥派生不确定性和 scope 计算问题 (#28)
1 parent 4a8bc71 commit 58ac644

File tree

50 files changed

+1313
-1036
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1313
-1036
lines changed

aegis/config/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ const (
477477
DefaultAegisSSOCookieName = "aegis-sso" // SSO Cookie 默认名称
478478
)
479479

480-
// GetSSOMasterKey 获取 SSO master key(Base64URL 编码的 32 字节密钥
480+
// GetSSOMasterKey 获取 SSO master key(Base64URL 编码的 48 字节 seed: 16-byte salt + 32-byte key
481481
// 未配置时返回 nil, nil;配置了但格式错误时返回 nil, error
482482
func GetSSOMasterKey() ([]byte, error) {
483483
secretStr := Cfg().GetString("sso.master-key")
@@ -488,8 +488,8 @@ func GetSSOMasterKey() ([]byte, error) {
488488
if err != nil {
489489
return nil, fmt.Errorf("decode sso master key: %w", err)
490490
}
491-
if len(secretBytes) != 32 {
492-
return nil, fmt.Errorf("sso master key must be 32 bytes, got %d", len(secretBytes))
491+
if len(secretBytes) != 48 {
492+
return nil, fmt.Errorf("sso master key must be 48 bytes, got %d", len(secretBytes))
493493
}
494494
return secretBytes, nil
495495
}

aegis/consts.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package aegis
22

3-
// ==================== HTTP 常量 ====================
3+
import "errors"
4+
5+
// ==================== 常量 ====================
46

57
const (
68
HeaderAuthorization = "Authorization" // Authorization 请求头
@@ -11,4 +13,12 @@ const (
1113

1214
// Gin Context Key
1315
ContextKeyUser = "user" // 用户 Token 在 Gin Context 中的 key
16+
17+
// Cookie
18+
AuthSessionCookie = "aegis-session" // Auth 会话 Cookie 名称
1419
)
20+
21+
// ==================== 哨兵错误 ====================
22+
23+
// errIdentifiedUser 内部哨兵错误:resolveUser 识别到已有用户,需前端确认关联
24+
var errIdentifiedUser = errors.New("identified existing user")

0 commit comments

Comments
 (0)