Skip to content

Commit d402291

Browse files
committed
Show SSH keys
1 parent 12a923c commit d402291

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

handlers/users.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ type UserForm struct {
4040
OTPSecret string
4141
OTPImg string
4242
PassAppBcrypt []string
43+
SSHKeys []string
4344
NewPassApp string
4445
PrimaryGroup int
4546
OtherGroups []int
@@ -159,7 +160,7 @@ func (userf *UserForm) Validate(cfg PassPolicy) bool {
159160
userf.Errors["Homedir"] = Tr(lang, "Bad character")
160161
}
161162

162-
validLoginShell := []string{"/bin/bash","/bin/sh","/bin/false"}
163+
validLoginShell := []string{"/bin/bash", "/bin/sh", "/bin/false"}
163164
if userf.LoginShell != "" && strContains(validLoginShell, userf.LoginShell) == false {
164165
userf.Errors["LoginShell"] = Tr(lang, "Forbidden LoginShell")
165166
}
@@ -168,12 +169,12 @@ func (userf *UserForm) Validate(cfg PassPolicy) bool {
168169
}
169170

170171
func strContains(s []string, e string) bool {
171-
for _, a := range s {
172-
if a == e {
173-
return true
174-
}
175-
}
176-
return false
172+
for _, a := range s {
173+
if a == e {
174+
return true
175+
}
176+
}
177+
return false
177178
}
178179

179180
// Helpers
@@ -253,6 +254,7 @@ func UserEdit(c *gin.Context) {
253254
Disabled: u.Disabled,
254255
OTPSecret: u.OTPSecret,
255256
PassAppBcrypt: u.PassAppBcrypt,
257+
SSHKeys: u.SSHKeys,
256258
Lang: lang,
257259
}
258260

routes/web/templates/user/edit.tmpl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,17 @@
193193
{{ end }}
194194
</div>
195195
</div>
196+
{{ with len .u.SSHKeys }}
197+
<div class="row mb-3">
198+
<label for="inputSSHKeys" class="col-sm-2 col-form-label">{{ tr "SSHkeys" }}</label>
199+
<div class="col-sm-6">
200+
{{ . }} SSH key(s)
201+
<div class="form-text">
202+
SSH keys need to be managed in glauth file
203+
</div>
204+
</div>
205+
</div>
206+
{{ end }}
196207
<div class="container-fluid">
197208
<div class="d-flex justify-content-between">
198209
<div class="col-sm-6">

0 commit comments

Comments
 (0)