Removed LDAP web UI
This commit is contained in:
No files matched your search
@@ -44,8 +44,7 @@
|
|||||||
{{ end }}
|
{{ end }}
|
||||||
{{ if .User.IsAdmin }}
|
{{ if .User.IsAdmin }}
|
||||||
<div class="col-span-full">{{ component "link" (props . "To" (path
|
<div class="col-span-full">{{ component "link" (props . "To" (path
|
||||||
"/admin/create_user")) }}create new{{ end }} {{component "link"
|
"/admin/create_user")) }}create new{{ end }}</div>
|
||||||
(props . "To" (path "/admin/ldap")) }}LDAP{{ end }}</div>
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|||||||
@@ -1,68 +0,0 @@
|
|||||||
{{ component "layout" . }}
|
|
||||||
{{ component "layout_user" . }}
|
|
||||||
|
|
||||||
{{ component "block" (props .
|
|
||||||
"Icon" "user"
|
|
||||||
"Name" "configuring LDAP"
|
|
||||||
) }}
|
|
||||||
<form class="flex flex-col gap-2 items-end" action="{{ path
|
|
||||||
"/admin/ldap_do" }}" method="post">
|
|
||||||
<p>Leave the server empty to disable LDAP.</p>
|
|
||||||
<input
|
|
||||||
type="username"
|
|
||||||
id="bind_user"
|
|
||||||
name="bind_user"
|
|
||||||
placeholder="bind username"
|
|
||||||
value={{ default "" .CurrentBindUID }}
|
|
||||||
>
|
|
||||||
<input
|
|
||||||
type="password"
|
|
||||||
id="bind_user_password"
|
|
||||||
name="bind_user_password"
|
|
||||||
placeholder="bind password"
|
|
||||||
>
|
|
||||||
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
id="fqdn"
|
|
||||||
name="fqdn"
|
|
||||||
placeholder="LDAP server"
|
|
||||||
value={{ default "" .CurrentFQDN }}
|
|
||||||
>
|
|
||||||
|
|
||||||
<input
|
|
||||||
type="number"
|
|
||||||
id="port"
|
|
||||||
name="port"
|
|
||||||
placeholder="port"
|
|
||||||
value={{ default "389" .CurrentPort }}
|
|
||||||
>
|
|
||||||
|
|
||||||
<select name="tls" id="tls">
|
|
||||||
<option value="true">TLS</option>
|
|
||||||
<option value="false" {{ .CurrentNoTLS }}>None</option>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
id="base_dn"
|
|
||||||
name="base_dn"
|
|
||||||
placeholder="Base DN"
|
|
||||||
value={{ default "" .CurrentBaseDN }}
|
|
||||||
>
|
|
||||||
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
id="filter"
|
|
||||||
name="filter"
|
|
||||||
placeholder="filter"
|
|
||||||
value={{ default "" .CurrentFilter }}
|
|
||||||
>
|
|
||||||
|
|
||||||
|
|
||||||
<input type="submit" value="update">
|
|
||||||
</form>
|
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
{{ end }}
|
|
||||||
{{ end }}
|
|
||||||
@@ -85,8 +85,6 @@ func New(dbc *db.DB, sessDB *gormstore.Store, scanner *scanner.Scanner, podcasts
|
|||||||
// user routes (if session is valid)
|
// user routes (if session is valid)
|
||||||
c.Handle("/logout", userChain(respRaw(c.ServeLogout)))
|
c.Handle("/logout", userChain(respRaw(c.ServeLogout)))
|
||||||
c.Handle("/home", userChain(resp(c.ServeHome)))
|
c.Handle("/home", userChain(resp(c.ServeHome)))
|
||||||
c.Handle("/ldap", userChain(resp(c.ServeLDAPConfig)))
|
|
||||||
c.Handle("/ldap_do", userChain(resp(c.ServeLDAPConfigDo)))
|
|
||||||
c.Handle("/change_username", userChain(resp(c.ServeChangeUsername)))
|
c.Handle("/change_username", userChain(resp(c.ServeChangeUsername)))
|
||||||
c.Handle("/change_username_do", userChain(resp(c.ServeChangeUsernameDo)))
|
c.Handle("/change_username_do", userChain(resp(c.ServeChangeUsernameDo)))
|
||||||
c.Handle("/change_password", userChain(resp(c.ServeChangePassword)))
|
c.Handle("/change_password", userChain(resp(c.ServeChangePassword)))
|
||||||
|
|||||||
@@ -138,125 +138,6 @@ func (c *Controller) ServeUnlinkListenBrainzDo(r *http.Request) *Response {
|
|||||||
return &Response{redirect: "/admin/home"}
|
return &Response{redirect: "/admin/home"}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Controller) ServeLDAPConfig(_ *http.Request) *Response {
|
|
||||||
data := &templateData{}
|
|
||||||
|
|
||||||
data.CurrentBindUID, _ = c.dbc.GetSetting("ldap_bind_user")
|
|
||||||
data.CurrentFQDN, _ = c.dbc.GetSetting("ldap_fqdn")
|
|
||||||
data.CurrentPort, _ = c.dbc.GetSetting("ldap_port")
|
|
||||||
data.CurrentBaseDN, _ = c.dbc.GetSetting("ldap_base_dn")
|
|
||||||
data.CurrentFilter, _ = c.dbc.GetSetting("ldap_filter")
|
|
||||||
|
|
||||||
// This is to fix the fact that select boxes are strange.
|
|
||||||
currentTLS, _ := c.dbc.GetSetting("ldap_tls")
|
|
||||||
data.CurrentNoTLS = "selected"
|
|
||||||
|
|
||||||
if currentTLS == "true" {
|
|
||||||
data.CurrentNoTLS = ""
|
|
||||||
}
|
|
||||||
|
|
||||||
return &Response{
|
|
||||||
template: "ldap.tmpl",
|
|
||||||
data: data,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Controller) ServeLDAPConfigDo(r *http.Request) *Response {
|
|
||||||
bindUID := r.FormValue("bind_user")
|
|
||||||
bindPSWD := r.FormValue("bind_user_password") // TODO: Secure this better.
|
|
||||||
fqdn := r.FormValue("fqdn")
|
|
||||||
port := r.FormValue("port")
|
|
||||||
tls := r.FormValue("tls")
|
|
||||||
baseDN := r.FormValue("base_dn")
|
|
||||||
filter := r.FormValue("filter")
|
|
||||||
|
|
||||||
if bindUID == "" || bindPSWD == "" || port == "" || baseDN == "" || filter == "" {
|
|
||||||
return &Response{
|
|
||||||
redirect: r.Referer(),
|
|
||||||
flashW: []string{"please provide a bind username and password, port, base CN, and filter"},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
err := c.dbc.SetSetting("ldap_bind_user", bindUID)
|
|
||||||
if err != nil {
|
|
||||||
log.Println("Failed to set bind user:", err)
|
|
||||||
|
|
||||||
return &Response{
|
|
||||||
redirect: r.Referer(),
|
|
||||||
flashW: []string{"Failed to set bind user."},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
err = c.dbc.SetSetting("ldap_bind_user_password", bindPSWD)
|
|
||||||
if err != nil {
|
|
||||||
log.Println("Failed to set bind user password:", err)
|
|
||||||
|
|
||||||
return &Response{
|
|
||||||
redirect: r.Referer(),
|
|
||||||
flashW: []string{"Failed to set bind user password."},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
err = c.dbc.SetSetting("ldap_fqdn", fqdn)
|
|
||||||
if err != nil {
|
|
||||||
log.Println("Failed to set server:", err)
|
|
||||||
|
|
||||||
return &Response{
|
|
||||||
redirect: r.Referer(),
|
|
||||||
flashW: []string{"Failed to set server."},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
err = c.dbc.SetSetting("ldap_port", port)
|
|
||||||
if err != nil {
|
|
||||||
log.Println("Failed to set port:", err)
|
|
||||||
|
|
||||||
return &Response{
|
|
||||||
redirect: r.Referer(),
|
|
||||||
flashW: []string{"Failed to set port."},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
err = c.dbc.SetSetting("ldap_tls", tls)
|
|
||||||
if err != nil {
|
|
||||||
log.Println("Failed to set TLS:", err)
|
|
||||||
|
|
||||||
return &Response{
|
|
||||||
redirect: r.Referer(),
|
|
||||||
flashW: []string{"Failed to set TLS."},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
err = c.dbc.SetSetting("ldap_base_dn", baseDN)
|
|
||||||
if err != nil {
|
|
||||||
log.Println("Failed to set base DN:", err)
|
|
||||||
|
|
||||||
return &Response{
|
|
||||||
redirect: r.Referer(),
|
|
||||||
flashW: []string{"Failed to set base DN."},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
err = c.dbc.SetSetting("ldap_filter", filter)
|
|
||||||
if err != nil {
|
|
||||||
log.Println("Failed to set filter:", err)
|
|
||||||
|
|
||||||
return &Response{
|
|
||||||
redirect: r.Referer(),
|
|
||||||
flashW: []string{"Failed to set filter."},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if fqdn == "" {
|
|
||||||
return &Response{
|
|
||||||
redirect: "/admin/home",
|
|
||||||
flashW: []string{"LDAP server was left empty, LDAP authentication will be disabled."},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return &Response{redirect: "/admin/home"}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Controller) ServeChangeUsername(r *http.Request) *Response {
|
func (c *Controller) ServeChangeUsername(r *http.Request) *Response {
|
||||||
user, err := selectedUserIfAdmin(c, r)
|
user, err := selectedUserIfAdmin(c, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user