diff --git a/pages/login.go.html b/pages/login.go.html
index 49cd4d7..c8f8021 100644
--- a/pages/login.go.html
+++ b/pages/login.go.html
@@ -18,11 +18,11 @@
-
+
-
+
diff --git a/server/login.go b/server/login.go
index dbaecd3..2794b8d 100644
--- a/server/login.go
+++ b/server/login.go
@@ -16,18 +16,37 @@ import (
"time"
)
+// getUserLoginName finds the `login_name` query parameter within the `/authorize` redirect url
+func getUserLoginName(req *http.Request) string {
+ q := req.URL.Query()
+ if !q.Has("redirect") {
+ return ""
+ }
+ originUrl, err := url.ParseRequestURI(q.Get("redirect"))
+ if err != nil {
+ return ""
+ }
+ if originUrl.Path != "/authorize" {
+ return ""
+ }
+ return originUrl.Query().Get("login_name")
+}
+
func (h *HttpServer) LoginGet(rw http.ResponseWriter, req *http.Request, _ httprouter.Params, auth UserAuth) {
if !auth.IsGuest() {
h.SafeRedirect(rw, req)
return
}
+ loginName := getUserLoginName(req)
+
rw.Header().Set("Content-Type", "text/html")
rw.WriteHeader(http.StatusOK)
pages.RenderPageTemplate(rw, "login", map[string]any{
"ServiceName": h.serviceName,
"Redirect": req.URL.Query().Get("redirect"),
"Mismatch": req.URL.Query().Get("mismatch"),
+ "LoginName": loginName,
})
}
diff --git a/server/server.go b/server/server.go
index 1489f6d..0286800 100644
--- a/server/server.go
+++ b/server/server.go
@@ -135,7 +135,7 @@ func NewHttpServer(listen, domain, otpIssuer, serviceName string, mailer mail.Ma
if !scope2.ScopesExist(a) {
return "", errInvalidScope
}
- return "openid", nil
+ return a, nil
})
r.GET("/.well-known/openid-configuration", func(rw http.ResponseWriter, req *http.Request, params httprouter.Params) {