You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2018/02/26 19:20:37 UTC
[GitHub] dangogh closed pull request #1927: remove the improper use of the NoAuth flag disabling user authentication
dangogh closed pull request #1927: remove the improper use of the NoAuth flag disabling user authentication
URL: https://github.com/apache/incubator-trafficcontrol/pull/1927
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/traffic_ops/traffic_ops_golang/routing.go b/traffic_ops/traffic_ops_golang/routing.go
index 070ac750b6..a940d5d7ff 100644
--- a/traffic_ops/traffic_ops_golang/routing.go
+++ b/traffic_ops/traffic_ops_golang/routing.go
@@ -189,7 +189,7 @@ func RegisterRoutes(d ServerData) error {
return fmt.Errorf("Error preparing db priv level query: %s", err)
}
- authBase := AuthBase{d.Insecure, d.Config.Secrets[0], userInfoStmt, nil} //we know d.Config.Secrets is a slice of at least one or start up would fail.
+ authBase := AuthBase{secret: d.Config.Secrets[0], getCurrentUserInfoStmt: userInfoStmt, override: nil} //we know d.Config.Secrets is a slice of at least one or start up would fail.
routes := CreateRouteMap(routeSlice, authBase)
compiledRoutes := CompileRoutes(routes)
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
diff --git a/traffic_ops/traffic_ops_golang/routing_test.go b/traffic_ops/traffic_ops_golang/routing_test.go
index 6467f42dab..8537aa18d1 100644
--- a/traffic_ops/traffic_ops_golang/routing_test.go
+++ b/traffic_ops/traffic_ops_golang/routing_test.go
@@ -37,7 +37,7 @@ type key int
const AuthWasCalled key = iota
func TestCreateRouteMap(t *testing.T) {
- authBase := AuthBase{false, "secret", nil, func(handlerFunc http.HandlerFunc) http.HandlerFunc {
+ authBase := AuthBase{"secret", nil, func(handlerFunc http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
ctx := context.WithValue(r.Context(), AuthWasCalled, "true")
handlerFunc(w, r.WithContext(ctx))
diff --git a/traffic_ops/traffic_ops_golang/wrappers.go b/traffic_ops/traffic_ops_golang/wrappers.go
index a6500116b9..812936b2d8 100644
--- a/traffic_ops/traffic_ops_golang/wrappers.go
+++ b/traffic_ops/traffic_ops_golang/wrappers.go
@@ -45,7 +45,6 @@ const ServerName = "traffic_ops_golang" + "/" + Version
// AuthBase ...
type AuthBase struct {
- noAuth bool
secret string
getCurrentUserInfoStmt *sqlx.Stmt
override Middleware
@@ -57,13 +56,6 @@ func (a AuthBase) GetWrapper(privLevelRequired int) Middleware {
return a.override
}
return func(handlerFunc http.HandlerFunc) http.HandlerFunc {
- if a.noAuth {
- return func(w http.ResponseWriter, r *http.Request) {
- ctx := r.Context()
- ctx = context.WithValue(ctx, auth.CurrentUserKey, auth.CurrentUser{UserName: "-", ID: -1, PrivLevel: auth.PrivLevelInvalid})
- handlerFunc(w, r.WithContext(ctx))
- }
- }
return func(w http.ResponseWriter, r *http.Request) {
// TODO remove, and make username available to wrapLogTime
start := time.Now()
diff --git a/traffic_ops/traffic_ops_golang/wrappers_test.go b/traffic_ops/traffic_ops_golang/wrappers_test.go
index a18e32c7a4..ab79ef2c56 100644
--- a/traffic_ops/traffic_ops_golang/wrappers_test.go
+++ b/traffic_ops/traffic_ops_golang/wrappers_test.go
@@ -141,7 +141,7 @@ func TestWrapAuth(t *testing.T) {
t.Fatalf("could not create priv statement: %v\n", err)
}
- authBase := AuthBase{false, secret, sqlStatement, nil}
+ authBase := AuthBase{secret, sqlStatement, nil}
cookie := tocookie.New(userName, time.Now().Add(time.Minute), secret)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services