2023-07-25 19:37:46 +00:00
|
|
|
/*
|
|
|
|
Routes the requests to the app
|
|
|
|
*/
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/gorilla/mux"
|
|
|
|
)
|
|
|
|
|
|
|
|
type ConfigFile struct {
|
|
|
|
HttpBindAddr string `json:"http_bind_addr"`
|
|
|
|
LdapServerAddr string `json:"ldap_server_addr"`
|
|
|
|
LdapTLS bool `json:"ldap_tls"`
|
|
|
|
|
|
|
|
BaseDN string `json:"base_dn"`
|
|
|
|
UserBaseDN string `json:"user_base_dn"`
|
|
|
|
UserNameAttr string `json:"user_name_attr"`
|
|
|
|
GroupBaseDN string `json:"group_base_dn"`
|
|
|
|
GroupNameAttr string `json:"group_name_attr"`
|
|
|
|
|
|
|
|
MailingBaseDN string `json:"mailing_list_base_dn"`
|
|
|
|
MailingNameAttr string `json:"mailing_list_name_attr"`
|
|
|
|
MailingGuestsBaseDN string `json:"mailing_list_guest_user_base_dn"`
|
|
|
|
|
|
|
|
InvitationBaseDN string `json:"invitation_base_dn"`
|
|
|
|
InvitationNameAttr string `json:"invitation_name_attr"`
|
|
|
|
InvitedMailFormat string `json:"invited_mail_format"`
|
|
|
|
InvitedAutoGroups []string `json:"invited_auto_groups"`
|
|
|
|
|
|
|
|
WebAddress string `json:"web_address"`
|
|
|
|
MailFrom string `json:"mail_from"`
|
|
|
|
SMTPServer string `json:"smtp_server"`
|
|
|
|
SMTPUsername string `json:"smtp_username"`
|
|
|
|
SMTPPassword string `json:"smtp_password"`
|
|
|
|
|
|
|
|
AdminAccount string `json:"admin_account"`
|
|
|
|
GroupCanInvite string `json:"group_can_invite"`
|
|
|
|
GroupCanAdmin string `json:"group_can_admin"`
|
|
|
|
|
|
|
|
S3AdminEndpoint string `json:"s3_admin_endpoint"`
|
|
|
|
S3AdminToken string `json:"s3_admin_token"`
|
|
|
|
|
|
|
|
S3Endpoint string `json:"s3_endpoint"`
|
|
|
|
S3AccessKey string `json:"s3_access_key"`
|
|
|
|
S3SecretKey string `json:"s3_secret_key"`
|
|
|
|
S3Region string `json:"s3_region"`
|
|
|
|
S3Bucket string `json:"s3_bucket"`
|
|
|
|
|
|
|
|
Org string `json:"org"`
|
|
|
|
DomainName string `json:"domain_name"`
|
|
|
|
NewUserDN string `json:"new_user_dn"`
|
|
|
|
NewUserPassword string `json:"new_user_password"`
|
2023-07-26 12:29:17 +00:00
|
|
|
NewUsersBaseDN string `json:"new_users_base_dn"`
|
2023-07-25 19:37:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var staticPath = "./static"
|
|
|
|
|
|
|
|
/*
|
|
|
|
Create the different routes
|
|
|
|
*/
|
|
|
|
func makeGVRouter() (*mux.Router, error) {
|
|
|
|
r := mux.NewRouter()
|
|
|
|
r.HandleFunc("/", handleHome)
|
|
|
|
|
2023-07-26 06:31:25 +00:00
|
|
|
r.HandleFunc("/session/logout", handleLogout)
|
|
|
|
|
2023-07-26 07:00:42 +00:00
|
|
|
r.HandleFunc("/user", handleUser)
|
2023-07-26 06:31:25 +00:00
|
|
|
r.HandleFunc("/user/new", handleInviteNewAccount)
|
2023-07-26 09:05:47 +00:00
|
|
|
r.HandleFunc("/user/wait", handleUserWait)
|
2023-07-26 06:31:25 +00:00
|
|
|
|
2023-07-25 19:37:46 +00:00
|
|
|
r.HandleFunc("/picture/{name}", handleDownloadPicture)
|
|
|
|
|
2023-07-26 06:31:25 +00:00
|
|
|
r.HandleFunc("/passwd", handlePasswd)
|
|
|
|
r.HandleFunc("/passwd/lost", handleLostPassword)
|
|
|
|
r.HandleFunc("/passwd/lost/{code}", handleFoundPassword)
|
|
|
|
|
|
|
|
r.HandleFunc("/admin", handleHome)
|
|
|
|
r.HandleFunc("/admin/activate", handleAdminActivateUsers)
|
|
|
|
r.HandleFunc("/admin/unactivate/{cn}", handleAdminUnactivateUser)
|
|
|
|
r.HandleFunc("/admin/activate/{cn}", handleAdminActivateUser)
|
|
|
|
r.HandleFunc("/admin/users", handleAdminUsers)
|
|
|
|
r.HandleFunc("/admin/groups", handleAdminGroups)
|
|
|
|
r.HandleFunc("/admin/ldap/{dn}", handleAdminLDAP)
|
|
|
|
r.HandleFunc("/admin/create/{template}/{super_dn}", handleAdminCreate)
|
2023-07-25 19:37:46 +00:00
|
|
|
|
|
|
|
// r.HandleFunc("/directory/search", handleDirectorySearch)
|
|
|
|
// r.HandleFunc("/directory", handleDirectory)
|
|
|
|
// r.HandleFunc("/garage/key", handleGarageKey)
|
|
|
|
// r.HandleFunc("/garage/website", handleGarageWebsiteList)
|
|
|
|
// r.HandleFunc("/garage/website/new", handleGarageWebsiteNew)
|
|
|
|
// r.HandleFunc("/garage/website/b/{bucket}", handleGarageWebsiteInspect)
|
|
|
|
|
2023-07-26 06:31:25 +00:00
|
|
|
// r.HandleFunc("/user/send_code", handleInviteSendCode)
|
|
|
|
|
2023-07-25 19:37:46 +00:00
|
|
|
// r.HandleFunc("/invitation/{code}", handleInvitationCode)
|
|
|
|
|
2023-07-25 20:00:07 +00:00
|
|
|
// r.HandleFunc("/admin-mailing", handleAdminMailing)
|
2023-07-25 19:37:46 +00:00
|
|
|
// r.HandleFunc("/admin/mailing/{id}", handleAdminMailingList)
|
|
|
|
|
|
|
|
staticFiles := http.FileServer(http.Dir(staticPath))
|
|
|
|
r.Handle("/static/{file:.*}", http.StripPrefix("/static/", staticFiles))
|
|
|
|
|
|
|
|
// log.Printf("Starting HTTP server on %s", config.HttpBindAddr)
|
|
|
|
err := http.ListenAndServe(config.HttpBindAddr, logRequest(r))
|
|
|
|
|
|
|
|
return r, err
|
|
|
|
}
|