Skip to content

Commit 4fedc7c

Browse files
authored
chore: include merged claims into the database (#15570)
Merging happens before IDP sync. Storing this will make some SQL queries much simplier.
1 parent 097b84f commit 4fedc7c

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

coderd/database/types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ func (p AgentIDNamePair) Value() (driver.Value, error) {
214214
type UserLinkClaims struct {
215215
IDTokenClaims map[string]interface{} `json:"id_token_claims"`
216216
UserInfoClaims map[string]interface{} `json:"user_info_claims"`
217+
// MergeClaims are computed in Golang. It is the result of merging
218+
// the IDTokenClaims and UserInfoClaims. UserInfoClaims take precedence.
219+
MergedClaims map[string]interface{} `json:"merged_claims"`
217220
}
218221

219222
func (a *UserLinkClaims) Scan(src interface{}) error {

coderd/userauth.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,6 +1326,7 @@ func (api *API) userOIDC(rw http.ResponseWriter, r *http.Request) {
13261326
UserClaims: database.UserLinkClaims{
13271327
IDTokenClaims: idtokenClaims,
13281328
UserInfoClaims: userInfoClaims,
1329+
MergedClaims: mergedClaims,
13291330
},
13301331
}).SetInitAuditRequest(func(params *audit.RequestParams) (*audit.Request[database.User], func()) {
13311332
return audit.InitRequest[database.User](rw, params)

enterprise/dbcrypt/dbcrypt_internal_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@ func TestUserLinks(t *testing.T) {
6464
"number": float64(2),
6565
},
6666
},
67+
MergedClaims: map[string]interface{}{
68+
"sub": "123",
69+
"groups": []interface{}{
70+
"foo", "bar",
71+
},
72+
"number": float64(2),
73+
"struct": map[string]interface{}{
74+
"number": float64(2),
75+
},
76+
},
6777
}
6878

6979
updated, err := crypt.UpdateUserLink(ctx, database.UpdateUserLinkParams{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy