forked from baron/baron-sso
fix(headless-login): show full parsed jwks key values
- return the full RSA n value in parsedKeys responses - render parsed key fields with labels and multiline key material in DevFront - lock the behavior with backend and Playwright regression tests
This commit is contained in:
@@ -3,11 +3,11 @@ package domain
|
||||
import "time"
|
||||
|
||||
type HeadlessJWKSParsedKey struct {
|
||||
Kid string `json:"kid,omitempty"`
|
||||
Kty string `json:"kty,omitempty"`
|
||||
Use string `json:"use,omitempty"`
|
||||
Alg string `json:"alg,omitempty"`
|
||||
NPreview string `json:"nPreview,omitempty"`
|
||||
Kid string `json:"kid,omitempty"`
|
||||
Kty string `json:"kty,omitempty"`
|
||||
Use string `json:"use,omitempty"`
|
||||
Alg string `json:"alg,omitempty"`
|
||||
N string `json:"n,omitempty"`
|
||||
}
|
||||
|
||||
// HeadlessJWKSCacheState는 headless login용 JWKS 캐시 상태와 최근 동기화 결과를 나타냅니다.
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -108,14 +107,6 @@ func devTestJWKSFirstKeyString(t *testing.T, jwks map[string]any, field string)
|
||||
return value
|
||||
}
|
||||
|
||||
func devTestPreviewValue(value string) string {
|
||||
value = strings.TrimSpace(value)
|
||||
if len(value) <= 24 {
|
||||
return value
|
||||
}
|
||||
return value[:12] + "..." + value[len(value)-12:]
|
||||
}
|
||||
|
||||
// --- Tests ---
|
||||
|
||||
func TestListClients_Success(t *testing.T) {
|
||||
@@ -855,7 +846,7 @@ func TestRefreshHeadlessJWKSCache_ReturnsUpdatedCacheState(t *testing.T) {
|
||||
privateKey, jwks := mustHeadlessRSAJWK(t)
|
||||
_ = privateKey
|
||||
jwksBody, _ := json.Marshal(jwks)
|
||||
expectedNPreview := devTestPreviewValue(devTestJWKSFirstKeyString(t, jwks, "n"))
|
||||
expectedN := devTestJWKSFirstKeyString(t, jwks, "n")
|
||||
redisRepo := &devMockRedisRepo{data: map[string]string{}}
|
||||
h := &DevHandler{
|
||||
Hydra: &service.HydraAdminService{
|
||||
@@ -908,7 +899,7 @@ func TestRefreshHeadlessJWKSCache_ReturnsUpdatedCacheState(t *testing.T) {
|
||||
assert.Equal(t, "RSA", got.HeadlessJWKSCache.ParsedKeys[0].Kty)
|
||||
assert.Equal(t, "sig", got.HeadlessJWKSCache.ParsedKeys[0].Use)
|
||||
assert.Equal(t, "RS256", got.HeadlessJWKSCache.ParsedKeys[0].Alg)
|
||||
assert.Equal(t, expectedNPreview, got.HeadlessJWKSCache.ParsedKeys[0].NPreview)
|
||||
assert.Equal(t, expectedN, got.HeadlessJWKSCache.ParsedKeys[0].N)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -390,24 +390,16 @@ func summarizeHeadlessJWKS(raw string) []domain.HeadlessJWKSParsedKey {
|
||||
parsedKeys := make([]domain.HeadlessJWKSParsedKey, 0, len(document.Keys))
|
||||
for _, key := range document.Keys {
|
||||
parsedKeys = append(parsedKeys, domain.HeadlessJWKSParsedKey{
|
||||
Kid: strings.TrimSpace(key.Kid),
|
||||
Kty: strings.TrimSpace(key.Kty),
|
||||
Use: strings.TrimSpace(key.Use),
|
||||
Alg: strings.TrimSpace(key.Alg),
|
||||
NPreview: previewHeadlessJWKValue(key.N),
|
||||
Kid: strings.TrimSpace(key.Kid),
|
||||
Kty: strings.TrimSpace(key.Kty),
|
||||
Use: strings.TrimSpace(key.Use),
|
||||
Alg: strings.TrimSpace(key.Alg),
|
||||
N: strings.TrimSpace(key.N),
|
||||
})
|
||||
}
|
||||
return parsedKeys
|
||||
}
|
||||
|
||||
func previewHeadlessJWKValue(value string) string {
|
||||
value = strings.TrimSpace(value)
|
||||
if len(value) <= 24 {
|
||||
return value
|
||||
}
|
||||
return value[:12] + "..." + value[len(value)-12:]
|
||||
}
|
||||
|
||||
func extractHeadlessKids(keySet *jose.JSONWebKeySet) []string {
|
||||
if keySet == nil {
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user