From 26860478c435ddb68add2f7fadc0fb8bc74f9f73 Mon Sep 17 00:00:00 2001 From: Kamil Páral Date: May 04 2021 09:12:58 +0000 Subject: allow the dev to log in as any user, always in admin group Allowing the developer to log in as any user is important to work on web UI which shows the "Review" column differently, if you're logged in as a user who already voted. Always placing the user into the admin group is a quality of life improvement. The default config is created with FAS_ADMIN_GROUP='', which prevents any admin access until you correctly populate it (with "qa-admin"). That serves little purpose. Instead, assign the admin group to the FakeFAS user automatically, whichever its value is (even an empty string). --- diff --git a/blockerbugs/controllers/users.py b/blockerbugs/controllers/users.py index e8ac042..fd46f95 100644 --- a/blockerbugs/controllers/users.py +++ b/blockerbugs/controllers/users.py @@ -58,6 +58,6 @@ def check_admin_rights(): if app.config['FAS_ADMIN_GROUP'] in g.fas_user.groups: return None - app.logger.info('Failed admin access to %s by %s' % ( - request.url, g.fas_user.username)) + app.logger.info('Failed admin access to {url} by {user} (not in group "{admin}")'.format( + url=request.url, user=g.fas_user.username, admin=app.config['FAS_ADMIN_GROUP'])) abort(401) diff --git a/blockerbugs/util/login.py b/blockerbugs/util/login.py index c8f14a3..0aef6bf 100644 --- a/blockerbugs/util/login.py +++ b/blockerbugs/util/login.py @@ -46,9 +46,9 @@ def getFAS(): class FakeFAS(object): - fake_user_groups = ['qa-admin'] - fake_user = munch.Munch(username='developer', - groups=fake_user_groups) + fake_user = munch.Munch( + username=app.config['FAS_USER'] or 'developer', + groups=[app.config['FAS_ADMIN_GROUP']]) def __init__(self, app): app.before_request(self._set_fas_user)