fixed CSRF in admin enabled/disable. thanks Nerendra Bhati
This commit is contained in:
@@ -533,8 +533,8 @@ def delete():
|
||||
redirect(URL(sender, anchor=request.vars.id2))
|
||||
return dict(dialog=dialog, filename=filename)
|
||||
|
||||
|
||||
def enable():
|
||||
if not URL.verify(request, hmac_key=session.hmac_key): raise HTTP(401)
|
||||
app = get_app()
|
||||
filename = os.path.join(apath(app, r=request), 'DISABLED')
|
||||
if is_gae:
|
||||
|
||||
@@ -4,6 +4,7 @@ import time
|
||||
from gluon import portalocker
|
||||
from gluon.admin import apath
|
||||
from gluon.fileutils import read_file
|
||||
from gluon.utils import web2py_uuid
|
||||
# ###########################################################
|
||||
# ## make sure administrator is on localhost or https
|
||||
# ###########################################################
|
||||
@@ -49,15 +50,18 @@ except IOError:
|
||||
def verify_password(password):
|
||||
session.pam_user = None
|
||||
if DEMO_MODE:
|
||||
return True
|
||||
ret = True
|
||||
elif not _config.get('password'):
|
||||
return False
|
||||
ret - False
|
||||
elif _config['password'].startswith('pam_user:'):
|
||||
session.pam_user = _config['password'][9:].strip()
|
||||
import gluon.contrib.pam
|
||||
return gluon.contrib.pam.authenticate(session.pam_user, password)
|
||||
ret = gluon.contrib.pam.authenticate(session.pam_user, password)
|
||||
else:
|
||||
return _config['password'] == CRYPT()(password)[0]
|
||||
ret = _config['password'] == CRYPT()(password)[0]
|
||||
if ret:
|
||||
session.hmac_key = web2py_uuid()
|
||||
return ret
|
||||
|
||||
|
||||
# ###########################################################
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
{{pass}}
|
||||
</ul>
|
||||
</div>
|
||||
{{=button_enable(URL('enable',args=a), a) if a!='admin' else ''}}
|
||||
{{=button_enable(URL('enable',args=a, hmac_key=session.hmac_key), a) if a!='admin' else ''}}
|
||||
</td>
|
||||
</tr>
|
||||
{{pass}}
|
||||
|
||||
Reference in New Issue
Block a user