1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-08-04 13:05:23 +02:00

Merge branch 'auth-with-cas' of github.com:dereknex/community into auth-with-cas

This commit is contained in:
Derek Chen 2019-08-16 22:24:51 +08:00
commit 15e687841f
39 changed files with 2462 additions and 1631 deletions

View file

@ -4,6 +4,11 @@ import (
"database/sql"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"strings"
"github.com/documize/community/core/env"
"github.com/documize/community/core/response"
"github.com/documize/community/core/secrets"
@ -16,10 +21,6 @@ import (
ath "github.com/documize/community/model/auth"
"github.com/documize/community/model/user"
casv2 "gopkg.in/cas.v2"
"io/ioutil"
"net/http"
"net/url"
"strings"
)
// Handler contains the runtime information such as logging and database.
@ -28,7 +29,6 @@ type Handler struct {
Store *store.Store
}
// Authenticate checks CAS authentication credentials.
func (h *Handler) Authenticate(w http.ResponseWriter, r *http.Request) {
method := "authenticate"
@ -63,15 +63,15 @@ func (h *Handler) Authenticate(w http.ResponseWriter, r *http.Request) {
ac := ath.CASConfig{}
err = json.Unmarshal([]byte(org.AuthConfig), &ac)
if err != nil {
response.WriteBadRequestError(w, method, "Unable to unmarshall CAS config")
response.WriteBadRequestError(w, method, "Unable to unmarshal CAS configuration")
h.Runtime.Log.Error(method, err)
return
}
service := url.QueryEscape(ac.RedirectURL)
validateUrl := ac.URL + "/serviceValidate?ticket=" + a.Ticket + "&service="+ service;
validateURL := ac.URL + "/serviceValidate?ticket=" + a.Ticket + "&service=" + service
resp, err := http.Get(validateUrl)
resp, err := http.Get(validateURL)
if err != nil {
response.WriteBadRequestError(w, method, "Unable to get service validate url")
h.Runtime.Log.Error(method, err)