mirror of
https://github.com/valitydev/redash.git
synced 2024-11-08 01:48:54 +00:00
Create stub User object for API to use permissions model
This commit is contained in:
parent
5de1795380
commit
0167bebf04
@ -40,6 +40,7 @@ class HMACAuthentication(object):
|
||||
calculated_signature = sign(query.api_key, request.path, expires)
|
||||
|
||||
if query.api_key and signature == calculated_signature:
|
||||
login_user(models.ApiUser(query.api_key), remember=False)
|
||||
return True
|
||||
|
||||
return False
|
||||
|
@ -22,6 +22,15 @@ class AnonymousUser(AnonymousUserMixin):
|
||||
return []
|
||||
|
||||
|
||||
class ApiUser(UserMixin):
|
||||
def __init__(self, api_key):
|
||||
self.id = api_key
|
||||
|
||||
@property
|
||||
def permissions(self):
|
||||
return ['view_query']
|
||||
|
||||
|
||||
class User(BaseModel, UserMixin):
|
||||
DEFAULT_PERMISSIONS = ['create_dashboard', 'create_query', 'edit_dashboard', 'edit_query',
|
||||
'view_query', 'view_source', 'execute_query']
|
||||
|
Loading…
Reference in New Issue
Block a user