An API for Guichet #23
1 changed files with 13 additions and 4 deletions
17
main.go
17
main.go
|
@ -198,6 +198,9 @@ func logRequest(handler http.Handler) http.Handler {
|
||||||
func checkLogin(w http.ResponseWriter, r *http.Request) *LoginStatus {
|
func checkLogin(w http.ResponseWriter, r *http.Request) *LoginStatus {
|
||||||
var login_info *LoginInfo
|
var login_info *LoginInfo
|
||||||
|
|
||||||
|
//@FIXME check authentication header
|
||||||
|
|
||||||
|
|
||||||
session, err := store.Get(r, SESSION_NAME)
|
session, err := store.Get(r, SESSION_NAME)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
username, ok := session.Values["login_username"]
|
username, ok := session.Values["login_username"]
|
||||||
|
@ -364,6 +367,15 @@ type LoginFormData struct {
|
||||||
ErrorMessage string
|
ErrorMessage string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func buildUserDN(username string) string {
|
||||||
|
user_dn := fmt.Sprintf("%s=%s,%s", config.UserNameAttr, username, config.UserBaseDN)
|
||||||
|
if strings.EqualFold(username, config.AdminAccount) {
|
||||||
|
user_dn = username
|
||||||
|
}
|
||||||
|
|
||||||
|
return user_dn
|
||||||
|
}
|
||||||
|
|
||||||
func handleLogin(w http.ResponseWriter, r *http.Request) *LoginInfo {
|
func handleLogin(w http.ResponseWriter, r *http.Request) *LoginInfo {
|
||||||
templateLogin := getTemplate("login.html")
|
templateLogin := getTemplate("login.html")
|
||||||
|
|
||||||
|
@ -375,10 +387,7 @@ func handleLogin(w http.ResponseWriter, r *http.Request) *LoginInfo {
|
||||||
|
|
||||||
username := strings.Join(r.Form["username"], "")
|
username := strings.Join(r.Form["username"], "")
|
||||||
password := strings.Join(r.Form["password"], "")
|
password := strings.Join(r.Form["password"], "")
|
||||||
user_dn := fmt.Sprintf("%s=%s,%s", config.UserNameAttr, username, config.UserBaseDN)
|
user_dn := buildUserDN(username)
|
||||||
if strings.EqualFold(username, config.AdminAccount) {
|
|
||||||
user_dn = username
|
|
||||||
}
|
|
||||||
|
|
||||||
l := ldapOpen(w)
|
l := ldapOpen(w)
|
||||||
if l == nil {
|
if l == nil {
|
||||||
|
|
Loading…
Reference in a new issue