feat: avatar, account menu, and single sign-on from Go Loose
Signing in now starts at the sign-in screen and one button that hands the browser to Go Loose, which returns to the welcome page. Nothing redirects to the identity provider on its own any more: that fired on every anonymous visit and read as a redirect loop rather than as a choice to sign in. The password form remains only where the API reports that Go Loose login is not configured for the host, because otherwise the application is unreachable on a bare localhost. A person's picture is carried through from the Go Loose identity and rendered in the account menu and on the profile page, with their initials as the fallback. Two things make that fallback necessary rather than decorative: Go Loose retires a picture key when a picture is replaced, so a link cached in a browser can be dead, and most people have not uploaded one. The URL is deliberately not persisted locally, since a stored key would keep failing after the picture changed. The account menu is a disclosure rather than a hover menu: a real button with aria-expanded, Escape and outside clicks closing it, and focus returning to the trigger. It is not an ARIA menu, because its actions are a link and a button and menuitem roles would strip the link semantics from one of them for no gain. The account URL of the Go Loose identity is resolved on each sign-in and is read from the live identity provider every time, which is also what makes it correct after a picture change. Depends on the Go Loose revision that serves avatar_url through /connect/userinfo, so the picture URL reaches this application at all.
This commit is contained in:
parent
6be21597d5
commit
5449cd3d8d
52 changed files with 1927 additions and 434 deletions
|
|
@ -31,6 +31,20 @@ type GoLooseTenant struct {
|
|||
ClientSecret string
|
||||
}
|
||||
|
||||
const (
|
||||
// DefaultAuthDomain is the Go Loose identity domain used for local
|
||||
// development. Production signs in through DefaultProdAuthDomain.
|
||||
DefaultAuthDomain = "auth-dev.urpi.be"
|
||||
// DefaultProdAuthDomain is the Go Loose identity domain used in production.
|
||||
DefaultProdAuthDomain = "auth.urpi.be"
|
||||
// DefaultAppDomain is the public application domain used for local
|
||||
// development, matching deploy/helm/go-guess/values-dev.yaml.
|
||||
DefaultAppDomain = "guess-dev.urpi.be"
|
||||
// DefaultProdAppDomain is the public application domain used in production,
|
||||
// matching deploy/helm/go-guess/values.yaml.
|
||||
DefaultProdAppDomain = "guess.urpi.be"
|
||||
)
|
||||
|
||||
// GoLooseCredentialEnv returns the environment variable names holding the Go
|
||||
// Loose client credentials of a tenant.
|
||||
func GoLooseCredentialEnv(slug string) (idEnv, secretEnv string) {
|
||||
|
|
@ -63,10 +77,17 @@ func Load() (Config, error) {
|
|||
return cfg, nil
|
||||
}
|
||||
|
||||
// loadGoLoose reads the Go Loose browser login configuration. Both domains are
|
||||
// single host suffixes: a tenant named "nmbs" signs in through
|
||||
// https://nmbs.<AuthDomain> and is served from https://nmbs.<AppDomain>.
|
||||
//
|
||||
// The defaults are the development domains, matching the rest of the local
|
||||
// defaults in Load. Production deployments set GO_LOOSE_AUTH_DOMAIN and
|
||||
// GO_LOOSE_APP_DOMAIN explicitly (see deploy/helm/go-guess/values.yaml).
|
||||
func loadGoLoose() GoLooseConfig {
|
||||
cfg := GoLooseConfig{
|
||||
AuthDomain: env("GO_LOOSE_AUTH_DOMAIN", "auth.dev"),
|
||||
AppDomain: env("GO_LOOSE_APP_DOMAIN", "guess.dev"),
|
||||
AuthDomain: env("GO_LOOSE_AUTH_DOMAIN", DefaultAuthDomain),
|
||||
AppDomain: env("GO_LOOSE_APP_DOMAIN", DefaultAppDomain),
|
||||
CAFile: os.Getenv("GO_LOOSE_CA_FILE"),
|
||||
Tenants: map[string]GoLooseTenant{},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue