fix #121. Db user authentication shouldn't fall back to cluster admin authentication

pull/144/head
John Shahid 2013-12-12 11:52:11 -05:00
parent f3b1ec8be1
commit cdef0f547f
2 changed files with 11 additions and 1 deletions

View File

@ -603,7 +603,7 @@ func (self *CoordinatorImpl) DropDatabase(user common.User, db string) error {
func (self *CoordinatorImpl) AuthenticateDbUser(db, username, password string) (common.User, error) {
dbUsers := self.clusterConfiguration.dbUsers[db]
if dbUsers == nil || dbUsers[username] == nil {
return self.AuthenticateClusterAdmin(username, password)
return nil, common.NewAuthorizationError("Invalid username/password")
}
user := dbUsers[username]
if user.isValidPwd(password) {

View File

@ -251,6 +251,16 @@ func (self *IntegrationSuite) TestMedians(c *C) {
c.Assert(data[0].Points[1][1], Equals, 70.0)
}
func (self *IntegrationSuite) TestDbUserAuthentication(c *C) {
resp, err := http.Get("http://localhost:8086/db/db1/authenticate?u=root&p=root")
c.Assert(err, IsNil)
c.Assert(resp.StatusCode, Equals, http.StatusUnauthorized)
resp, err = http.Get("http://localhost:8086/db/db2/authenticate?u=root&p=root")
c.Assert(err, IsNil)
c.Assert(resp.StatusCode, Equals, http.StatusUnauthorized)
}
func (self *IntegrationSuite) TestArithmeticOperations(c *C) {
queries := map[string][9]float64{
"select input + output from test_arithmetic_3.0;": [9]float64{1, 2, 3, 4, 5, 9, 6, 7, 13},