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:
terminarandClaude Opus 5.5 committed 2026-11-17 15:16:32 +01:00
1 parent a3e8f9bb3b
commit 538a6c8ae6
4 files changed
+21 -11

No files matched your search

+13 -6
View File
@@ -31,9 +31,11 @@ import (
)
// WebScopes are asked for when Web.Scopes is nil: who the user is, their
// address, and their groups and roles at yaiam (the client must be
// allowed "groups" and "roles").
var WebScopes = []string{"openid", "profile", "email", "groups", "roles"}
// address, their groups and roles at yaiam (the client must be allowed
// "groups" and "roles") and the user attributes released to the client
// (yaiam allows "attributes" once some are). A scope the client is not
// allowed is left out, not refused.
var WebScopes = []string{"openid", "profile", "email", "groups", "roles", "attributes"}
// signInLifetime is how long a started sign-in may take.
const signInLifetime = 10 * time.Minute
@@ -88,6 +90,9 @@ type SignedIn struct {
// Groups and Roles with the scopes groups and roles: the names of the
// user's groups (subgroups' members included) and roles in the tenant.
Groups, Roles []string
// Attributes with the scope attributes: the user's attributes yaiam
// releases to the client (department, cost_center, ...), by name.
Attributes map[string]string
// ACR is how strongly the user signed in ("pwd", "mfa", "phr"), AMR
// with what; AuthTime when.
ACR string
@@ -282,6 +287,7 @@ func (w *Web) Callback(ctx context.Context, rw http.ResponseWriter, r *http.Requ
return nil, errors.New("yaiam: UserInfo names another user than the ID token")
}
out.Username, out.Name, out.Email, out.EmailVerified, out.Groups, out.Roles = u.Username, u.Name, u.Email, u.EmailVerified, u.Groups, u.Roles
out.Attributes = u.Attributes
}
return out, nil
}
@@ -389,9 +395,10 @@ func (w *Web) checkIDToken(idToken, nonce string) (*idClaims, error) {
// webUserInfo is UserInfo's answer with what a web sign-in also takes.
type webUserInfo struct {
UserInfo
EmailVerified bool `json:"email_verified"`
Groups []string `json:"groups"`
Roles []string `json:"roles"`
EmailVerified bool `json:"email_verified"`
Groups []string `json:"groups"`
Roles []string `json:"roles"`
Attributes map[string]string `json:"attributes"`
}
func (w *Web) userInfo(ctx context.Context, m *metadata, t *Token) (*webUserInfo, error) {