-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdot.go
More file actions
25 lines (21 loc) · 867 Bytes
/
dot.go
File metadata and controls
25 lines (21 loc) · 867 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package scimpatch
import (
"strings"
)
// Resolve an attribute name with dot notation ("name.givenName") to a new scopedMap ("name") and scopedAttr ("givenName")
// This is used prominently by MS Entra. See https://learn.microsoft.com/en-us/entra/identity/app-provisioning/application-provisioning-config-problem-scim-compatibility#flags-to-alter-the-scim-behavior
func resolveDotNotationAttribute(scopedMap map[string]interface{}, scopedAttr string) (map[string]interface{}, string) {
attrParts := strings.SplitN(scopedAttr, ".", 2)
if len(attrParts) == 1 {
return scopedMap, scopedAttr
}
if subMap, exists := scopedMap[attrParts[0]]; exists {
scopedMap = subMap.(map[string]interface{})
} else {
subMap := map[string]interface{}{}
scopedMap[attrParts[0]] = subMap
scopedMap = subMap
}
scopedAttr = attrParts[1]
return scopedMap, scopedAttr
}