mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: add query to fetch top level idp claim fields (#15525)
Adds an api endpoint to grab all available sync field options for IDP sync. This is for autocomplete on idp sync forms. This is required for organization admins to have some insight into the claim fields available when configuring group/role sync.
This commit is contained in:
@@ -8409,6 +8409,35 @@ func (q *FakeQuerier) ListWorkspaceAgentPortShares(_ context.Context, workspaceI
|
||||
return shares, nil
|
||||
}
|
||||
|
||||
func (q *FakeQuerier) OIDCClaimFields(_ context.Context, organizationID uuid.UUID) ([]string, error) {
|
||||
orgMembers := q.getOrganizationMemberNoLock(organizationID)
|
||||
|
||||
var fields []string
|
||||
for _, link := range q.userLinks {
|
||||
if organizationID != uuid.Nil {
|
||||
inOrg := slices.ContainsFunc(orgMembers, func(organizationMember database.OrganizationMember) bool {
|
||||
return organizationMember.UserID == link.UserID
|
||||
})
|
||||
if !inOrg {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
if link.LoginType != database.LoginTypeOIDC {
|
||||
continue
|
||||
}
|
||||
|
||||
for k := range link.Claims.IDTokenClaims {
|
||||
fields = append(fields, k)
|
||||
}
|
||||
for k := range link.Claims.UserInfoClaims {
|
||||
fields = append(fields, k)
|
||||
}
|
||||
}
|
||||
|
||||
return slice.Unique(fields), nil
|
||||
}
|
||||
|
||||
func (q *FakeQuerier) OrganizationMembers(_ context.Context, arg database.OrganizationMembersParams) ([]database.OrganizationMembersRow, error) {
|
||||
if err := validateDatabaseType(arg); err != nil {
|
||||
return []database.OrganizationMembersRow{}, err
|
||||
|
||||
Reference in New Issue
Block a user