fix querying claim data on the dashboard (#1560)

This commit is contained in:
Caleb Doxsey 2020-10-29 10:49:02 -06:00 committed by GitHub
parent 93c257259e
commit 10b5c5ca0e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 56 additions and 39 deletions

File diff suppressed because one or more lines are too long

View file

@ -12,8 +12,8 @@
<div class="card">
<div class="card-header">
<h2>Current user</h2>
{{if .User.Claims.picture }}
<img class="icon" src="{{.User.GetClaim "picture"}}" alt="user image" />
{{with .User.GetClaim "picture"}}
<img class="icon" src="{{.}}" alt="user image" />
{{else}}
<img
class="icon"
@ -27,68 +27,74 @@
<section>
<p class="message">Your current session details.</p>
<fieldset>
{{if .RedirectURL}}
{{with .RedirectURL}}
<label>
<span>URL</span>
<a href="{{.RedirectURL}}">{{.RedirectURL}}</a>
<a href="{{.}}">{{.}}</a>
</label>
{{end}}
{{if .User.Name}}
{{with .User.Name}}
<label>
<span>Name</span>
<input
type="text"
class="field"
value="{{.User.Name}}"
title="{{.User.Name}}"
value="{{.}}"
title="{{.}}"
disabled
/>
</label>
{{else}} {{if .User.Claims.given_name}}
{{else}}
{{with .User.GetClaim "given_name"}}
<label>
<span>Given Name</span>
<input
type="text"
class="field"
value="{{.User.GetClaim "given_name"}}"
title="{{.User.GetClaim "given_name"}}"
value="{{.}}"
title="{{.}}"
disabled
/>
</label>
{{end}} {{if .User.Claims.family_name}}
{{end}}
{{with .User.GetClaim "family_name"}}
<label>
<span>Family Name</span>
<input
type="text"
class="field"
value="{{.User.GetClaim "family_name"}}"
title="{{.User.GetClaim "family_name"}}"
value="{{.}}"
title="{{.}}"
disabled
/>
</label>
{{end}} {{end}} {{if .User.Id}}
{{end}}
{{end}}
{{with .User.Id}}
<label>
<span>UserID</span>
<input
type="text"
class="field"
value="{{.User.Id}}"
title="{{.User.Id}}"
value="{{.}}"
title="{{.}}"
disabled
/>
</label>
{{end}} {{if .User.Email}}
{{end}}
{{with .User.Email}}
<label>
<span>Email</span>
<input
type="email"
class="field"
value="{{.User.Email}}"
title="{{.User.Email}}"
value="{{.}}"
title="{{.}}"
disabled
/>
</label>
{{end}} {{range $i,$_:= .DirectoryGroups}}
{{end}}
{{range $i,$_:= .DirectoryGroups}}
<label>
{{if eq $i 0}}
<span>Group</span>

File diff suppressed because one or more lines are too long

View file

@ -1,4 +1,4 @@
//go:generate statik -src=./assets -include=*.svg,*.html,*.css,*.js -ns web
//go:generate go run github.com/rakyll/statik -src=./assets -include=*.svg,*.html,*.css,*.js -ns web
// Package frontend handles the generation, and instantiation of Pomerium's
// html templates.

View file

@ -69,3 +69,14 @@ func (x *User) AddClaims(claims identity.FlattenedClaims) {
x.Claims[k] = svs
}
}
// GetClaim returns a claim.
//
// This method is used by the dashboard template HTML to display claim data.
func (x *User) GetClaim(claim string) []interface{} {
var vs []interface{}
for _, sv := range x.GetClaims()[claim].GetValues() {
vs = append(vs, sv.AsInterface())
}
return vs
}