Commit 88e5a71e authored by =Corey Hulen's avatar =Corey Hulen

Adding service settings to admin console

parent 08a3acbb
...@@ -35,7 +35,7 @@ func getLogs(c *Context, w http.ResponseWriter, r *http.Request) { ...@@ -35,7 +35,7 @@ func getLogs(c *Context, w http.ResponseWriter, r *http.Request) {
var lines []string var lines []string
if utils.Cfg.LogSettings.FileEnable { if utils.Cfg.LogSettings.EnableFile {
file, err := os.Open(utils.GetLogFileLocation(utils.Cfg.LogSettings.FileLocation)) file, err := os.Open(utils.GetLogFileLocation(utils.Cfg.LogSettings.FileLocation))
if err != nil { if err != nil {
...@@ -82,7 +82,7 @@ func saveConfig(c *Context, w http.ResponseWriter, r *http.Request) { ...@@ -82,7 +82,7 @@ func saveConfig(c *Context, w http.ResponseWriter, r *http.Request) {
return return
} }
if len(cfg.ServiceSettings.Port) == 0 { if len(cfg.ServiceSettings.ListenAddress) == 0 {
c.SetInvalidParam("saveConfig", "config") c.SetInvalidParam("saveConfig", "config")
return return
} }
......
...@@ -18,7 +18,7 @@ func Setup() { ...@@ -18,7 +18,7 @@ func Setup() {
NewServer() NewServer()
StartServer() StartServer()
InitApi() InitApi()
Client = model.NewClient("http://localhost:" + utils.Cfg.ServiceSettings.Port) Client = model.NewClient("http://localhost" + utils.Cfg.ServiceSettings.ListenAddress)
} }
} }
......
...@@ -627,7 +627,7 @@ func TestGetChannelExtraInfo(t *testing.T) { ...@@ -627,7 +627,7 @@ func TestGetChannelExtraInfo(t *testing.T) {
currentEtag = cache_result.Etag currentEtag = cache_result.Etag
} }
Client2 := model.NewClient("http://localhost:" + utils.Cfg.ServiceSettings.Port) Client2 := model.NewClient("http://localhost" + utils.Cfg.ServiceSettings.ListenAddress)
user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "tester2@test.com", Nickname: "Tester 2", Password: "pwd"} user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "tester2@test.com", Nickname: "Tester 2", Password: "pwd"}
user2 = Client2.Must(Client2.CreateUser(user2, "")).Data.(*model.User) user2 = Client2.Must(Client2.CreateUser(user2, "")).Data.(*model.User)
......
...@@ -215,8 +215,8 @@ func joinCommand(c *Context, command *model.Command) bool { ...@@ -215,8 +215,8 @@ func joinCommand(c *Context, command *model.Command) bool {
func loadTestCommand(c *Context, command *model.Command) bool { func loadTestCommand(c *Context, command *model.Command) bool {
cmd := "/loadtest" cmd := "/loadtest"
// This command is only available when AllowTesting is true // This command is only available when EnableTesting is true
if !utils.Cfg.ServiceSettings.AllowTesting { if !utils.Cfg.ServiceSettings.EnableTesting {
return false return false
} }
......
...@@ -107,21 +107,7 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { ...@@ -107,21 +107,7 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
isTokenFromQueryString = true isTokenFromQueryString = true
} }
protocol := "http" protocol := GetProtocol(r)
// If the request came from the ELB then assume this is produciton
// and redirect all http requests to https
if utils.Cfg.ServiceSettings.UseSSL {
forwardProto := r.Header.Get(model.HEADER_FORWARDED_PROTO)
if forwardProto == "http" {
l4g.Info("redirecting http request to https for %v", r.URL.Path)
http.Redirect(w, r, "https://"+r.Host, http.StatusTemporaryRedirect)
return
} else {
protocol = "https"
}
}
c.setSiteURL(protocol + "://" + r.Host) c.setSiteURL(protocol + "://" + r.Host)
w.Header().Set(model.HEADER_REQUEST_ID, c.RequestId) w.Header().Set(model.HEADER_REQUEST_ID, c.RequestId)
...@@ -209,6 +195,14 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { ...@@ -209,6 +195,14 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
} }
} }
func GetProtocol(r *http.Request) string {
if r.Header.Get(model.HEADER_FORWARDED_PROTO) == "https" {
return "https"
} else {
return "http"
}
}
func (c *Context) LogAudit(extraInfo string) { func (c *Context) LogAudit(extraInfo string) {
audit := &model.Audit{UserId: c.Session.UserId, IpAddress: c.IpAddress, Action: c.Path, ExtraInfo: extraInfo, SessionId: c.Session.Id} audit := &model.Audit{UserId: c.Session.UserId, IpAddress: c.IpAddress, Action: c.Path, ExtraInfo: extraInfo, SessionId: c.Session.Id}
if r := <-Srv.Store.Audit().Save(audit); r.Err != nil { if r := <-Srv.Store.Audit().Save(audit); r.Err != nil {
...@@ -385,6 +379,11 @@ func (c *Context) GetSiteURL() string { ...@@ -385,6 +379,11 @@ func (c *Context) GetSiteURL() string {
func GetIpAddress(r *http.Request) string { func GetIpAddress(r *http.Request) string {
address := r.Header.Get(model.HEADER_FORWARDED) address := r.Header.Get(model.HEADER_FORWARDED)
if len(address) == 0 {
address = r.Header.Get(model.HEADER_REAL_IP)
}
if len(address) == 0 { if len(address) == 0 {
address, _, _ = net.SplitHostPort(r.RemoteAddr) address, _, _ = net.SplitHostPort(r.RemoteAddr)
} }
...@@ -458,14 +457,7 @@ func IsPrivateIpAddress(ipAddress string) bool { ...@@ -458,14 +457,7 @@ func IsPrivateIpAddress(ipAddress string) bool {
func RenderWebError(err *model.AppError, w http.ResponseWriter, r *http.Request) { func RenderWebError(err *model.AppError, w http.ResponseWriter, r *http.Request) {
protocol := "http" protocol := GetProtocol(r)
if utils.Cfg.ServiceSettings.UseSSL {
forwardProto := r.Header.Get(model.HEADER_FORWARDED_PROTO)
if forwardProto != "http" {
protocol = "https"
}
}
SiteURL := protocol + "://" + r.Host SiteURL := protocol + "://" + r.Host
m := make(map[string]string) m := make(map[string]string)
......
...@@ -399,7 +399,7 @@ func getFile(c *Context, w http.ResponseWriter, r *http.Request) { ...@@ -399,7 +399,7 @@ func getFile(c *Context, w http.ResponseWriter, r *http.Request) {
asyncGetFile(path, fileData) asyncGetFile(path, fileData)
if len(hash) > 0 && len(data) > 0 && len(teamId) == 26 { if len(hash) > 0 && len(data) > 0 && len(teamId) == 26 {
if !model.ComparePassword(hash, fmt.Sprintf("%v:%v", data, utils.Cfg.ServiceSettings.PublicLinkSalt)) { if !model.ComparePassword(hash, fmt.Sprintf("%v:%v", data, utils.Cfg.ImageSettings.PublicLinkSalt)) {
c.Err = model.NewAppError("getFile", "The public link does not appear to be valid", "") c.Err = model.NewAppError("getFile", "The public link does not appear to be valid", "")
return return
} }
...@@ -477,7 +477,7 @@ func getPublicLink(c *Context, w http.ResponseWriter, r *http.Request) { ...@@ -477,7 +477,7 @@ func getPublicLink(c *Context, w http.ResponseWriter, r *http.Request) {
newProps["time"] = fmt.Sprintf("%v", model.GetMillis()) newProps["time"] = fmt.Sprintf("%v", model.GetMillis())
data := model.MapToJson(newProps) data := model.MapToJson(newProps)
hash := model.HashPassword(fmt.Sprintf("%v:%v", data, utils.Cfg.ServiceSettings.PublicLinkSalt)) hash := model.HashPassword(fmt.Sprintf("%v:%v", data, utils.Cfg.ImageSettings.PublicLinkSalt))
url := fmt.Sprintf("%s/api/v1/files/get/%s/%s/%s?d=%s&h=%s&t=%s", c.GetSiteURL(), channelId, userId, filename, url.QueryEscape(data), url.QueryEscape(hash), c.Session.TeamId) url := fmt.Sprintf("%s/api/v1/files/get/%s/%s/%s?d=%s&h=%s&t=%s", c.GetSiteURL(), channelId, userId, filename, url.QueryEscape(data), url.QueryEscape(hash), c.Session.TeamId)
......
...@@ -38,7 +38,7 @@ func BenchmarkGetFile(b *testing.B) { ...@@ -38,7 +38,7 @@ func BenchmarkGetFile(b *testing.B) {
newProps["time"] = fmt.Sprintf("%v", model.GetMillis()) newProps["time"] = fmt.Sprintf("%v", model.GetMillis())
data := model.MapToJson(newProps) data := model.MapToJson(newProps)
hash := model.HashPassword(fmt.Sprintf("%v:%v", data, utils.Cfg.ServiceSettings.PublicLinkSalt)) hash := model.HashPassword(fmt.Sprintf("%v:%v", data, utils.Cfg.ImageSettings.PublicLinkSalt))
// wait a bit for files to ready // wait a bit for files to ready
time.Sleep(5 * time.Second) time.Sleep(5 * time.Second)
......
...@@ -222,7 +222,7 @@ func TestGetFile(t *testing.T) { ...@@ -222,7 +222,7 @@ func TestGetFile(t *testing.T) {
newProps["time"] = fmt.Sprintf("%v", model.GetMillis()) newProps["time"] = fmt.Sprintf("%v", model.GetMillis())
data := model.MapToJson(newProps) data := model.MapToJson(newProps)
hash := model.HashPassword(fmt.Sprintf("%v:%v", data, utils.Cfg.ServiceSettings.PublicLinkSalt)) hash := model.HashPassword(fmt.Sprintf("%v:%v", data, utils.Cfg.ImageSettings.PublicLinkSalt))
Client.LoginByEmail(team2.Name, user2.Email, "pwd") Client.LoginByEmail(team2.Name, user2.Email, "pwd")
......
...@@ -38,7 +38,7 @@ func NewServer() { ...@@ -38,7 +38,7 @@ func NewServer() {
func StartServer() { func StartServer() {
l4g.Info("Starting Server...") l4g.Info("Starting Server...")
l4g.Info("Server is listening on " + utils.Cfg.ServiceSettings.Port) l4g.Info("Server is listening on " + utils.Cfg.ServiceSettings.ListenAddress)
var handler http.Handler = Srv.Router var handler http.Handler = Srv.Router
...@@ -71,7 +71,7 @@ func StartServer() { ...@@ -71,7 +71,7 @@ func StartServer() {
} }
go func() { go func() {
err := Srv.Server.ListenAndServe(":"+utils.Cfg.ServiceSettings.Port, handler) err := Srv.Server.ListenAndServe(utils.Cfg.ServiceSettings.ListenAddress, handler)
if err != nil { if err != nil {
l4g.Critical("Error starting server, err:%v", err) l4g.Critical("Error starting server, err:%v", err)
time.Sleep(time.Second) time.Sleep(time.Second)
......
...@@ -38,7 +38,7 @@ func InitTeam(r *mux.Router) { ...@@ -38,7 +38,7 @@ func InitTeam(r *mux.Router) {
} }
func signupTeam(c *Context, w http.ResponseWriter, r *http.Request) { func signupTeam(c *Context, w http.ResponseWriter, r *http.Request) {
if !utils.Cfg.EmailSettings.AllowSignUpWithEmail { if !utils.Cfg.EmailSettings.EnableSignUpWithEmail {
c.Err = model.NewAppError("signupTeam", "Team sign-up with email is disabled.", "") c.Err = model.NewAppError("signupTeam", "Team sign-up with email is disabled.", "")
c.Err.StatusCode = http.StatusNotImplemented c.Err.StatusCode = http.StatusNotImplemented
return return
...@@ -66,7 +66,7 @@ func signupTeam(c *Context, w http.ResponseWriter, r *http.Request) { ...@@ -66,7 +66,7 @@ func signupTeam(c *Context, w http.ResponseWriter, r *http.Request) {
props["time"] = fmt.Sprintf("%v", model.GetMillis()) props["time"] = fmt.Sprintf("%v", model.GetMillis())
data := model.MapToJson(props) data := model.MapToJson(props)
hash := model.HashPassword(fmt.Sprintf("%v:%v", data, utils.Cfg.ServiceSettings.InviteSalt)) hash := model.HashPassword(fmt.Sprintf("%v:%v", data, utils.Cfg.EmailSettings.InviteSalt))
bodyPage.Props["Link"] = fmt.Sprintf("%s/signup_team_complete/?d=%s&h=%s", c.GetSiteURL(), url.QueryEscape(data), url.QueryEscape(hash)) bodyPage.Props["Link"] = fmt.Sprintf("%s/signup_team_complete/?d=%s&h=%s", c.GetSiteURL(), url.QueryEscape(data), url.QueryEscape(hash))
...@@ -85,7 +85,7 @@ func createTeamFromSSO(c *Context, w http.ResponseWriter, r *http.Request) { ...@@ -85,7 +85,7 @@ func createTeamFromSSO(c *Context, w http.ResponseWriter, r *http.Request) {
service := params["service"] service := params["service"]
sso := utils.Cfg.GetSSOService(service) sso := utils.Cfg.GetSSOService(service)
if sso != nil && !sso.Allow { if sso != nil && !sso.Enable {
c.SetInvalidParam("createTeamFromSSO", "service") c.SetInvalidParam("createTeamFromSSO", "service")
return return
} }
...@@ -142,7 +142,7 @@ func createTeamFromSSO(c *Context, w http.ResponseWriter, r *http.Request) { ...@@ -142,7 +142,7 @@ func createTeamFromSSO(c *Context, w http.ResponseWriter, r *http.Request) {
} }
func createTeamFromSignup(c *Context, w http.ResponseWriter, r *http.Request) { func createTeamFromSignup(c *Context, w http.ResponseWriter, r *http.Request) {
if !utils.Cfg.EmailSettings.AllowSignUpWithEmail { if !utils.Cfg.EmailSettings.EnableSignUpWithEmail {
c.Err = model.NewAppError("createTeamFromSignup", "Team sign-up with email is disabled.", "") c.Err = model.NewAppError("createTeamFromSignup", "Team sign-up with email is disabled.", "")
c.Err.StatusCode = http.StatusNotImplemented c.Err.StatusCode = http.StatusNotImplemented
return return
...@@ -183,7 +183,7 @@ func createTeamFromSignup(c *Context, w http.ResponseWriter, r *http.Request) { ...@@ -183,7 +183,7 @@ func createTeamFromSignup(c *Context, w http.ResponseWriter, r *http.Request) {
teamSignup.User.TeamId = "" teamSignup.User.TeamId = ""
teamSignup.User.Password = password teamSignup.User.Password = password
if !model.ComparePassword(teamSignup.Hash, fmt.Sprintf("%v:%v", teamSignup.Data, utils.Cfg.ServiceSettings.InviteSalt)) { if !model.ComparePassword(teamSignup.Hash, fmt.Sprintf("%v:%v", teamSignup.Data, utils.Cfg.EmailSettings.InviteSalt)) {
c.Err = model.NewAppError("createTeamFromSignup", "The signup link does not appear to be valid", "") c.Err = model.NewAppError("createTeamFromSignup", "The signup link does not appear to be valid", "")
return return
} }
...@@ -243,7 +243,7 @@ func createTeam(c *Context, w http.ResponseWriter, r *http.Request) { ...@@ -243,7 +243,7 @@ func createTeam(c *Context, w http.ResponseWriter, r *http.Request) {
} }
func CreateTeam(c *Context, team *model.Team) *model.Team { func CreateTeam(c *Context, team *model.Team) *model.Team {
if !utils.Cfg.EmailSettings.AllowSignUpWithEmail { if !utils.Cfg.EmailSettings.EnableSignUpWithEmail {
c.Err = model.NewAppError("createTeam", "Team sign-up with email is disabled.", "") c.Err = model.NewAppError("createTeam", "Team sign-up with email is disabled.", "")
c.Err.StatusCode = http.StatusNotImplemented c.Err.StatusCode = http.StatusNotImplemented
return nil return nil
...@@ -258,11 +258,6 @@ func CreateTeam(c *Context, team *model.Team) *model.Team { ...@@ -258,11 +258,6 @@ func CreateTeam(c *Context, team *model.Team) *model.Team {
return nil return nil
} }
if utils.Cfg.ServiceSettings.Mode != utils.MODE_DEV {
c.Err = model.NewAppError("CreateTeam", "The mode does not allow network creation without a valid invite", "")
return nil
}
if result := <-Srv.Store.Team().Save(team); result.Err != nil { if result := <-Srv.Store.Team().Save(team); result.Err != nil {
c.Err = result.Err c.Err = result.Err
return nil return nil
...@@ -488,10 +483,10 @@ func InviteMembers(c *Context, team *model.Team, user *model.User, invites []str ...@@ -488,10 +483,10 @@ func InviteMembers(c *Context, team *model.Team, user *model.User, invites []str
props["name"] = team.Name props["name"] = team.Name
props["time"] = fmt.Sprintf("%v", model.GetMillis()) props["time"] = fmt.Sprintf("%v", model.GetMillis())
data := model.MapToJson(props) data := model.MapToJson(props)
hash := model.HashPassword(fmt.Sprintf("%v:%v", data, utils.Cfg.ServiceSettings.InviteSalt)) hash := model.HashPassword(fmt.Sprintf("%v:%v", data, utils.Cfg.EmailSettings.InviteSalt))
bodyPage.Props["Link"] = fmt.Sprintf("%s/signup_user_complete/?d=%s&h=%s", c.GetSiteURL(), url.QueryEscape(data), url.QueryEscape(hash)) bodyPage.Props["Link"] = fmt.Sprintf("%s/signup_user_complete/?d=%s&h=%s", c.GetSiteURL(), url.QueryEscape(data), url.QueryEscape(hash))
if utils.Cfg.ServiceSettings.Mode == utils.MODE_DEV { if !utils.Cfg.EmailSettings.SendEmailNotifications {
l4g.Info("sending invitation to %v %v", invite, bodyPage.Props["Link"]) l4g.Info("sending invitation to %v %v", invite, bodyPage.Props["Link"])
} }
......
...@@ -30,7 +30,7 @@ func TestCreateFromSignupTeam(t *testing.T) { ...@@ -30,7 +30,7 @@ func TestCreateFromSignupTeam(t *testing.T) {
props["time"] = fmt.Sprintf("%v", model.GetMillis()) props["time"] = fmt.Sprintf("%v", model.GetMillis())
data := model.MapToJson(props) data := model.MapToJson(props)
hash := model.HashPassword(fmt.Sprintf("%v:%v", data, utils.Cfg.ServiceSettings.InviteSalt)) hash := model.HashPassword(fmt.Sprintf("%v:%v", data, utils.Cfg.EmailSettings.InviteSalt))
team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
user := model.User{Email: props["email"], Nickname: "Corey Hulen", Password: "hello"} user := model.User{Email: props["email"], Nickname: "Corey Hulen", Password: "hello"}
......
...@@ -58,7 +58,7 @@ func InitUser(r *mux.Router) { ...@@ -58,7 +58,7 @@ func InitUser(r *mux.Router) {
} }
func createUser(c *Context, w http.ResponseWriter, r *http.Request) { func createUser(c *Context, w http.ResponseWriter, r *http.Request) {
if !utils.Cfg.EmailSettings.AllowSignUpWithEmail { if !utils.Cfg.EmailSettings.EnableSignUpWithEmail {
c.Err = model.NewAppError("signupTeam", "User sign-up with email is disabled.", "") c.Err = model.NewAppError("signupTeam", "User sign-up with email is disabled.", "")
c.Err.StatusCode = http.StatusNotImplemented c.Err.StatusCode = http.StatusNotImplemented
return return
...@@ -90,7 +90,7 @@ func createUser(c *Context, w http.ResponseWriter, r *http.Request) { ...@@ -90,7 +90,7 @@ func createUser(c *Context, w http.ResponseWriter, r *http.Request) {
data := r.URL.Query().Get("d") data := r.URL.Query().Get("d")
props := model.MapFromJson(strings.NewReader(data)) props := model.MapFromJson(strings.NewReader(data))
if !model.ComparePassword(hash, fmt.Sprintf("%v:%v", data, utils.Cfg.ServiceSettings.InviteSalt)) { if !model.ComparePassword(hash, fmt.Sprintf("%v:%v", data, utils.Cfg.EmailSettings.InviteSalt)) {
c.Err = model.NewAppError("createUser", "The signup link does not appear to be valid", "") c.Err = model.NewAppError("createUser", "The signup link does not appear to be valid", "")
return return
} }
...@@ -287,7 +287,7 @@ func LoginByEmail(c *Context, w http.ResponseWriter, r *http.Request, email, nam ...@@ -287,7 +287,7 @@ func LoginByEmail(c *Context, w http.ResponseWriter, r *http.Request, email, nam
func checkUserPassword(c *Context, user *model.User, password string) bool { func checkUserPassword(c *Context, user *model.User, password string) bool {
if user.FailedAttempts >= utils.Cfg.ServiceSettings.AllowedLoginAttempts { if user.FailedAttempts >= utils.Cfg.ServiceSettings.MaximumLoginAttempts {
c.LogAuditWithUserId(user.Id, "fail") c.LogAuditWithUserId(user.Id, "fail")
c.Err = model.NewAppError("checkUserPassword", "Your account is locked because of too many failed password attempts. Please reset your password.", "user_id="+user.Id) c.Err = model.NewAppError("checkUserPassword", "Your account is locked because of too many failed password attempts. Please reset your password.", "user_id="+user.Id)
c.Err.StatusCode = http.StatusForbidden c.Err.StatusCode = http.StatusForbidden
...@@ -1129,7 +1129,7 @@ func sendPasswordReset(c *Context, w http.ResponseWriter, r *http.Request) { ...@@ -1129,7 +1129,7 @@ func sendPasswordReset(c *Context, w http.ResponseWriter, r *http.Request) {
newProps["time"] = fmt.Sprintf("%v", model.GetMillis()) newProps["time"] = fmt.Sprintf("%v", model.GetMillis())
data := model.MapToJson(newProps) data := model.MapToJson(newProps)
hash := model.HashPassword(fmt.Sprintf("%v:%v", data, utils.Cfg.ServiceSettings.ResetSalt)) hash := model.HashPassword(fmt.Sprintf("%v:%v", data, utils.Cfg.EmailSettings.PasswordResetSalt))
link := fmt.Sprintf("%s/reset_password?d=%s&h=%s", c.GetTeamURLFromTeam(team), url.QueryEscape(data), url.QueryEscape(hash)) link := fmt.Sprintf("%s/reset_password?d=%s&h=%s", c.GetTeamURLFromTeam(team), url.QueryEscape(data), url.QueryEscape(hash))
...@@ -1208,7 +1208,7 @@ func resetPassword(c *Context, w http.ResponseWriter, r *http.Request) { ...@@ -1208,7 +1208,7 @@ func resetPassword(c *Context, w http.ResponseWriter, r *http.Request) {
return return
} }
if !model.ComparePassword(hash, fmt.Sprintf("%v:%v", props["data"], utils.Cfg.ServiceSettings.ResetSalt)) { if !model.ComparePassword(hash, fmt.Sprintf("%v:%v", props["data"], utils.Cfg.EmailSettings.PasswordResetSalt)) {
c.Err = model.NewAppError("resetPassword", "The reset password link does not appear to be valid", "") c.Err = model.NewAppError("resetPassword", "The reset password link does not appear to be valid", "")
return return
} }
...@@ -1357,7 +1357,7 @@ func getStatuses(c *Context, w http.ResponseWriter, r *http.Request) { ...@@ -1357,7 +1357,7 @@ func getStatuses(c *Context, w http.ResponseWriter, r *http.Request) {
func GetAuthorizationCode(c *Context, w http.ResponseWriter, r *http.Request, teamName, service, redirectUri, loginHint string) { func GetAuthorizationCode(c *Context, w http.ResponseWriter, r *http.Request, teamName, service, redirectUri, loginHint string) {
sso := utils.Cfg.GetSSOService(service) sso := utils.Cfg.GetSSOService(service)
if sso != nil && !sso.Allow { if sso != nil && !sso.Enable {
c.Err = model.NewAppError("GetAuthorizationCode", "Unsupported OAuth service provider", "service="+service) c.Err = model.NewAppError("GetAuthorizationCode", "Unsupported OAuth service provider", "service="+service)
c.Err.StatusCode = http.StatusBadRequest c.Err.StatusCode = http.StatusBadRequest
return return
...@@ -1385,7 +1385,7 @@ func GetAuthorizationCode(c *Context, w http.ResponseWriter, r *http.Request, te ...@@ -1385,7 +1385,7 @@ func GetAuthorizationCode(c *Context, w http.ResponseWriter, r *http.Request, te
func AuthorizeOAuthUser(service, code, state, redirectUri string) (io.ReadCloser, *model.Team, *model.AppError) { func AuthorizeOAuthUser(service, code, state, redirectUri string) (io.ReadCloser, *model.Team, *model.AppError) {
sso := utils.Cfg.GetSSOService(service) sso := utils.Cfg.GetSSOService(service)
if sso != nil && !sso.Allow { if sso != nil && !sso.Enable {
return nil, nil, model.NewAppError("AuthorizeOAuthUser", "Unsupported OAuth service provider", "service="+service) return nil, nil, model.NewAppError("AuthorizeOAuthUser", "Unsupported OAuth service provider", "service="+service)
} }
......
...@@ -151,7 +151,7 @@ func TestLogin(t *testing.T) { ...@@ -151,7 +151,7 @@ func TestLogin(t *testing.T) {
props["display_name"] = rteam2.Data.(*model.Team).DisplayName props["display_name"] = rteam2.Data.(*model.Team).DisplayName
props["time"] = fmt.Sprintf("%v", model.GetMillis()) props["time"] = fmt.Sprintf("%v", model.GetMillis())
data := model.MapToJson(props) data := model.MapToJson(props)
hash := model.HashPassword(fmt.Sprintf("%v:%v", data, utils.Cfg.ServiceSettings.InviteSalt)) hash := model.HashPassword(fmt.Sprintf("%v:%v", data, utils.Cfg.EmailSettings.InviteSalt))
ruser2, _ := Client.CreateUserFromSignup(&user2, data, hash) ruser2, _ := Client.CreateUserFromSignup(&user2, data, hash)
...@@ -814,7 +814,7 @@ func TestResetPassword(t *testing.T) { ...@@ -814,7 +814,7 @@ func TestResetPassword(t *testing.T) {
props["user_id"] = user.Id props["user_id"] = user.Id
props["time"] = fmt.Sprintf("%v", model.GetMillis()) props["time"] = fmt.Sprintf("%v", model.GetMillis())
data["data"] = model.MapToJson(props) data["data"] = model.MapToJson(props)
data["hash"] = model.HashPassword(fmt.Sprintf("%v:%v", data["data"], utils.Cfg.ServiceSettings.ResetSalt)) data["hash"] = model.HashPassword(fmt.Sprintf("%v:%v", data["data"], utils.Cfg.EmailSettings.PasswordResetSalt))
data["name"] = team.Name data["name"] = team.Name
if _, err := Client.ResetPassword(data); err != nil { if _, err := Client.ResetPassword(data); err != nil {
......
...@@ -16,7 +16,7 @@ import ( ...@@ -16,7 +16,7 @@ import (
func TestSocket(t *testing.T) { func TestSocket(t *testing.T) {
Setup() Setup()
url := "ws://localhost:" + utils.Cfg.ServiceSettings.Port + "/api/v1/websocket" url := "ws://localhost" + utils.Cfg.ServiceSettings.ListenAddress + "/api/v1/websocket"
team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team)
......
{ {
"ServiceSettings": { "ServiceSettings": {
"Mode": "dev", "ListenAddress": ":8065",
"AllowTesting": false, "MaximumLoginAttempts": 10,
"UseSSL": false,
"Port": "8065",
"Version": "developer",
"InviteSalt": "gxHVDcKUyP2y1eiyW8S8na1UYQAfq6J6",
"PublicLinkSalt": "TO3pTyXIZzwHiwyZgGql7lM7DG3zeId4",
"ResetSalt": "IPxFzSfnDFsNsRafZxz8NaYqFKhf9y2t",
"AnalyticsUrl": "",
"AllowedLoginAttempts": 10,
"EnableOAuthServiceProvider": false,
"SegmentDeveloperKey": "", "SegmentDeveloperKey": "",
"GoogleDeveloperKey": "" "GoogleDeveloperKey": "",
"EnableOAuthServiceProvider": false,
"EnableTesting": false
}, },
"TeamSettings": { "TeamSettings": {
"SiteName": "Mattermost", "SiteName": "Mattermost",
...@@ -32,9 +25,9 @@ ...@@ -32,9 +25,9 @@
"AtRestEncryptKey": "7rAh6iwQCkV4cA1Gsg3fgGOXJAQ43QV" "AtRestEncryptKey": "7rAh6iwQCkV4cA1Gsg3fgGOXJAQ43QV"
}, },
"LogSettings": { "LogSettings": {
"ConsoleEnable": true, "EnableConsole": true,
"ConsoleLevel": "DEBUG", "ConsoleLevel": "DEBUG",
"FileEnable": true, "EnableFile": true,
"FileLevel": "INFO", "FileLevel": "INFO",
"FileFormat": "", "FileFormat": "",
"FileLocation": "" "FileLocation": ""
...@@ -43,6 +36,7 @@ ...@@ -43,6 +36,7 @@
"DriverName": "local", "DriverName": "local",
"Directory": "./data/", "Directory": "./data/",
"EnablePublicLink": true, "EnablePublicLink": true,
"PublicLinkSalt": "LhaAWC6lYEKHTkBKsvyXNIOfUIT37AX",
"ThumbnailWidth": 120, "ThumbnailWidth": 120,
"ThumbnailHeight": 100, "ThumbnailHeight": 100,
"PreviewWidth": 1024, "PreviewWidth": 1024,
...@@ -56,7 +50,7 @@ ...@@ -56,7 +50,7 @@
"AmazonS3Region": "" "AmazonS3Region": ""
}, },
"EmailSettings": { "EmailSettings": {
"AllowSignUpWithEmail": true, "EnableSignUpWithEmail": true,
"SendEmailNotifications": false, "SendEmailNotifications": false,
"RequireEmailVerification": false, "RequireEmailVerification": false,
"FeedbackName": "", "FeedbackName": "",
...@@ -66,6 +60,8 @@ ...@@ -66,6 +60,8 @@
"SMTPServer": "", "SMTPServer": "",
"SMTPPort": "", "SMTPPort": "",
"ConnectionSecurity": "", "ConnectionSecurity": "",
"InviteSalt": "bjlSR4QqkXFBr7TP4oDzlfZmcNuH9Yo",
"PasswordResetSalt": "vZ4DcKyVVRlKHHJpexcuXzojkE5PZ5e",
"ApplePushServer": "", "ApplePushServer": "",
"ApplePushCertPublic": "", "ApplePushCertPublic": "",
"ApplePushCertPrivate": "" "ApplePushCertPrivate": ""
...@@ -82,7 +78,7 @@ ...@@ -82,7 +78,7 @@
"ShowFullName": true "ShowFullName": true
}, },
"GitLabSettings": { "GitLabSettings": {
"Allow": false, "Enable": false,
"Secret": "", "Secret": "",
"Id": "", "Id": "",
"Scope": "", "Scope": "",
......
{ {
"LogSettings": {
"ConsoleEnable": true,
"ConsoleLevel": "INFO",
"FileEnable": true,
"FileLevel": "INFO",
"FileFormat": "",
"FileLocation": ""
},
"ServiceSettings": { "ServiceSettings": {
"SiteName": "Mattermost", "ListenAddress": ":80",
"Mode" : "dev", "MaximumLoginAttempts": 10,
"AllowTesting" : true, "SegmentDeveloperKey": "",
"UseSSL": false, "GoogleDeveloperKey": "",
"Port": "80", "EnableOAuthServiceProvider": false,
"Version": "developer", "EnableTesting": false
"Shards": {
},
"InviteSalt": "gxHVDcKUyP2y1eiyW8S8na1UYQAfq6J6",
"PublicLinkSalt": "TO3pTyXIZzwHiwyZgGql7lM7DG3zeId4",
"ResetSalt": "IPxFzSfnDFsNsRafZxz8NaYqFKhf9y2t",
"AnalyticsUrl": "",
"UseLocalStorage": true,
"StorageDirectory": "/mattermost/data/",
"AllowedLoginAttempts": 10,
"DisableEmailSignUp": false,
"EnableOAuthServiceProvider": false
}, },
"SSOSettings": { "TeamSettings": {
"gitlab": { "SiteName": "Mattermost",
"Allow": false, "MaxUsersPerTeam": 50,
"Secret" : "", "DefaultThemeColor": "#2389D7",
"Id": "", "EnableTeamCreation": true,
"Scope": "", "EnableUserCrea