-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathldap.go
49 lines (43 loc) · 1.76 KB
/
ldap.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"net/http"
"path/filepath"
ldap "imuslab.com/arozos/mod/auth/ldap"
fs "imuslab.com/arozos/mod/filesystem"
prout "imuslab.com/arozos/mod/prouter"
)
func ldapInit() {
//ldap
authIcon := filepath.Join(vendorResRoot, "auth_icon.png")
if !fs.FileExists(authIcon) {
authIcon = "./app/img/public/auth_icon.png"
}
ldapHandler := ldap.NewLdapHandler(authAgent, registerHandler, sysdb, permissionHandler, userHandler, nightlyManager, authIcon)
//add a entry to the system settings
adminRouter := prout.NewModuleRouter(prout.RouterOption{
ModuleName: "System Setting",
AdminOnly: true,
UserHandler: userHandler,
DeniedHandler: func(w http.ResponseWriter, r *http.Request) {
errorHandlePermissionDenied(w, r)
},
})
registerSetting(settingModule{
Name: "LDAP",
Desc: "Allows external account access to system",
IconPath: "SystemAO/advance/img/small_icon.png",
Group: "Security",
StartDir: "SystemAO/advance/ldap.html",
RequireAdmin: true,
})
adminRouter.HandleFunc("/system/auth/ldap/config/read", ldapHandler.ReadConfig)
adminRouter.HandleFunc("/system/auth/ldap/config/write", ldapHandler.WriteConfig)
adminRouter.HandleFunc("/system/auth/ldap/config/testConnection", ldapHandler.TestConnection)
adminRouter.HandleFunc("/system/auth/ldap/config/syncorizeUser", ldapHandler.SynchronizeUser)
//login interface and login handler
http.HandleFunc("/system/auth/ldap/login", ldapHandler.HandleLogin)
http.HandleFunc("/system/auth/ldap/setPassword", ldapHandler.HandleSetPassword)
http.HandleFunc("/system/auth/ldap/newPassword", ldapHandler.HandleNewPasswordPage)
http.HandleFunc("/ldapLogin.system", ldapHandler.HandleLoginPage)
http.HandleFunc("/system/auth/ldap/checkldap", ldapHandler.HandleCheckLDAP)
}