1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-24 15:49:44 +02:00
This commit is contained in:
Harvey Kandola 2017-03-14 17:19:53 +00:00
parent 0b51608383
commit 9d1af37f6e
22 changed files with 2215 additions and 647 deletions

View file

@ -176,3 +176,60 @@ type licenseJSON struct {
<Signature>some signature</Signature>
</DocumizeLicense>
*/
// SaveAuthConfig returns installation-wide authentication configuration
func SaveAuthConfig(w http.ResponseWriter, r *http.Request) {
method := "SaveAuthConfig"
p := request.GetPersister(r)
if !p.Context.Global {
writeForbiddenError(w)
return
}
defer r.Body.Close()
body, err := ioutil.ReadAll(r.Body)
if err != nil {
writePayloadError(w, method, err)
return
}
var data authData
err = json.Unmarshal(body, &data)
if err != nil {
writePayloadError(w, method, err)
return
}
org, err := p.GetOrganization(p.Context.OrgID)
if err != nil {
util.WriteGeneralSQLError(w, method, err)
return
}
org.AuthProvider = data.AuthProvider
org.AuthConfig = data.AuthConfig
p.Context.Transaction, err = request.Db.Beginx()
if err != nil {
writeTransactionError(w, method, err)
return
}
err = p.UpdateAuthConfig(org)
if err != nil {
util.WriteGeneralSQLError(w, method, err)
p.Context.Transaction.Rollback()
return
}
p.Context.Transaction.Commit()
util.WriteSuccessEmptyJSON(w)
}
type authData struct {
AuthProvider string `json:"authProvider"`
AuthConfig string `json:"authConfig"`
}

View file

@ -33,7 +33,6 @@ func GetMeta(w http.ResponseWriter, r *http.Request) {
data.URL = request.GetSubdomainFromHost(r)
org, err := p.GetOrganizationByDomain(data.URL)
if err != nil {
log.Info(fmt.Sprintf("%s URL not found", data.URL))
writeForbiddenError(w)
@ -44,12 +43,13 @@ func GetMeta(w http.ResponseWriter, r *http.Request) {
data.Title = org.Title
data.Message = org.Message
data.AllowAnonymousAccess = org.AllowAnonymousAccess
data.AuthProvider = org.AuthProvider
data.AuthConfig = org.AuthConfig
data.Version = Product.Version
data.Edition = Product.License.Edition
data.Valid = Product.License.Valid
json, err := json.Marshal(data)
if err != nil {
writeJSONMarshalError(w, method, "meta", err)
return

View file

@ -233,6 +233,7 @@ func init() {
log.IfErr(Add(RoutePrefixPrivate, "global/smtp", []string{"PUT", "OPTIONS"}, nil, SaveSMTPConfig))
log.IfErr(Add(RoutePrefixPrivate, "global/license", []string{"GET", "OPTIONS"}, nil, GetLicense))
log.IfErr(Add(RoutePrefixPrivate, "global/license", []string{"PUT", "OPTIONS"}, nil, SaveLicense))
log.IfErr(Add(RoutePrefixPrivate, "global/auth", []string{"PUT", "OPTIONS"}, nil, SaveAuthConfig))
// Pinned items
log.IfErr(Add(RoutePrefixPrivate, "pin/{userID}", []string{"POST", "OPTIONS"}, nil, AddPin))

View file

@ -34,8 +34,8 @@ var Product core.ProdInfo
func init() {
Product.Major = "0"
Product.Minor = "43"
Product.Patch = "1"
Product.Minor = "44"
Product.Patch = "0"
Product.Version = fmt.Sprintf("%s.%s.%s", Product.Major, Product.Minor, Product.Patch)
Product.Edition = "Community"
Product.Title = fmt.Sprintf("%s Edition", Product.Edition)