Skip to content

Commit 47f0b53

Browse files
authored
Merge pull request #254 from treeverse/fix-rbac-demo-after-fluffy-deprecation
Fix RBAC demo after deprecation of Fluffy
2 parents 20d00db + 9cce8ef commit 47f0b53

File tree

1 file changed

+72
-23
lines changed

1 file changed

+72
-23
lines changed

00_notebooks/rbac-demo.ipynb

Lines changed: 72 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@
5959
"cell_type": "code",
6060
"execution_count": null,
6161
"id": "dfa46799-5f86-4104-9447-d91328edbff4",
62-
"metadata": {},
62+
"metadata": {
63+
"tags": []
64+
},
6365
"outputs": [],
6466
"source": [
6567
"lakefsEndPoint = 'lakefs:8000' # e.g. 'https://username.aws_region_name.lakefscloud.io'\n",
@@ -80,7 +82,9 @@
8082
"cell_type": "code",
8183
"execution_count": null,
8284
"id": "25b151c2-743d-43e1-9f2f-25482967c207",
83-
"metadata": {},
85+
"metadata": {
86+
"tags": []
87+
},
8488
"outputs": [],
8589
"source": [
8690
"storageNamespace = 's3://example/' # e.g. \"s3://username-lakefs-cloud/\""
@@ -108,7 +112,9 @@
108112
"cell_type": "code",
109113
"execution_count": null,
110114
"id": "c6e3c546-98b9-4e4e-a9c0-c6737758ce20",
111-
"metadata": {},
115+
"metadata": {
116+
"tags": []
117+
},
112118
"outputs": [],
113119
"source": [
114120
"repo_name = \"rbac-repo\""
@@ -126,7 +132,9 @@
126132
"cell_type": "code",
127133
"execution_count": null,
128134
"id": "3b839850-5954-4631-8e7e-d0dee6d17dde",
129-
"metadata": {},
135+
"metadata": {
136+
"tags": []
137+
},
130138
"outputs": [],
131139
"source": [
132140
"sourceBranch = \"main\"\n",
@@ -281,7 +289,9 @@
281289
"cell_type": "code",
282290
"execution_count": null,
283291
"id": "49ed0e63-bcff-4858-a461-3764f108d049",
284-
"metadata": {},
292+
"metadata": {
293+
"tags": []
294+
},
285295
"outputs": [],
286296
"source": [
287297
"credentials = superUserClient.auth_api.create_credentials(user_id='admin1')\n",
@@ -335,7 +345,9 @@
335345
"cell_type": "code",
336346
"execution_count": null,
337347
"id": "3007f6a9-9b28-48a2-9028-810de0b4d5bf",
338-
"metadata": {},
348+
"metadata": {
349+
"tags": []
350+
},
339351
"outputs": [],
340352
"source": [
341353
"admin1Client.auth_api.get_current_user()"
@@ -481,7 +493,9 @@
481493
"cell_type": "code",
482494
"execution_count": null,
483495
"id": "d356d8b5-839d-4040-8f33-8e37fd4f8471",
484-
"metadata": {},
496+
"metadata": {
497+
"tags": []
498+
},
485499
"outputs": [],
486500
"source": [
487501
"DataScientistsGroup = admin1Client.auth_api.create_group(\n",
@@ -506,8 +520,21 @@
506520
},
507521
"outputs": [],
508522
"source": [
523+
"groupNameDataScientists='DataScientists'\n",
524+
"\n",
525+
"has_more = True\n",
526+
"next_offset = \"\"\n",
527+
"while has_more:\n",
528+
" groups = admin1Client.auth_api.list_groups(after=next_offset)\n",
529+
" for r in groups.results:\n",
530+
" if r.name == groupNameDataScientists:\n",
531+
" groupIdDataScientists = r.id\n",
532+
" break\n",
533+
" has_more = groups.pagination.has_more\n",
534+
" next_offset = groups.pagination.next_offset\n",
535+
" \n",
509536
"admin1Client.auth_api.attach_policy_to_group(\n",
510-
" group_id=DataScientistsGroup.id,\n",
537+
" group_id=groupIdDataScientists,\n",
511538
" policy_id='AuthManageOwnCredentials')"
512539
]
513540
},
@@ -523,11 +550,13 @@
523550
"cell_type": "code",
524551
"execution_count": null,
525552
"id": "822d7660-b4a9-489c-9812-6efb2bf9642a",
526-
"metadata": {},
553+
"metadata": {
554+
"tags": []
555+
},
527556
"outputs": [],
528557
"source": [
529558
"admin1Client.auth_api.attach_policy_to_group(\n",
530-
" group_id=DataScientistsGroup.id,\n",
559+
" group_id=groupIdDataScientists,\n",
531560
" policy_id='FSReadWriteAll')"
532561
]
533562
},
@@ -543,11 +572,13 @@
543572
"cell_type": "code",
544573
"execution_count": null,
545574
"id": "e53e3325-e641-4fa4-af61-e275898ba885",
546-
"metadata": {},
575+
"metadata": {
576+
"tags": []
577+
},
547578
"outputs": [],
548579
"source": [
549580
"admin1Client.auth_api.attach_policy_to_group(\n",
550-
" group_id=DataScientistsGroup.id,\n",
581+
" group_id=groupIdDataScientists,\n",
551582
" policy_id='RepoManagementReadAll')"
552583
]
553584
},
@@ -563,7 +594,9 @@
563594
"cell_type": "code",
564595
"execution_count": null,
565596
"id": "418de2f8-d477-4ced-bb7b-9e48af9cf093",
566-
"metadata": {},
597+
"metadata": {
598+
"tags": []
599+
},
567600
"outputs": [],
568601
"source": [
569602
"admin1Client.auth_api.create_user(\n",
@@ -583,11 +616,13 @@
583616
"cell_type": "code",
584617
"execution_count": null,
585618
"id": "23771e33-75f3-41a1-9abc-8c37d1aa09eb",
586-
"metadata": {},
619+
"metadata": {
620+
"tags": []
621+
},
587622
"outputs": [],
588623
"source": [
589624
"admin1Client.auth_api.add_group_membership(\n",
590-
" group_id=DataScientistsGroup.id,\n",
625+
" group_id=groupIdDataScientists,\n",
591626
" user_id='data_scientist1')"
592627
]
593628
},
@@ -603,7 +638,9 @@
603638
"cell_type": "code",
604639
"execution_count": null,
605640
"id": "c1d02624-1ad5-425f-a1fb-bf5b6190998f",
606-
"metadata": {},
641+
"metadata": {
642+
"tags": []
643+
},
607644
"outputs": [],
608645
"source": [
609646
"credentials = admin1Client.auth_api.create_credentials(user_id='data_scientist1')\n",
@@ -657,7 +694,9 @@
657694
"cell_type": "code",
658695
"execution_count": null,
659696
"id": "4a8e7a27-e66a-4fd1-9de1-b319c36a2446",
660-
"metadata": {},
697+
"metadata": {
698+
"tags": []
699+
},
661700
"outputs": [],
662701
"source": [
663702
"data_scientist1Client.auth_api.get_current_user()"
@@ -675,7 +714,9 @@
675714
"cell_type": "code",
676715
"execution_count": null,
677716
"id": "8b3e1c16-15d2-4a70-8d0a-959c8e15d28a",
678-
"metadata": {},
717+
"metadata": {
718+
"tags": []
719+
},
679720
"outputs": [],
680721
"source": [
681722
"admin1Client.auth_api.create_policy(\n",
@@ -703,11 +744,13 @@
703744
"cell_type": "code",
704745
"execution_count": null,
705746
"id": "b4e2964c-968a-476e-a636-8c2097181380",
706-
"metadata": {},
747+
"metadata": {
748+
"tags": []
749+
},
707750
"outputs": [],
708751
"source": [
709752
"admin1Client.auth_api.attach_policy_to_group(\n",
710-
" group_id=DataScientistsGroup.id,\n",
753+
" group_id=groupIdDataScientists,\n",
711754
" policy_id='FSBlockMergingToMain')"
712755
]
713756
},
@@ -723,7 +766,9 @@
723766
"cell_type": "code",
724767
"execution_count": null,
725768
"id": "d8af2c6b-2651-4d80-9efe-c5c6180419ed",
726-
"metadata": {},
769+
"metadata": {
770+
"tags": []
771+
},
727772
"outputs": [],
728773
"source": [
729774
"admin1Client.auth_api.create_policy(\n",
@@ -751,7 +796,9 @@
751796
"cell_type": "code",
752797
"execution_count": null,
753798
"id": "09968f0e-399c-4799-8dea-50d6e2c71c4d",
754-
"metadata": {},
799+
"metadata": {
800+
"tags": []
801+
},
755802
"outputs": [],
756803
"source": [
757804
"admin1Client.auth_api.attach_policy_to_group(\n",
@@ -793,7 +840,9 @@
793840
"cell_type": "code",
794841
"execution_count": null,
795842
"id": "2f7713d4-5b21-4f99-807e-447e9f5845c5",
796-
"metadata": {},
843+
"metadata": {
844+
"tags": []
845+
},
797846
"outputs": [],
798847
"source": [
799848
"admin1Client.repositories_api.set_branch_protection_rules(\n",

0 commit comments

Comments
 (0)