This repository has been archived by the owner on Jan 13, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API endpoints are now secured with role based ACLs. Also implemented client approval flow. Added a role based permission model for IAM. BUG= Review URL: https://codereview.appspot.com/326780043.
- Loading branch information
Showing
26 changed files
with
831 additions
and
348 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,46 @@ | ||
# Controller to manage clients. | ||
import json | ||
import api | ||
import utils | ||
|
||
from gluon.globals import current | ||
|
||
|
||
def index(): | ||
form = FORM('Search:', INPUT(_name='q'), INPUT(_type='submit')) | ||
form.accepts(request, session) | ||
return dict(form=form) | ||
|
||
|
||
def request_approval(): | ||
"""Request an approval to view client.""" | ||
client_id = request.vars.client_id | ||
if client_id: | ||
roles = ["Examiner", "Investigator"] | ||
approvers = api.api_dispatcher.call( | ||
current, "client.approver.list", client_id).get("data") | ||
inputs = [SELECT(*roles, | ||
_name="role", | ||
requires=IS_IN_SET(roles)), | ||
SELECT(*sorted(approvers), | ||
_name="approver", | ||
requires=IS_IN_SET(approvers)), | ||
] | ||
|
||
form = utils.build_form(inputs) | ||
if form.accepts(request, session): | ||
# Request an approval from the API | ||
api.api_dispatcher.call( | ||
current, "client.approver.request", client_id, | ||
form.vars.approver, form.vars.role) | ||
#redirect(URL(c="default", f="index")) | ||
|
||
return dict(form=form, client_id=client_id) | ||
|
||
|
||
def approve_request(): | ||
"""Approves a request from another user.""" | ||
client_id = request.vars.client_id | ||
role = request.vars.role | ||
user = request.vars.user | ||
if client_id and role and user: | ||
return dict(client_id=client_id, user=user, role=role) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.