diff options
author | Wim <wim@42.be> | 2016-08-15 18:47:31 +0200 |
---|---|---|
committer | Wim <wim@42.be> | 2016-08-15 18:47:31 +0200 |
commit | 24defcb970838133eb82f4fbbc516630fb81cae6 (patch) | |
tree | de88bd0761b08ee35d8f2ddbcb133f7899b4264d /vendor/github.com/mattermost/platform/model/oauth.go | |
parent | a1a11a88b334a4deb78915336def0113eec9738b (diff) | |
download | matterbridge-msglm-24defcb970838133eb82f4fbbc516630fb81cae6.tar.gz matterbridge-msglm-24defcb970838133eb82f4fbbc516630fb81cae6.tar.bz2 matterbridge-msglm-24defcb970838133eb82f4fbbc516630fb81cae6.zip |
Sync with mattermost 3.3.0
Diffstat (limited to 'vendor/github.com/mattermost/platform/model/oauth.go')
-rw-r--r-- | vendor/github.com/mattermost/platform/model/oauth.go | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/vendor/github.com/mattermost/platform/model/oauth.go b/vendor/github.com/mattermost/platform/model/oauth.go index c54df107..cfe643c9 100644 --- a/vendor/github.com/mattermost/platform/model/oauth.go +++ b/vendor/github.com/mattermost/platform/model/oauth.go @@ -25,8 +25,10 @@ type OAuthApp struct { ClientSecret string `json:"client_secret"` Name string `json:"name"` Description string `json:"description"` + IconURL string `json:"icon_url"` CallbackUrls StringArray `json:"callback_urls"` Homepage string `json:"homepage"` + IsTrusted bool `json:"is_trusted"` } // IsValid validates the app and returns an error if it isn't configured @@ -61,7 +63,13 @@ func (a *OAuthApp) IsValid() *AppError { return NewLocAppError("OAuthApp.IsValid", "model.oauth.is_valid.callback.app_error", nil, "app_id="+a.Id) } - if len(a.Homepage) == 0 || len(a.Homepage) > 256 { + for _, callback := range a.CallbackUrls { + if !IsValidHttpUrl(callback) { + return NewLocAppError("OAuthApp.IsValid", "model.oauth.is_valid.callback.app_error", nil, "") + } + } + + if len(a.Homepage) == 0 || len(a.Homepage) > 256 || !IsValidHttpUrl(a.Homepage) { return NewLocAppError("OAuthApp.IsValid", "model.oauth.is_valid.homepage.app_error", nil, "app_id="+a.Id) } @@ -69,6 +77,12 @@ func (a *OAuthApp) IsValid() *AppError { return NewLocAppError("OAuthApp.IsValid", "model.oauth.is_valid.description.app_error", nil, "app_id="+a.Id) } + if len(a.IconURL) > 0 { + if len(a.IconURL) > 512 || !IsValidHttpUrl(a.IconURL) { + return NewLocAppError("OAuthApp.IsValid", "model.oauth.is_valid.icon_url.app_error", nil, "app_id="+a.Id) + } + } + return nil } @@ -85,10 +99,6 @@ func (a *OAuthApp) PreSave() { a.CreateAt = GetMillis() a.UpdateAt = a.CreateAt - - if len(a.ClientSecret) > 0 { - a.ClientSecret = HashPassword(a.ClientSecret) - } } // PreUpdate should be run before updating the app in the db. @@ -157,3 +167,23 @@ func OAuthAppMapFromJson(data io.Reader) map[string]*OAuthApp { return nil } } + +func OAuthAppListToJson(l []*OAuthApp) string { + b, err := json.Marshal(l) + if err != nil { + return "" + } else { + return string(b) + } +} + +func OAuthAppListFromJson(data io.Reader) []*OAuthApp { + decoder := json.NewDecoder(data) + var o []*OAuthApp + err := decoder.Decode(&o) + if err == nil { + return o + } else { + return nil + } +} |