This is an automated email from the ASF dual-hosted git repository. dangogh pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-trafficcontrol.git
The following commit(s) were added to refs/heads/master by this push: new 0069926 renames privlevel variables according to their associated role 0069926 is described below commit 0069926582034e7c3d18e3a59f642b94072f8a49 Author: Jeremy Mitchell <mitchell...@gmail.com> AuthorDate: Thu Feb 1 10:55:50 2018 -0700 renames privlevel variables according to their associated role --- traffic_ops/traffic_ops_golang/auth/authorize.go | 11 ++++++--- traffic_ops/traffic_ops_golang/cdn/cdns.go | 2 -- traffic_ops/traffic_ops_golang/divisions.go | 2 -- traffic_ops/traffic_ops_golang/hwinfo.go | 2 -- traffic_ops/traffic_ops_golang/monitoring.go | 3 --- traffic_ops/traffic_ops_golang/parameters.go | 2 -- traffic_ops/traffic_ops_golang/phys_locations.go | 2 -- traffic_ops/traffic_ops_golang/regions.go | 1 - traffic_ops/traffic_ops_golang/routes.go | 30 ++++++++++++------------ traffic_ops/traffic_ops_golang/routing_test.go | 4 +++- traffic_ops/traffic_ops_golang/servers.go | 3 --- traffic_ops/traffic_ops_golang/statuses.go | 2 -- traffic_ops/traffic_ops_golang/system_info.go | 2 -- 13 files changed, 26 insertions(+), 40 deletions(-) diff --git a/traffic_ops/traffic_ops_golang/auth/authorize.go b/traffic_ops/traffic_ops_golang/auth/authorize.go index 1f7df09..e1a5c77 100644 --- a/traffic_ops/traffic_ops_golang/auth/authorize.go +++ b/traffic_ops/traffic_ops_golang/auth/authorize.go @@ -39,13 +39,18 @@ type CurrentUser struct { // PrivLevelInvalid - The Default Priv level const PrivLevelInvalid = -1 -// PrivLevelReadOnly - The user cannot do any API updates const PrivLevelReadOnly = 10 -// PrivLevelOperations - The user has minimal privileges +const PrivLevelORT = 11 + +const PrivLevelSteering = 15 + +const PrivLevelFederation = 15 + +const PrivLevelPortal = 15 + const PrivLevelOperations = 20 -// PrivLevelAdmin - The user has full privileges const PrivLevelAdmin = 30 // TenantIDInvalid - The default Tenant ID diff --git a/traffic_ops/traffic_ops_golang/cdn/cdns.go b/traffic_ops/traffic_ops_golang/cdn/cdns.go index 866e9b7..dd52654 100644 --- a/traffic_ops/traffic_ops_golang/cdn/cdns.go +++ b/traffic_ops/traffic_ops_golang/cdn/cdns.go @@ -33,8 +33,6 @@ import ( "github.com/lib/pq" ) -const CDNsPrivLevel = 10 - //we need a type alias to define functions on type TOCDN tc.CDN diff --git a/traffic_ops/traffic_ops_golang/divisions.go b/traffic_ops/traffic_ops_golang/divisions.go index 7e4cfd1..556a22a 100644 --- a/traffic_ops/traffic_ops_golang/divisions.go +++ b/traffic_ops/traffic_ops_golang/divisions.go @@ -30,8 +30,6 @@ import ( "github.com/jmoiron/sqlx" ) -const DivisionsPrivLevel = 10 - func divisionsHandler(db *sqlx.DB) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { handleErrs := tc.GetHandleErrorsFunc(w, r) diff --git a/traffic_ops/traffic_ops_golang/hwinfo.go b/traffic_ops/traffic_ops_golang/hwinfo.go index 393c43c..a50b949 100644 --- a/traffic_ops/traffic_ops_golang/hwinfo.go +++ b/traffic_ops/traffic_ops_golang/hwinfo.go @@ -30,8 +30,6 @@ import ( "github.com/jmoiron/sqlx" ) -const HWInfoPrivLevel = 10 - func hwInfoHandler(db *sqlx.DB) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { handleErrs := tc.GetHandleErrorsFunc(w, r) diff --git a/traffic_ops/traffic_ops_golang/monitoring.go b/traffic_ops/traffic_ops_golang/monitoring.go index 0de7e24..7835b0b 100644 --- a/traffic_ops/traffic_ops_golang/monitoring.go +++ b/traffic_ops/traffic_ops_golang/monitoring.go @@ -32,11 +32,8 @@ import ( "github.com/apache/incubator-trafficcontrol/lib/go-tc" "github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/api" - "github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/auth" ) -const MonitoringPrivLevel = auth.PrivLevelReadOnly - const CacheMonitorConfigFile = "rascal.properties" const MonitorType = "RASCAL" const RouterType = "CCR" diff --git a/traffic_ops/traffic_ops_golang/parameters.go b/traffic_ops/traffic_ops_golang/parameters.go index 5527b32..e3c97e7 100644 --- a/traffic_ops/traffic_ops_golang/parameters.go +++ b/traffic_ops/traffic_ops_golang/parameters.go @@ -33,8 +33,6 @@ import ( "github.com/jmoiron/sqlx" ) -const ParametersPrivLevel = auth.PrivLevelReadOnly - func parametersHandler(db *sqlx.DB) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { handleErrs := tc.GetHandleErrorsFunc(w, r) diff --git a/traffic_ops/traffic_ops_golang/phys_locations.go b/traffic_ops/traffic_ops_golang/phys_locations.go index 2a08ca6..538970d 100644 --- a/traffic_ops/traffic_ops_golang/phys_locations.go +++ b/traffic_ops/traffic_ops_golang/phys_locations.go @@ -31,8 +31,6 @@ import ( "github.com/jmoiron/sqlx" ) -const PhysLocationsPrivLevel = 10 - func physLocationsHandler(db *sqlx.DB) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { handleErrs := tc.GetHandleErrorsFunc(w, r) diff --git a/traffic_ops/traffic_ops_golang/regions.go b/traffic_ops/traffic_ops_golang/regions.go index 00eadfd..3b06f23 100644 --- a/traffic_ops/traffic_ops_golang/regions.go +++ b/traffic_ops/traffic_ops_golang/regions.go @@ -31,7 +31,6 @@ import ( "github.com/jmoiron/sqlx" ) -const RegionsPrivLevel = 10 func regionsHandler(db *sqlx.DB) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { diff --git a/traffic_ops/traffic_ops_golang/routes.go b/traffic_ops/traffic_ops_golang/routes.go index 49a3fd4..f3cac41 100644 --- a/traffic_ops/traffic_ops_golang/routes.go +++ b/traffic_ops/traffic_ops_golang/routes.go @@ -60,10 +60,10 @@ func Routes(d ServerData) ([]Route, http.Handler, error) { {1.2, http.MethodGet, `cdns/health$`, handlerToFunc(proxyHandler), 0, NoAuth, []Middleware{}}, {1.2, http.MethodGet, `cdns/routing$`, handlerToFunc(proxyHandler), 0, NoAuth, []Middleware{}}, - {1.2, http.MethodGet, `cdns/{name}/configs/monitoring(\.json)?$`, monitoringHandler(d.DB), MonitoringPrivLevel, Authenticated, nil}, + {1.2, http.MethodGet, `cdns/{name}/configs/monitoring(\.json)?$`, monitoringHandler(d.DB), auth.PrivLevelReadOnly, Authenticated, nil}, //CDN generic handlers: - {1.3, http.MethodGet, `cdns/?(\.json)?$`, api.ReadHandler(cdn.GetRefType(), d.DB), cdn.CDNsPrivLevel, Authenticated, nil}, - {1.3, http.MethodGet, `cdns/{id}$`, api.ReadHandler(cdn.GetRefType(), d.DB), cdn.CDNsPrivLevel, Authenticated, nil}, + {1.3, http.MethodGet, `cdns/?(\.json)?$`, api.ReadHandler(cdn.GetRefType(), d.DB), auth.PrivLevelReadOnly, Authenticated, nil}, + {1.3, http.MethodGet, `cdns/{id}$`, api.ReadHandler(cdn.GetRefType(), d.DB), auth.PrivLevelReadOnly, Authenticated, nil}, {1.3, http.MethodPut, `cdns/{id}$`, api.UpdateHandler(cdn.GetRefType(), d.DB), auth.PrivLevelOperations, Authenticated, nil}, {1.3, http.MethodPost, `cdns/?$`, api.CreateHandler(cdn.GetRefType(), d.DB), auth.PrivLevelOperations, Authenticated, nil}, {1.3, http.MethodDelete, `cdns/{id}$`, api.DeleteHandler(cdn.GetRefType(), d.DB), auth.PrivLevelOperations, Authenticated, nil}, @@ -74,14 +74,14 @@ func Routes(d ServerData) ([]Route, http.Handler, error) { {1.3, http.MethodPut, `deliveryservices/{xmlID}/urisignkeys$`, saveDeliveryServiceURIKeysHandler(d.DB, d.Config), auth.PrivLevelAdmin, Authenticated, nil}, {1.3, http.MethodDelete, `deliveryservices/{xmlID}/urisignkeys$`, removeDeliveryServiceURIKeysHandler(d.DB, d.Config), auth.PrivLevelAdmin, Authenticated, nil}, //Divisions - {1.2, http.MethodGet, `divisions/?(\.json)?$`, divisionsHandler(d.DB), DivisionsPrivLevel, Authenticated, nil}, + {1.2, http.MethodGet, `divisions/?(\.json)?$`, divisionsHandler(d.DB), auth.PrivLevelReadOnly, Authenticated, nil}, //HwInfo - {1.2, http.MethodGet, `hwinfo-wip/?(\.json)?$`, hwInfoHandler(d.DB), HWInfoPrivLevel, Authenticated, nil}, + {1.2, http.MethodGet, `hwinfo-wip/?(\.json)?$`, hwInfoHandler(d.DB), auth.PrivLevelReadOnly, Authenticated, nil}, //Parameters - {1.3, http.MethodGet, `parameters/?(\.json)?$`, parametersHandler(d.DB), ParametersPrivLevel, Authenticated, nil}, + {1.3, http.MethodGet, `parameters/?(\.json)?$`, parametersHandler(d.DB), auth.PrivLevelReadOnly, Authenticated, nil}, //Regions - {1.2, http.MethodGet, `regions/?(\.json)?$`, regionsHandler(d.DB), RegionsPrivLevel, Authenticated, nil}, - {1.2, http.MethodGet, `regions/{id}$`, regionsHandler(d.DB), RegionsPrivLevel, Authenticated, nil}, + {1.2, http.MethodGet, `regions/?(\.json)?$`, regionsHandler(d.DB), auth.PrivLevelReadOnly, Authenticated, nil}, + {1.2, http.MethodGet, `regions/{id}$`, regionsHandler(d.DB), auth.PrivLevelReadOnly, Authenticated, nil}, //Servers // explicitly passed to legacy system until fully implemented. Auth handled by legacy system. {1.2, http.MethodGet, `servers/checks$`, handlerToFunc(proxyHandler), 0, NoAuth, []Middleware{}}, @@ -89,8 +89,8 @@ func Routes(d ServerData) ([]Route, http.Handler, error) { {1.2, http.MethodGet, `servers/status$`, handlerToFunc(proxyHandler), 0, NoAuth, []Middleware{}}, {1.2, http.MethodGet, `servers/totals$`, handlerToFunc(proxyHandler), 0, NoAuth, []Middleware{}}, - {1.2, http.MethodGet, `servers/?(\.json)?$`, serversHandler(d.DB), ServersPrivLevel, Authenticated, nil}, - {1.2, http.MethodGet, `servers/{id}$`, serversHandler(d.DB), ServersPrivLevel, Authenticated, nil}, + {1.2, http.MethodGet, `servers/?(\.json)?$`, serversHandler(d.DB), auth.PrivLevelReadOnly, Authenticated, nil}, + {1.2, http.MethodGet, `servers/{id}$`, serversHandler(d.DB), auth.PrivLevelReadOnly, Authenticated, nil}, {1.2, http.MethodPost, `servers/{id}/deliveryservices$`, assignDeliveryServicesToServerHandler(d.DB), auth.PrivLevelOperations, Authenticated, nil}, {1.2, http.MethodGet, `servers/{host_name}/update_status$`, getServerUpdateStatusHandler(d.DB), auth.PrivLevelReadOnly, Authenticated, nil}, @@ -99,14 +99,14 @@ func Routes(d ServerData) ([]Route, http.Handler, error) { {1.2, http.MethodGet, `deliveryservices-wip/hostname/{hostName}/sslkeys$`, getDeliveryServiceSSLKeysByHostNameHandler(d.DB, d.Config), auth.PrivLevelAdmin, Authenticated, nil}, {1.2, http.MethodPost, `deliveryservices-wip/hostname/{hostName}/sslkeys/add$`, addDeliveryServiceSSLKeysHandler(d.DB, d.Config), auth.PrivLevelAdmin, Authenticated, nil}, //Statuses - {1.2, http.MethodGet, `statuses/?(\.json)?$`, statusesHandler(d.DB), StatusesPrivLevel, Authenticated, nil}, - {1.2, http.MethodGet, `statuses/{id}$`, statusesHandler(d.DB), StatusesPrivLevel, Authenticated, nil}, + {1.2, http.MethodGet, `statuses/?(\.json)?$`, statusesHandler(d.DB), auth.PrivLevelReadOnly, Authenticated, nil}, + {1.2, http.MethodGet, `statuses/{id}$`, statusesHandler(d.DB), auth.PrivLevelReadOnly, Authenticated, nil}, //System - {1.2, http.MethodGet, `system/info/?(\.json)?$`, systemInfoHandler(d.DB), SystemInfoPrivLevel, Authenticated, nil}, + {1.2, http.MethodGet, `system/info/?(\.json)?$`, systemInfoHandler(d.DB), auth.PrivLevelReadOnly, Authenticated, nil}, //Phys_Locations - {1.2, http.MethodGet, `phys_locations/?(\.json)?$`, physLocationsHandler(d.DB), PhysLocationsPrivLevel, Authenticated, nil}, - {1.2, http.MethodGet, `phys_locations/{id}$`, physLocationsHandler(d.DB), PhysLocationsPrivLevel, Authenticated, nil}, + {1.2, http.MethodGet, `phys_locations/?(\.json)?$`, physLocationsHandler(d.DB), auth.PrivLevelReadOnly, Authenticated, nil}, + {1.2, http.MethodGet, `phys_locations/{id}$`, physLocationsHandler(d.DB), auth.PrivLevelReadOnly, Authenticated, nil}, } return routes, proxyHandler, nil } diff --git a/traffic_ops/traffic_ops_golang/routing_test.go b/traffic_ops/traffic_ops_golang/routing_test.go index 265a558..e3ed187 100644 --- a/traffic_ops/traffic_ops_golang/routing_test.go +++ b/traffic_ops/traffic_ops_golang/routing_test.go @@ -28,6 +28,8 @@ import ( "bytes" "context" "net/http/httptest" + + "github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/auth" ) func TestCreateRouteMap(t *testing.T) { @@ -57,7 +59,7 @@ func TestCreateRouteMap(t *testing.T) { } routes := []Route{ - {1.2, http.MethodGet, `path1`, PathOneHandler, ServersPrivLevel, true, nil}, + {1.2, http.MethodGet, `path1`, PathOneHandler, auth.PrivLevelReadOnly, true, nil}, {1.2, http.MethodGet, `path2`, PathTwoHandler, 0, false, nil}, {1.2, http.MethodGet, `path3`, PathThreeHandler, 0, false, []Middleware{}}, } diff --git a/traffic_ops/traffic_ops_golang/servers.go b/traffic_ops/traffic_ops_golang/servers.go index 364f791..4e7e776 100644 --- a/traffic_ops/traffic_ops_golang/servers.go +++ b/traffic_ops/traffic_ops_golang/servers.go @@ -36,9 +36,6 @@ import ( "github.com/jmoiron/sqlx" ) -// ServersPrivLevel - privileges for the /servers endpoint -const ServersPrivLevel = 10 - func serversHandler(db *sqlx.DB) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { handleErrs := tc.GetHandleErrorsFunc(w, r) diff --git a/traffic_ops/traffic_ops_golang/statuses.go b/traffic_ops/traffic_ops_golang/statuses.go index 6ae0659..f9b5954 100644 --- a/traffic_ops/traffic_ops_golang/statuses.go +++ b/traffic_ops/traffic_ops_golang/statuses.go @@ -34,8 +34,6 @@ import ( "github.com/jmoiron/sqlx" ) -const StatusesPrivLevel = 10 - func statusesHandler(db *sqlx.DB) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { handleErrs := tc.GetHandleErrorsFunc(w, r) diff --git a/traffic_ops/traffic_ops_golang/system_info.go b/traffic_ops/traffic_ops_golang/system_info.go index da0c081..62e845b 100644 --- a/traffic_ops/traffic_ops_golang/system_info.go +++ b/traffic_ops/traffic_ops_golang/system_info.go @@ -30,8 +30,6 @@ import ( "github.com/jmoiron/sqlx" ) -const SystemInfoPrivLevel = 10 - func systemInfoHandler(db *sqlx.DB) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { handleErrs := tc.GetHandleErrorsFunc(w, r) -- To stop receiving notification emails like this one, please contact dang...@apache.org.