Skip to content

Commit ad609e8

Browse files
Copy changes
1 parent 8eac79b commit ad609e8

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

samples/authX-pro/create.ipynb

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
"\n",
99
"Sets up a more sophisticate authentication (authN) and authorization (authZ) combination for role-based access control (RBAC) to a mock API and its operations. \n",
1010
"\n",
11-
"This sample, compared to the simpler _AuthX_, introduces use of API Management Product and policy fragments to simplify and consolidate shared logic. When considering scaling, consider this as your starting point.\n",
12-
"\n",
1311
"⚙️ **Supported infrastructures**: All infrastructures\n",
1412
"\n",
1513
"⌚ **Expected *Run All* runtime (excl. infrastructure prerequisite): ~2-3 minutes**\n",
@@ -23,14 +21,25 @@
2321
"1. Experience how API Management policy fragments simplify shared logic.\n",
2422
"\n",
2523
"## 📝 Scenario\n",
24+
"This sample, compared to the simpler _AuthX_, introduces use of API Management Product and policy fragments to simplify and consolidate shared logic. When considering scaling, consider this as your starting point.\n",
2625
"\n",
27-
"This sample combines _authentication (authN)_ and _authorization (authZ)_ into _authX_. This scenario focuses on a Human Resources API that requires privileged role-based access to GET and to POST data. This is simplistic but shows the combination of authN and authZ.\n",
28-
"\n",
29-
"There are two personas at play:\n",
26+
"The same two personas from _AuthX_ are at play:\n",
3027
"\n",
3128
"- `HR Administrator` - holds broad rights to the API\n",
3229
"- `HR Associate` - has read-only permissions\n",
3330
"\n",
31+
"The API hierarchy is as follows:\n",
32+
"\n",
33+
"1. All APIs / global\n",
34+
" This is a great place to do authentication, but we refrain from doing it in the sample as to not affect other samples. \n",
35+
"1. HR Product\n",
36+
" Perform authentication and authorization for HR_Member in the JWT claims. Continue on success; otherwise, return 401.\n",
37+
"1. HR Employee & Benefits APIs\n",
38+
" Both APIs are associated with the HR Product. The API must be called in a product context.\n",
39+
"1. API Operations\n",
40+
" GET authorization must either satisfy an HR Administrator or HR Associate role\n",
41+
" POST authorization must satisfy an HR Administrator role..\n",
42+
"\n",
3443
"Both personas are part of an HR_Members group and may access the HR API Management Product. Subsequent access to the APIs and their operations must be granular.\n",
3544
"\n",
3645
"### 💡 Notes\n",
@@ -128,7 +137,9 @@
128137
"\n",
129138
"hr_product_name = 'hr'\n",
130139
"products: List[Product] = [\n",
131-
" Product(hr_product_name, 'Human Resources', 'Product for Human Resources APIs providing access to employee data, organizational structure, benefits information, and HR management services. Includes JWT-based authentication for HR members.', 'published', False, False, hr_product_xml)\n",
140+
" Product(hr_product_name, 'Human Resources', \n",
141+
" 'Product for Human Resources APIs providing access to employee data, organizational structure, benefits information, and HR management services. Includes JWT-based authentication for HR members.', \n",
142+
" 'published', False, False, hr_product_xml)\n",
132143
"]\n",
133144
"\n",
134145
"# 6) Define the APIs and their operations and policies\n",
@@ -137,13 +148,15 @@
137148
"hremployees_api_path = f'/{api_prefix}employees'\n",
138149
"hremployees_get = GET_APIOperation('Gets the employees', utils.read_policy_xml('./hr_get.xml'))\n",
139150
"hremployees_post = POST_APIOperation('Creates a new employee', utils.read_policy_xml('./hr_post.xml'))\n",
140-
"hremployees = API(f'{api_prefix}Employees', 'Employees Pro', hremployees_api_path, 'This is a Human Resources API for employee information', utils.read_policy_xml(DEFAULT_XML_POLICY_PATH), operations = [hremployees_get, hremployees_post], tags = tags, productNames = [hr_product_name])\n",
151+
"hremployees = API(f'{api_prefix}Employees', 'Employees Pro', hremployees_api_path, 'This is a Human Resources API for employee information', utils.read_policy_xml(DEFAULT_XML_POLICY_PATH), \n",
152+
" operations = [hremployees_get, hremployees_post], tags = tags, productNames = [hr_product_name], subscriptionRequired = True)\n",
141153
"\n",
142154
"# Benefits (HR)\n",
143155
"hrbenefits_api_path = f'/{api_prefix}benefits'\n",
144156
"hrbenefits_get = GET_APIOperation('Gets employee benefits', utils.read_policy_xml('./hr_get.xml'))\n",
145157
"hrbenefits_post = POST_APIOperation('Creates employee benefits', utils.read_policy_xml('./hr_post.xml'))\n",
146-
"hrbenefits = API(f'{api_prefix}Benefits', 'Benefits Pro', hrbenefits_api_path, 'This is a Human Resources API for employee benefits', utils.read_policy_xml(DEFAULT_XML_POLICY_PATH), operations = [hrbenefits_get, hrbenefits_post], tags = tags, productNames = [hr_product_name])\n",
158+
"hrbenefits = API(f'{api_prefix}Benefits', 'Benefits Pro', hrbenefits_api_path, 'This is a Human Resources API for employee benefits', utils.read_policy_xml(DEFAULT_XML_POLICY_PATH), \n",
159+
" operations = [hrbenefits_get, hrbenefits_post], tags = tags, productNames = [hr_product_name], subscriptionRequired = True)\n",
147160
"\n",
148161
"# APIs Array\n",
149162
"apis: List[API] = [hremployees, hrbenefits]\n",

samples/authX/create.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"- `HR Administrator` - holds broad rights to the API\n",
2929
"- `HR Associate` - has read-only permissions\n",
3030
"\n",
31-
"Both personas are part of an HR_Members group and may access the HR API Management Product. Subsequent access to the APIs and their operations must be granular.\n",
31+
"Both personas are part of an HR_Members group and may access the HR Employees API, but its operations permissions are more granular.\n",
3232
"\n",
3333
"### 💡 Notes\n",
3434
"\n",

0 commit comments

Comments
 (0)