feat: make MFA status visible in WebAdmin (#844)

Signed-off-by: Tim Birkett <tim.birkett@sainsburys.co.uk>
This commit is contained in:
Tim Birkett 2022-05-17 18:27:12 +01:00 committed by GitHub
parent 9abd186166
commit a87aa9b98e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 0 deletions

View file

@ -1331,6 +1331,15 @@ func (u *User) GetBandwidthAsString() string {
return result
}
// GetMFAStatusAsString returns MFA status
func (u *User) GetMFAStatusAsString() string {
result := "-"
if u.Filters.TOTPConfig.Enabled {
result = strings.Join(u.Filters.TOTPConfig.Protocols, ", ")
}
return result
}
// GetInfoString returns user's info as string.
// Storage provider, number of public keys, max sessions, uid,
// gid, denied and allowed IP/Mask are returned

View file

@ -130,6 +130,7 @@ type basePage struct {
CSRFToken string
HasDefender bool
HasExternalLogin bool
HasMFA bool
LoggedAdmin *dataprovider.Admin
Branding UIBranding
}
@ -485,6 +486,7 @@ func (s *httpdServer) getBasePageData(title, currentURL string, r *http.Request)
Version: version.GetAsString(),
LoggedAdmin: getAdminFromToken(r),
HasDefender: common.Config.DefenderConfig.Enabled,
HasMFA: len(mfa.GetAvailableTOTPConfigNames()) > 0,
HasExternalLogin: isLoggedInWithOIDC(r),
CSRFToken: csrfToken,
Branding: s.binding.Branding.WebAdmin,

View file

@ -32,6 +32,7 @@
<th>ID</th>
<th>Username</th>
<th>Status</th>
{{if .HasMFA }}<th>MFA</th>{{end}}
<th>Permissions</th>
<th>Other</th>
</tr>
@ -42,6 +43,7 @@
<td>{{.ID}}</td>
<td>{{.Username}}</td>
<td>{{if eq .Status 1 }}Active{{else}}Inactive{{end}}</td>
{{if $.HasMFA }}<td>{{if .Filters.TOTPConfig.Enabled }}Enabled{{else}}-{{end}}</td>{{end}}
<td>{{.GetPermissionsAsString}}</td>
<td>{{.GetInfoString}}</td>
</tr>

View file

@ -32,6 +32,7 @@
<th>ID</th>
<th>Username</th>
<th>Status</th>
{{if .HasMFA }}<th>MFA</th>{{end}}
<th>Bandwidth</th>
<th>Quota</th>
<th>Other</th>
@ -43,6 +44,7 @@
<td>{{.ID}}</td>
<td>{{.Username}}</td>
<td>{{.GetStatusAsString}}</td>
{{if $.HasMFA }}<td>{{.GetMFAStatusAsString}}</td>{{end}}
<td>{{.GetBandwidthAsString}}</td>
<td>{{.GetQuotaSummary}}</td>
<td>{{.GetInfoString}}</td>