yaiam: user attributes in SignedIn and User (ADR-0044)
Web asks for the scope attributes; SignedIn.Attributes carries the attributes yaiam released to the application (from UserInfo), and Admin's User carries a user's attributes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a3e8f9bb3b
commit
538a6c8ae6
4 files changed
+21
-11
No files matched your search
+3
-3
@@ -71,7 +71,7 @@ func newOP(t *testing.T) *op {
|
||||
o.ts = httptest.NewServer(mux)
|
||||
t.Cleanup(o.ts.Close)
|
||||
o.issuer = o.ts.URL + "/t/default"
|
||||
o.userBody = `{"sub":"u-1","preferred_username":"alice","name":"Alice","email":"alice@example.org","email_verified":true,"groups":["staff","dev"],"roles":["editor"]}`
|
||||
o.userBody = `{"sub":"u-1","preferred_username":"alice","name":"Alice","email":"alice@example.org","email_verified":true,"groups":["staff","dev"],"roles":["editor"],"attributes":{"department":"IT"}}`
|
||||
o.claims = func(nonce string) map[string]any {
|
||||
now := time.Now()
|
||||
return map[string]any{"iss": o.issuer, "sub": "u-1", "aud": "web", "exp": now.Add(5 * time.Minute).Unix(), "iat": now.Unix(),
|
||||
@@ -137,7 +137,7 @@ func TestWebSignIn(t *testing.T) {
|
||||
w := o.web()
|
||||
q, cookie := o.start(t, w, "/staff?x=1")
|
||||
if q.Get("response_type") != "code" || q.Get("client_id") != "web" || q.Get("redirect_uri") != w.RedirectURL ||
|
||||
q.Get("scope") != "openid profile email groups roles" || q.Get("code_challenge_method") != "S256" || q.Get("state") == "" || q.Get("nonce") == "" {
|
||||
q.Get("scope") != "openid profile email groups roles attributes" || q.Get("code_challenge_method") != "S256" || q.Get("state") == "" || q.Get("nonce") == "" {
|
||||
t.Errorf("authorization request %v", q)
|
||||
}
|
||||
if !cookie.HttpOnly || cookie.SameSite != http.SameSiteLaxMode || cookie.Name != "yaiam_signin" || cookie.Secure || cookie.MaxAge != 600 {
|
||||
@@ -148,7 +148,7 @@ func TestWebSignIn(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if s.Subject != "u-1" || s.Username != "alice" || s.Name != "Alice" || s.Email != "alice@example.org" || !s.EmailVerified ||
|
||||
strings.Join(s.Groups, ",") != "staff,dev" || strings.Join(s.Roles, ",") != "editor" || s.ACR != "mfa" || s.AuthTime.IsZero() ||
|
||||
strings.Join(s.Groups, ",") != "staff,dev" || strings.Join(s.Roles, ",") != "editor" || s.Attributes["department"] != "IT" || len(s.Attributes) != 1 || s.ACR != "mfa" || s.AuthTime.IsZero() ||
|
||||
s.ReturnTo != "/staff?x=1" || s.Token.AccessToken != "at-1" || s.IDToken == "" {
|
||||
t.Errorf("signed in %+v", s)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user