-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransform_template.tmpl
110 lines (104 loc) · 2.73 KB
/
transform_template.tmpl
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
{
{{$email := $.primaryEmail}}
"objects": [
{{ if contains $.kind "admin#directory#user" }}
{
"id": "{{ $email }}",
"type": "user",
"displayName": "{{ $.name.fullName }}",
"created_at":"{{ $.creationTime }}",
"properties":{
"id": "{{ $.id }}",
"email": "{{ $email }}",
{{ fromEnv "connection_id" "ASERTO_CONNECTION_ID" }},
{{ if $.recoveryPhone }}
"phone": "{{ $.recoveryPhone }}",
{{ end }}
{{ if $.thumbnailPhotoUrl }}
"picture": "{{ $.thumbnailPhotoUrl }}",
{{ end }}
{{ if $.isAdmin }}
"isAdmin": true
{{ else }}
"isAdmin": false
{{ end }}
}
},
{
"id": "{{ $email }}",
"type": "identity",
"properties": {
"kind": "IDENTITY_KIND_EMAIL",
"provider": "google-workspace",
{{ fromEnv "connection_id" "ASERTO_CONNECTION_ID" }},
"verified": true
}
},
{
"id": "{{ $.id }}",
"type": "identity",
"properties": {
"kind": "IDENTITY_KIND_PID",
"provider": "google-workspace",
{{ fromEnv "connection_id" "ASERTO_CONNECTION_ID" }},
"verified": true
}
}
{{ end }}
{{ if contains $.kind "admin#directory#group" }}
{
"id": "{{ $.email }}",
"type": "group",
"displayName": "{{ $.name }}",
"properties": {
"email": "{{ $.email }}",
{{ fromEnv "connection_id" "ASERTO_CONNECTION_ID" }},
"id": "{{ $.id }}"
}
}
{{ end }}
],
"relations":[
{{ if contains $.kind "admin#directory#user" }}
{
"object_type": "identity",
"object_id": "{{$.id}}",
"relation": "identifier",
"subject_type": "user",
"subject_id": "{{$email}}"
},
{
"object_type": "identity",
"object_id": "{{$email}}",
"relation": "identifier",
"subject_type": "user",
"subject_id": "{{$email}}"
}
{{ end }}
{{ if contains $.kind "admin#directory#group" }}
{{ $index := 0 }}
{{ range $i, $element := $.users }}
{{ $subject_type := $element.type }}
{{ if contains $element.type "USER" }}
{{ $subject_type = "user" }}
{{ else if contains $element.type "GROUP"}}
{{ $subject_type = "group" }}
{{ else }}
{{ continue }}
{{ end }}
{{ if $index }},{{ end }}
{{$index = add $index 1}}
{
"object_type": "group",
"object_id": "{{$.email}}",
"relation": "member",
"subject_type": "{{$subject_type}}",
{{ if contains $element.type "GROUP" }}
"subject_relation": "member",
{{ end }}
"subject_id": "{{$element.email}}"
}
{{ end }}
{{ end }}
]
}