Browse code

daemon/info: don't sort authorization plugins as order matters

plugins exist in a chain that composes potentially mutating requests and
responses. This simply reverts the sorting of AuthZ plugins so that the
/info API endpoint returns the internal ordering used for AuthZ composition.

Volume driver plugins are not affected because they are just a set.

Signed-off-by: David Sheets <dsheets@docker.com>

David Sheets authored on 2017/05/01 01:24:12
Showing 2 changed files
... ...
@@ -9,7 +9,6 @@ import (
9 9
 	"io/ioutil"
10 10
 	"reflect"
11 11
 	"runtime"
12
-	"sort"
13 12
 	"strings"
14 13
 	"sync"
15 14
 
... ...
@@ -503,19 +502,6 @@ func Validate(config *Config) error {
503 503
 	return nil
504 504
 }
505 505
 
506
-// GetAuthorizationPlugins returns daemon's sorted authorization plugins
507
-func (conf *Config) GetAuthorizationPlugins() []string {
508
-	conf.Lock()
509
-	defer conf.Unlock()
510
-
511
-	authPlugins := make([]string, 0, len(conf.AuthorizationPlugins))
512
-	for _, p := range conf.AuthorizationPlugins {
513
-		authPlugins = append(authPlugins, p)
514
-	}
515
-	sort.Strings(authPlugins)
516
-	return authPlugins
517
-}
518
-
519 506
 // ModifiedDiscoverySettings returns whether the discovery configuration has been modified or not.
520 507
 func ModifiedDiscoverySettings(config *Config, backendType, advertise string, clusterOpts map[string]string) bool {
521 508
 	if config.ClusterStore != backendType || config.ClusterAdvertise != advertise {
... ...
@@ -175,7 +175,9 @@ func (daemon *Daemon) showPluginsInfo() types.PluginsInfo {
175 175
 
176 176
 	pluginsInfo.Volume = volumedrivers.GetDriverList()
177 177
 	pluginsInfo.Network = daemon.GetNetworkDriverList()
178
-	pluginsInfo.Authorization = daemon.configStore.GetAuthorizationPlugins()
178
+	// The authorization plugins are returned in the order they are
179
+	// used as they constitute a request/response modification chain.
180
+	pluginsInfo.Authorization = daemon.configStore.AuthorizationPlugins
179 181
 	pluginsInfo.Log = logger.ListDrivers()
180 182
 
181 183
 	return pluginsInfo