Skip to content

Commit

Permalink
authorized_users -> admin_users
Browse files Browse the repository at this point in the history
  • Loading branch information
chen-anders committed Jul 11, 2017
1 parent b195fa9 commit 27d590f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions nsqadmin/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -785,12 +785,12 @@ func (s *httpServer) doConfig(w http.ResponseWriter, req *http.Request, ps httpr
}

func (s *httpServer) authorizedAdminRequest(req *http.Request) (bool) {
authorizedUsers := s.ctx.nsqadmin.getOpts().AuthorizedUsers
if len(authorizedUsers) == 0 {
adminUsers := s.ctx.nsqadmin.getOpts().AdminUsers
if len(adminUsers) == 0 {
return true
} else {
user := req.Header.Get("X-FORWARDED-USER")
for _, v := range authorizedUsers {
for _, v := range adminUsers {
if v == user {
return true
}
Expand Down
6 changes: 3 additions & 3 deletions nsqadmin/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func bootstrapNSQClusterWithAuth(t *testing.T, withAuth bool) (string, []*nsqd.N
nsqadminOpts.NSQLookupdHTTPAddresses = []string{nsqlookupd1.RealHTTPAddr().String()}
nsqadminOpts.Logger = lgr
if withAuth {
nsqadminOpts.AuthorizedUsers = []string{"matt"}
nsqadminOpts.AdminUsers = []string{"matt"}
}
nsqadmin1 := New(nsqadminOpts)
go nsqadmin1.Main()
Expand Down Expand Up @@ -119,7 +119,7 @@ func TestPing(t *testing.T) {
test.Equal(t, []byte("OK"), body)
}

func TestAuthorizedWithoutAnyAuthorizedUsers(t *testing.T) {
func TestAuthorizedWithoutAnyAdminUsers(t *testing.T) {
dataPath, nsqds, nsqlookupds, nsqadmin1 := bootstrapNSQCluster(t)
defer os.RemoveAll(dataPath)
defer nsqds[0].Exit()
Expand All @@ -141,7 +141,7 @@ func TestAuthorizedWithoutAnyAuthorizedUsers(t *testing.T) {
test.Equal(t, res["authorized"], true)
}

func TestAuthorizedWithAuthorizedUsers(t *testing.T) {
func TestAuthorizedWithAdminUsers(t *testing.T) {
dataPath, nsqds, nsqlookupds, nsqadmin1 := bootstrapNSQClusterWithAuth(t, true)
defer os.RemoveAll(dataPath)
defer nsqds[0].Exit()
Expand Down
4 changes: 2 additions & 2 deletions nsqadmin/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type Options struct {

NotificationHTTPEndpoint string `flag:"notification-http-endpoint"`

AuthorizedUsers []string `flag:"authorized-user" cfg:"authorized_users"`
AdminUsers []string `flag:"admin-user" cfg:"admin_users"`
}

func NewOptions() *Options {
Expand All @@ -54,6 +54,6 @@ func NewOptions() *Options {
HTTPClientConnectTimeout: 2 * time.Second,
HTTPClientRequestTimeout: 5 * time.Second,
AllowConfigFromCIDR: "127.0.0.1/8",
AuthorizedUsers: []string{},
AdminUsers: []string{},
}
}

0 comments on commit 27d590f

Please sign in to comment.