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 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. // GetInfoString returns user's info as string.
// Storage provider, number of public keys, max sessions, uid, // Storage provider, number of public keys, max sessions, uid,
// gid, denied and allowed IP/Mask are returned // gid, denied and allowed IP/Mask are returned

View file

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

View file

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

View file

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