mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-11-15 00:09:00 +01:00
- OIDC discovery via .well-known/openid-configuration; falls back to /.well-known/jwks.json when discovery is absent. Reject discovery docs whose issuer claim does not match the configured issuer to defend against issuer-substitution. - ComputeParentUser derives a stable per-identity hash from (sub, iss). Surface as aws:userid in the request context and as a parent_user claim in the session JWT so per-user state survives token rotation. - Per-role MaxSessionDuration (3600..43200) clamps requested DurationSeconds before the STS service applies its own caps. - Tighten RoleSessionName to the AWS contract: 2..64 chars from [\w+=,.@-]. - Populate PackedPolicySize in AssumeRole / AssumeRoleWithWebIdentity / AssumeRoleWithLDAPIdentity responses as a percentage of the 2048-byte inline session policy budget.
35 lines
967 B
Go
35 lines
967 B
Go
package integration
|
|
|
|
import "testing"
|
|
|
|
func intPtr(v int64) *int64 { return &v }
|
|
|
|
func TestCapDurationByRole(t *testing.T) {
|
|
cases := []struct {
|
|
name string
|
|
requested *int64
|
|
roleMax int64
|
|
want *int64
|
|
}{
|
|
{"no cap, no request", nil, 0, nil},
|
|
{"no cap, with request", intPtr(7200), 0, intPtr(7200)},
|
|
{"cap only, no request -> use cap", nil, 3600, intPtr(3600)},
|
|
{"request below cap -> request", intPtr(1800), 3600, intPtr(1800)},
|
|
{"request equal cap -> request", intPtr(3600), 3600, intPtr(3600)},
|
|
{"request above cap -> cap", intPtr(43200), 3600, intPtr(3600)},
|
|
}
|
|
for _, tc := range cases {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
got := capDurationByRole(tc.requested, tc.roleMax)
|
|
switch {
|
|
case got == nil && tc.want == nil:
|
|
return
|
|
case got == nil || tc.want == nil:
|
|
t.Fatalf("nilness mismatch: got=%v want=%v", got, tc.want)
|
|
case *got != *tc.want:
|
|
t.Fatalf("got=%d want=%d", *got, *tc.want)
|
|
}
|
|
})
|
|
}
|
|
}
|