Skip to content

Commit 5776fff

Browse files
committed
initial dev on appllication list with search
1 parent 69fa7da commit 5776fff

4 files changed

Lines changed: 8 additions & 3 deletions

File tree

api/src/controller/userSearch.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ def get(self):
1717
permissions = canAccessUserData(auth0_id)
1818
if permissions is None:
1919
return {"message": "Internal Server Error"}, 500
20-
if not permissions:
20+
if not (permissions or authenticationPayload['gty'] == 'client-credentials'):
21+
# check that the grant type is client-credentials which will exist only for the machine to machine
22+
# auth0 connections using client id and secret, aka: discord bots and s3 resume downloader
2123
return {"message": "Permission Denied"}, 403
2224

2325
parser = reqparse.RequestParser()

api/src/controller/users.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from utils.authentication import authenticate
55
from data.permissions import canAccessUserData
66

7-
87
class Users(Resource):
98
PATH = '/users'
109

@@ -13,6 +12,7 @@ def get(self):
1312
if authenticationPayload is None:
1413
return {"message": "Must be logged in"}, 401
1514
auth0_id = authenticationPayload['sub']
15+
1616
permissions = canAccessUserData(auth0_id)
1717
if permissions is None:
1818
return {"message": "Internal Server Error"}, 500

api/src/data/permissions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ def checkUserPermissionsByAuth0Id(auth0Id, permission, accessType) -> bool:
5454
result, err = exec_get_one(sql, args)
5555
if err:
5656
return None
57+
if result is None:
58+
return False
5759
if len(result) > 0:
5860
# check if there are keys in result, if there are then user has permission
5961
return True

api/src/data/users.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ def getUsers(applicationStatusFilterList: List[str] = None, is_virtual=None, fir
3939

4040
if applicationStatusFilterList is not None:
4141
sql += f" WHERE app.status in ({','.join(['%s'] * len(applicationStatusFilterList))}) "
42-
args = args + (tuple(applicationStatusFilterList),)
42+
for status in applicationStatusFilterList:
43+
args = args + (status,)
4344
if is_virtual is not None:
4445
sql += getOptionalAnd(firstWhereClause) + " WHERE app.is_virtual = %s "
4546
args = args + (is_virtual,)

0 commit comments

Comments
 (0)