Skip to content
Snippets Groups Projects
Commit 5d87d16d authored by ale's avatar ale
Browse files

require service on auth_pwonly

parent 6eaea794
No related branches found
No related tags found
No related merge requests found
...@@ -55,15 +55,16 @@ def api_auth(): ...@@ -55,15 +55,16 @@ def api_auth():
@app.route('/api/1/auth_pwonly', methods=('POST',)) @app.route('/api/1/auth_pwonly', methods=('POST',))
def api_auth_pwonly(): def api_auth_pwonly():
service = request.form.get('service')
username = request.form.get('username') username = request.form.get('username')
password = request.form.get('password') password = request.form.get('password')
if not username: if not service or not username:
abort(400) abort(400)
try: try:
auth_status, errmsg, unused_shard = do_auth( auth_status, errmsg, unused_shard = do_auth(
username, None, None, password, None, None, username, service, None, password, None, None,
password_only=True) password_only=True)
except Exception, e: except Exception, e:
app.logger.exception('Unexpected exception in auth_pwonly()') app.logger.exception('Unexpected exception in auth_pwonly()')
......
...@@ -223,6 +223,7 @@ class ServerTest(unittest.TestCase): ...@@ -223,6 +223,7 @@ class ServerTest(unittest.TestCase):
response = self.app.post( response = self.app.post(
URL_PWONLY, data={ URL_PWONLY, data={
'username': 'user', 'username': 'user',
'service': 'svc',
'password': 'pass'}) 'password': 'pass'})
self.assertEquals(protocol.OK, response.data) self.assertEquals(protocol.OK, response.data)
...@@ -230,6 +231,7 @@ class ServerTest(unittest.TestCase): ...@@ -230,6 +231,7 @@ class ServerTest(unittest.TestCase):
response = self.app.post( response = self.app.post(
URL_PWONLY, data={ URL_PWONLY, data={
'username': 'otpuser', 'username': 'otpuser',
'service': 'svc',
'password': 'pass'}) 'password': 'pass'})
self.assertEquals(protocol.OK, response.data) self.assertEquals(protocol.OK, response.data)
...@@ -237,6 +239,7 @@ class ServerTest(unittest.TestCase): ...@@ -237,6 +239,7 @@ class ServerTest(unittest.TestCase):
response = self.app.post( response = self.app.post(
URL_PWONLY, data={ URL_PWONLY, data={
'username': 'user', 'username': 'user',
'service': 'svc',
'password': 'badpass'}) 'password': 'badpass'})
self.assertEquals(protocol.ERR_AUTHENTICATION_FAILURE, self.assertEquals(protocol.ERR_AUTHENTICATION_FAILURE,
response.data) response.data)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment