Repository navigation
Expand file tree
/
Copy pathconfig_form.go.html
More file actions
283 lines (276 loc) · 12.7 KB
/
Copy pathconfig_form.go.html
File metadata and controls
283 lines (276 loc) · 12.7 KB
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
{{/* Copyright (c) ClaceIO, LLC */}}
{{/* SPDX-License-Identifier: Apache-2.0 */}}
{{/* RBAC group/role/grant form (/config/rbac/*): one shared form, sections
switch on .Data.Kind. Submissions edit the staged config draft */}}
{{ template "page_open" (dict "Ctx" . "Main" "space-y-4 max-w-2xl") }}
<!-- Header -->
<div class="page-header flex items-center gap-2 flex-wrap mb-2 md:mb-6">
{{ template "hamburger" . }}
<div>
{{ template "page_title" "Configuration" }}
<nav aria-label="Breadcrumb" class="breadcrumbs text-xs text-base-content/70 p-0">
<ul>
<li>
<a href="{{ .AppPath }}/config">Configuration</a>
</li>
<li>
<a href="{{ .AppPath }}/config/rbac">RBAC</a>
</li>
<li>
{{ if .Data.Values.is_edit }}edit{{ else }}new{{ end }}
{{ .Data.Kind }}
</li>
</ul></nav>
<h2 class="text-xl font-semibold">
{{ if .Data.Values.is_edit }}
Edit
{{ else }}
New
{{ end }}
{{ .Data.Kind }}
</h2>
<p class="page-desc text-sm text-base-content/70">
Changes are staged - publish from the RBAC page to make them
live
</p>
</div>
</div>
{{ template "page_progress" }}
{{ block "op_form" . }}
<div id="op-form-wrap" class="space-y-4">
{{ template "error_alert" .Data.Error }}
<form
method="post"
action="{{ .AppPath }}/config/rbac/{{ .Data.Kind }}{{ if and (eq .Data.Kind "grant") .Data.Values.is_edit }}?index={{ .Data.Values.index }}{{ end }}"
id="op-form"
hx-post="{{ .AppPath }}/config/rbac/{{ .Data.Kind }}{{ if and (eq .Data.Kind "grant") .Data.Values.is_edit }}?index={{ .Data.Values.index }}{{ end }}"
hx-target="#op-form-wrap"
hx-swap="outerHTML show:top showTarget:#op-form-wrap"
hx-indicator="#page-progress, #op-form"
class="card bg-base-100 border border-base-300">
<div class="card-body p-5 gap-5">
<input
type="hidden"
name="draft_version"
value="{{ .Data.DraftVersion }}" />
<input
type="hidden"
name="is_edit"
value="{{ if .Data.Values.is_edit }}true{{ else }}false{{ end }}" />
{{ if eq .Data.Kind "group" }}
<div>
<label class="block text-sm font-medium mb-1" for="rbac-name"
>Group name</label
>
<input
id="rbac-name"
name="name"
type="text"
required
value="{{ .Data.Values.name }}"
{{ if .Data.Values.is_edit }}readonly{{ end }}
placeholder="developers"
class="input w-full font-mono text-sm {{ if .Data.Values.is_edit }}bg-base-200{{ end }}" />
<p class="text-xs text-base-content/70 mt-1">
Reference the group in grants as
<span class="font-mono">group:name</span>
</p>
</div>
<div>
<label class="block text-sm font-medium mb-1" for="rbac-users"
>Members</label
>
<textarea
id="rbac-users"
name="users_text"
rows="6"
placeholder="user1@example.com user2@example.com"
class="textarea w-full font-mono text-sm leading-relaxed">{{ .Data.Values.users_text }}</textarea>
<p class="text-xs text-base-content/70 mt-1">
One user id per line. These are merged with any groups
coming from SAML
</p>
</div>
{{ else if eq .Data.Kind "role" }}
<div>
<label class="block text-sm font-medium mb-1" for="rbac-name"
>Role name</label
>
<input
id="rbac-name"
name="name"
type="text"
required
value="{{ .Data.Values.name }}"
{{ if .Data.Values.is_edit }}readonly{{ end }}
placeholder="developer"
class="input w-full font-mono text-sm {{ if .Data.Values.is_edit }}bg-base-200{{ end }}" />
</div>
<fieldset>
<legend class="block text-sm font-medium mb-2">Permissions</legend>
<div class="space-y-3">
{{ $selected := .Data.Values.selected }}
{{ range .Data.PermGroups }}
<fieldset>
<legend
class="text-xs text-base-content/70 uppercase tracking-wide"
>{{ .resource }}</legend
>
<div
class="grid grid-cols-2 sm:grid-cols-3 gap-x-4 gap-y-2 mt-1">
{{ range .permissions }}
<label
class="flex items-center gap-2 cursor-pointer text-xs font-mono">
<input
type="checkbox"
name="permissions"
value="{{ . }}"
class="checkbox checkbox-xs checkbox-primary"
{{ if index $selected . }}checked{{ end }} />
{{ . }}
</label>
{{ end }}
</div>
</fieldset>
{{ end }}
</div>
<p class="text-xs text-base-content/70 mt-2">
The manage permissions are composites of the other
permissions of their resource;
<span class="font-mono">app:approve</span>,
<span class="font-mono">secret:reveal</span> and
<span class="font-mono">binding:reveal</span> are never
implied and must be selected explicitly.
</p>
</fieldset>
<div>
<label
class="block text-sm font-medium mb-1"
for="rbac-custom"
>Custom entries</label
>
<textarea
id="rbac-custom"
name="custom_text"
rows="2"
placeholder="app:* role:other_role"
class="textarea w-full font-mono text-sm leading-relaxed">{{ .Data.Values.custom_text }}</textarea>
<p class="text-xs text-base-content/70 mt-1">
One entry per line: permission globs like
<span class="font-mono">app:*</span> or role references
like <span class="font-mono">role:other</span>
</p>
</div>
{{ else }}
<div>
<label class="block text-sm font-medium mb-1" for="rbac-desc"
>Description</label
>
<input
id="rbac-desc"
name="description"
type="text"
value="{{ .Data.Values.description }}"
placeholder="developers can manage team apps"
class="input w-full text-sm" />
</div>
<div>
<label class="block text-sm font-medium mb-1" for="rbac-users"
>Users / groups</label
>
<textarea
id="rbac-users"
name="users_text"
rows="4"
placeholder="user1@example.com group:developers"
class="textarea w-full font-mono text-sm leading-relaxed">{{ .Data.Values.users_text }}</textarea>
<p class="text-xs text-base-content/70 mt-1">
One per line: user ids or
<span class="font-mono">group:name</span> references
{{ if .Data.GroupNames }}
- groups:
{{ range .Data.GroupNames }}
<span class="font-mono">{{ . }}</span>
{{ end }}
{{ end }}
</p>
</div>
<fieldset>
<legend class="block text-sm font-medium mb-2">Roles</legend>
{{ if .Data.RoleNames }}
<div class="grid grid-cols-2 sm:grid-cols-3 gap-x-4 gap-y-2">
{{ $granted := .Data.Values.roles }}
{{ range .Data.RoleNames }}
<label
class="flex items-center gap-2 cursor-pointer text-xs font-mono">
<input
type="checkbox"
name="roles"
value="{{ . }}"
class="checkbox checkbox-xs checkbox-primary"
{{ if index $granted . }}checked{{ end }} />
{{ . }}
</label>
{{ end }}
</div>
{{ else }}
<p class="text-xs text-base-content/70">
No roles defined yet - add a role first, or save the
grant and add roles before publishing
</p>
{{ end }}
</fieldset>
<div>
<label
class="block text-sm font-medium mb-1"
for="rbac-targets"
>Targets</label
>
<textarea
id="rbac-targets"
name="targets_text"
rows="4"
placeholder="/myteam/* service:postgres/* binding:/myteam/**"
class="textarea w-full font-mono text-sm leading-relaxed">{{ .Data.Values.targets_text }}</textarea>
<p class="text-xs text-base-content/70 mt-1">
One target per line, scoping the roles' permissions to
matching entries. An app path glob like
<span class="font-mono">/myteam/*</span> or
<span class="font-mono">example.com:/**</span> scopes the
app:* permissions;
<span class="font-mono">service:<glob></span> matches
service ids (<span class="font-mono">service:postgres/*</span>)
and scopes the service:* permissions;
<span class="font-mono">binding:<glob></span> matches
binding paths
(<span class="font-mono">binding:/myteam/**</span>) and
scopes the binding:* permissions.
<span class="font-mono">all</span> matches every app,
service and binding. Permissions of a kind with no matching
target entry are not granted; all other permissions are
global and apply regardless of the targets.
</p>
</div>
{{ end }}
<div class="card-actions justify-end pt-2">
<a href="{{ .AppPath }}/config/rbac" class="btn btn-ghost btn-sm"
>Cancel</a
>
<button
type="submit"
{{ if not (index .Data.Perms "config:update") }}
disabled data-tip="requires config:update"
{{ end }}
class="btn btn-primary btn-sm transition-transform duration-150 active:scale-95 {{ if not (index .Data.Perms "config:update") }}tooltip tooltip-top{{ end }}">
{{ if .Data.Values.is_edit }}
Save to staged config
{{ else }}
Add to staged config
{{ end }}
</button>
</div>
</div>
</form>
</div>
{{ end }}
{{ template "page_close" . }}