ldap.go 1.8 KB

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