Skip to content

Commit

Permalink
Merge pull request #385 from dinukadesilva/disable-write-access
Browse files Browse the repository at this point in the history
Disable write access temporary
  • Loading branch information
dinukadesilva authored Nov 19, 2019
2 parents 4d5bcad + 5d9f425 commit 4ad55c7
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 70 deletions.
6 changes: 3 additions & 3 deletions api/TallySheetApi.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from app import db
from auth import authorize, DATA_EDITOR_ROLE, POLLING_DIVISION_REPORT_VERIFIER_ROLE, \
ELECTORAL_DISTRICT_REPORT_VERIFIER_ROLE, NATIONAL_REPORT_VERIFIER_ROLE, EC_LEADERSHIP_ROLE
from auth.AuthConstants import ALL_ROLES
from auth.AuthConstants import ALL_ROLES, EC_LEADERSHIP_WRITE_ROLE
from exception import NotFoundException, ForbiddenException
from exception.messages import MESSAGE_CODE_TALLY_SHEET_CANNOT_LOCK_BEFORE_SUBMIT, \
MESSAGE_CODE_TALLY_SHEET_SUBMIT_IS_NOT_SUPPORTED, MESSAGE_CODE_TALLY_SHEET_NOT_FOUND, \
Expand Down Expand Up @@ -167,7 +167,7 @@ def lock(tallySheetId, body):
# return TallySheetSchema().dump(tally_sheet).data, 201


@authorize(required_roles=[EC_LEADERSHIP_ROLE])
@authorize(required_roles=[EC_LEADERSHIP_WRITE_ROLE])
def notify(tallySheetId):
tally_sheet = TallySheet.get_by_id(tallySheetId=tallySheetId)

Expand All @@ -193,7 +193,7 @@ def notify(tallySheetId):
return TallySheetSchema().dump(tally_sheet).data, 201


@authorize(required_roles=[EC_LEADERSHIP_ROLE])
@authorize(required_roles=[EC_LEADERSHIP_WRITE_ROLE])
def release(tallySheetId):
tally_sheet = TallySheet.get_by_id(tallySheetId=tallySheetId)

Expand Down
3 changes: 2 additions & 1 deletion auth/AuthConstants.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
NATIONAL_REPORT_VIEWER_ROLE = "nat_dis_rep_view"
NATIONAL_REPORT_VERIFIER_ROLE = "nat_dis_rep_verf"
EC_LEADERSHIP_ROLE = "ec_leadership"
EC_LEADERSHIP_WRITE_ROLE = "ec_leadership_write"

ACCESS_TYPE_READ = 'read'
ACCESS_TYPE_LOCK = 'lock'
Expand All @@ -21,6 +22,6 @@

ALL_ROLES = [DATA_EDITOR_ROLE, POLLING_DIVISION_REPORT_VERIFIER_ROLE, POLLING_DIVISION_REPORT_VIEWER_ROLE,
ELECTORAL_DISTRICT_REPORT_VERIFIER_ROLE, ELECTORAL_DISTRICT_REPORT_VIEWER_ROLE,
NATIONAL_REPORT_VERIFIER_ROLE, NATIONAL_REPORT_VIEWER_ROLE, EC_LEADERSHIP_ROLE]
NATIONAL_REPORT_VERIFIER_ROLE, NATIONAL_REPORT_VIEWER_ROLE, EC_LEADERSHIP_ROLE, EC_LEADERSHIP_WRITE_ROLE]

JWT_TOKEN_HEADER_KEY = "X-Jwt-Assertion"
132 changes: 66 additions & 66 deletions auth/RoleBasedAccess.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,76 +78,76 @@
}

role_to_write_allowed_tallysheet_types = {
DATA_EDITOR_ROLE: [
TallySheetCodeEnum.PRE_41,
TallySheetCodeEnum.CE_201,
TallySheetCodeEnum.CE_201_PV,
TallySheetCodeEnum.PRE_34_CO
]
# DATA_EDITOR_ROLE: [
# TallySheetCodeEnum.PRE_41,
# TallySheetCodeEnum.CE_201,
# TallySheetCodeEnum.CE_201_PV,
# TallySheetCodeEnum.PRE_34_CO
# ]
}

role_to_lock_allowed_tallysheet_types = {
DATA_EDITOR_ROLE: [
TallySheetCodeEnum.PRE_41,
TallySheetCodeEnum.CE_201,
TallySheetCodeEnum.CE_201_PV,
TallySheetCodeEnum.PRE_34_CO
],
POLLING_DIVISION_REPORT_VERIFIER_ROLE: [
TallySheetCodeEnum.PRE_30_PD,
TallySheetCodeEnum.PRE_34_I_RO,
TallySheetCodeEnum.PRE_34_PD
],
ELECTORAL_DISTRICT_REPORT_VERIFIER_ROLE: [
TallySheetCodeEnum.PRE_30_PD,
TallySheetCodeEnum.PRE_30_ED,
TallySheetCodeEnum.PRE_34_I_RO,
TallySheetCodeEnum.PRE_34_II_RO,
TallySheetCodeEnum.PRE_34,
TallySheetCodeEnum.PRE_34_PD,
TallySheetCodeEnum.PRE_34_ED
],
NATIONAL_REPORT_VERIFIER_ROLE: [
TallySheetCodeEnum.PRE_ALL_ISLAND_RESULTS,
TallySheetCodeEnum.PRE_ALL_ISLAND_RESULTS_BY_ELECTORAL_DISTRICTS,
TallySheetCodeEnum.PRE_34_AI
]
# DATA_EDITOR_ROLE: [
# TallySheetCodeEnum.PRE_41,
# TallySheetCodeEnum.CE_201,
# TallySheetCodeEnum.CE_201_PV,
# TallySheetCodeEnum.PRE_34_CO
# ],
# POLLING_DIVISION_REPORT_VERIFIER_ROLE: [
# TallySheetCodeEnum.PRE_30_PD,
# TallySheetCodeEnum.PRE_34_I_RO,
# TallySheetCodeEnum.PRE_34_PD
# ],
# ELECTORAL_DISTRICT_REPORT_VERIFIER_ROLE: [
# TallySheetCodeEnum.PRE_30_PD,
# TallySheetCodeEnum.PRE_30_ED,
# TallySheetCodeEnum.PRE_34_I_RO,
# TallySheetCodeEnum.PRE_34_II_RO,
# TallySheetCodeEnum.PRE_34,
# TallySheetCodeEnum.PRE_34_PD,
# TallySheetCodeEnum.PRE_34_ED
# ],
# NATIONAL_REPORT_VERIFIER_ROLE: [
# TallySheetCodeEnum.PRE_ALL_ISLAND_RESULTS,
# TallySheetCodeEnum.PRE_ALL_ISLAND_RESULTS_BY_ELECTORAL_DISTRICTS,
# TallySheetCodeEnum.PRE_34_AI
# ]
}

role_to_unlock_allowed_tallysheet_types = {
POLLING_DIVISION_REPORT_VERIFIER_ROLE: [
TallySheetCodeEnum.PRE_41,
TallySheetCodeEnum.CE_201,
TallySheetCodeEnum.CE_201_PV,
TallySheetCodeEnum.PRE_34_CO
],
ELECTORAL_DISTRICT_REPORT_VERIFIER_ROLE: [
TallySheetCodeEnum.PRE_41,
TallySheetCodeEnum.CE_201_PV,
TallySheetCodeEnum.PRE_34_CO,
],
NATIONAL_REPORT_VERIFIER_ROLE: [
TallySheetCodeEnum.PRE_30_PD,
TallySheetCodeEnum.PRE_30_ED,
TallySheetCodeEnum.PRE_34_I_RO,
TallySheetCodeEnum.PRE_34_II_RO,
TallySheetCodeEnum.PRE_34,
# TallySheetCodeEnum.PRE_ALL_ISLAND_RESULTS,
# TallySheetCodeEnum.PRE_ALL_ISLAND_RESULTS_BY_ELECTORAL_DISTRICTS,
TallySheetCodeEnum.PRE_34_PD,
TallySheetCodeEnum.PRE_34_ED,
TallySheetCodeEnum.PRE_34_AI
],
EC_LEADERSHIP_ROLE: [
TallySheetCodeEnum.PRE_30_PD,
TallySheetCodeEnum.PRE_30_ED,
TallySheetCodeEnum.PRE_34_I_RO,
TallySheetCodeEnum.PRE_34_II_RO,
TallySheetCodeEnum.PRE_34,
TallySheetCodeEnum.PRE_ALL_ISLAND_RESULTS,
TallySheetCodeEnum.PRE_ALL_ISLAND_RESULTS_BY_ELECTORAL_DISTRICTS,
TallySheetCodeEnum.PRE_34_PD,
TallySheetCodeEnum.PRE_34_ED,
TallySheetCodeEnum.PRE_34_AI
]
# POLLING_DIVISION_REPORT_VERIFIER_ROLE: [
# TallySheetCodeEnum.PRE_41,
# TallySheetCodeEnum.CE_201,
# TallySheetCodeEnum.CE_201_PV,
# TallySheetCodeEnum.PRE_34_CO
# ],
# ELECTORAL_DISTRICT_REPORT_VERIFIER_ROLE: [
# TallySheetCodeEnum.PRE_41,
# TallySheetCodeEnum.CE_201_PV,
# TallySheetCodeEnum.PRE_34_CO,
# ],
# NATIONAL_REPORT_VERIFIER_ROLE: [
# TallySheetCodeEnum.PRE_30_PD,
# TallySheetCodeEnum.PRE_30_ED,
# TallySheetCodeEnum.PRE_34_I_RO,
# TallySheetCodeEnum.PRE_34_II_RO,
# TallySheetCodeEnum.PRE_34,
# # TallySheetCodeEnum.PRE_ALL_ISLAND_RESULTS,
# # TallySheetCodeEnum.PRE_ALL_ISLAND_RESULTS_BY_ELECTORAL_DISTRICTS,
# TallySheetCodeEnum.PRE_34_PD,
# TallySheetCodeEnum.PRE_34_ED,
# TallySheetCodeEnum.PRE_34_AI
# ],
# EC_LEADERSHIP_ROLE: [
# TallySheetCodeEnum.PRE_30_PD,
# TallySheetCodeEnum.PRE_30_ED,
# TallySheetCodeEnum.PRE_34_I_RO,
# TallySheetCodeEnum.PRE_34_II_RO,
# TallySheetCodeEnum.PRE_34,
# TallySheetCodeEnum.PRE_ALL_ISLAND_RESULTS,
# TallySheetCodeEnum.PRE_ALL_ISLAND_RESULTS_BY_ELECTORAL_DISTRICTS,
# TallySheetCodeEnum.PRE_34_PD,
# TallySheetCodeEnum.PRE_34_ED,
# TallySheetCodeEnum.PRE_34_AI
# ]
}

0 comments on commit 4ad55c7

Please sign in to comment.