[MM-34919] Use Mattermost-Plugin-ID header to pass ID in inter-plugin requests (#17418)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
4bd6f4942f
Коммит
730dc6b985
@@ -1404,6 +1404,10 @@ func TestInterpluginPluginHTTP(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
if r.Header.Get("Mattermost-Plugin-ID") != "testplugininterclient" {
|
||||
return
|
||||
}
|
||||
|
||||
buf := bytes.Buffer{}
|
||||
buf.ReadFrom(r.Body)
|
||||
resp := "we got:" + buf.String()
|
||||
|
||||
@@ -74,6 +74,8 @@ func (a *App) ServeInterPluginRequest(w http.ResponseWriter, r *http.Request, so
|
||||
SourcePluginId: sourcePluginId,
|
||||
}
|
||||
|
||||
r.Header.Set("Mattermost-Plugin-ID", sourcePluginId)
|
||||
|
||||
hooks.ServeHTTP(context, w, r)
|
||||
}
|
||||
|
||||
@@ -135,6 +137,9 @@ func (a *App) servePluginRequest(w http.ResponseWriter, r *http.Request, handler
|
||||
token = r.URL.Query().Get("access_token")
|
||||
}
|
||||
|
||||
// Mattermost-Plugin-ID can only be set by inter-plugin requests
|
||||
r.Header.Del("Mattermost-Plugin-ID")
|
||||
|
||||
r.Header.Del("Mattermost-User-Id")
|
||||
if token != "" {
|
||||
session, err := a.GetSession(token)
|
||||
|
||||
@@ -12,5 +12,5 @@ type Context struct {
|
||||
IpAddress string
|
||||
AcceptLanguage string
|
||||
UserAgent string
|
||||
SourcePluginId string
|
||||
SourcePluginId string // Deprecated: Use the "Mattermost-Plugin-ID" HTTP header instead
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user