Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

19673 - Create eft_staff role to access EFT shortname functionality #2711

Merged
merged 6 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion auth-api/src/auth_api/resources/v1/org.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ def search_organizations():
@bp.route('/simple', methods=['GET', 'OPTIONS'])
@cross_origin(origins='*', methods=['GET'])
@TRACER.trace()
@validate_roles(allowed_roles=[Role.MANAGE_EFT.value, Role.SYSTEM.value])
@_jwt.has_one_of_roles(
[Role.SYSTEM.value, Role.STAFF_VIEW_ACCOUNTS.value])
[Role.SYSTEM.value, Role.MANAGE_EFT.value])
def search_simple_orgs():
"""Return simplified organization information."""
current_app.logger.info('<search_simple_orgs')
Expand Down
1 change: 1 addition & 0 deletions auth-api/src/auth_api/utils/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Role(Enum):
GOV_ACCOUNT_USER = 'gov_account_user'
ANONYMOUS_USER = 'anonymous_user'
ACCOUNT_IDENTITY = 'account_identity'
MANAGE_EFT = 'manage_eft'

SYSTEM = 'system'
TESTER = 'tester'
Expand Down
2 changes: 1 addition & 1 deletion auth-api/tests/unit/api/test_simple_org.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def test_simple_org_search(client, jwt, session, keycloak_mock): # pylint:disab
type_code=OrgType.PREMIUM.value,
status_code=OrgStatus.ACTIVE.value).save()

headers = factory_auth_header(jwt=jwt, claims=TestJwtClaims.staff_view_accounts_role)
headers = factory_auth_header(jwt=jwt, claims=TestJwtClaims.manage_eft_role)

# Assert status filter by inactive orgs
rv = client.get(f'/api/v1/orgs/simple?status={OrgStatus.INACTIVE.value}',
Expand Down
17 changes: 17 additions & 0 deletions auth-api/tests/utilities/factory_scenarios.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,23 @@ class TestJwtClaims(dict, Enum):
'loginSource': LoginSource.STAFF.value
}

manage_eft_role = {
'iss': CONFIG.JWT_OIDC_TEST_ISSUER,
'sub': 'f7a4a1d3-73a8-4cbc-a40f-bb1145302064',
'idp_userid': 'f7a4a1d3-73a8-4cbc-a40f-bb1145302064',
'firstname': fake.first_name(),
'lastname': fake.last_name(),
'preferred_username': fake.user_name(),
'realm_access': {
'roles': [
'staff',
'view_accounts',
'manage_eft'
]
},
'loginSource': LoginSource.STAFF.value
}

staff_admin_dir_search_role = {
'iss': CONFIG.JWT_OIDC_TEST_ISSUER,
'sub': 'f7a4a1d3-73a8-4cbc-a40f-bb1145302064',
Expand Down
4 changes: 2 additions & 2 deletions auth-web/src/routes/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ export function getRoutes (): RouteConfig[] {
path: '/pay/manage-shortnames',
name: 'manage-shortnames',
component: ShortNameMappingView,
meta: { requiresAuth: true, allowedRoles: [Role.Staff] }, // TODO rewire this in #19673
meta: { requiresAuth: true, allowedRoles: [Role.ManageEft] },
props: true
},
{
Expand All @@ -810,7 +810,7 @@ export function getRoutes (): RouteConfig[] {
component: ShortNameDetailsView,
meta: {
requiresAuth: true,
allowedRoles: [Role.Staff],
allowedRoles: [Role.ManageEft],
breadcrumb: [
StaffDashboardBreadcrumb,
ShortNameMappingBreadcrumb,
Expand Down
3 changes: 2 additions & 1 deletion auth-web/src/util/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ export enum Role {
GOVMAccountUser = 'gov_account_user',
ManageGlCodes = 'manage_gl_codes',
FasSearch = 'fas_search',
ViewAllTransactions = 'view_all_transactions'
ViewAllTransactions = 'view_all_transactions',
ManageEft = 'manage_eft'
}

export enum Pages {
Expand Down
Loading