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

🔒 Update auth requirements for tenant-admin and governance roles #633

Merged
merged 7 commits into from
Feb 6, 2024

Conversation

ff137
Copy link
Collaborator

@ff137 ff137 commented Jan 29, 2024

Endpoints that can only be called by tenant-admins and governance were previously authed under the hood to use the correct API keys.

Now the API keys are inferred from the auth provided in the request, and will return unauthorized if a tenant-admin or governance request does not provide the correct API key for the multitenant or governance agent, respectively.

To-do:

  • there is one hacky workaround that uses tenant-admin internally to fetch a label for a verifier wallet, in case the verifier is not found on the trust registry. Ideally we don't need a "default tenant admin" auth internally, so perhaps this workaround can be refactored
  • we use endorser controller internally in quite a few places, and this logic should be migrated to the endorser service, such that only the endorser service needs to know what the governance agent api key (cloudapi can then remove the env var for that key)

@ff137 ff137 self-assigned this Jan 29, 2024
@ff137 ff137 added the enhancement New feature or request label Jan 29, 2024
@ff137 ff137 requested review from cl0ete and wdbasson January 29, 2024 11:55
@ff137 ff137 marked this pull request as draft January 29, 2024 12:00
Copy link

Coverage

Coverage Report
FileStmtsMissCoverMissing
app
   main.py782667%71–74, 96, 98, 100, 104, 111, 137–142, 149–179
app/dependencies
   acapy_clients.py22291%26, 42
   auth.py561966%31, 37–38, 41, 52–55, 62–63, 68, 74–77, 81–84, 88–89, 94
   role.py34197%56
app/event_handling
   sse_listener.py40880%48–53, 72–77
   websocket_manager.py753257%32–38, 63–67, 86–89, 96–107, 114–124, 138
app/models
   issuer.py41295%34, 43
   tenants.py661380%93, 96, 105–115, 130–138
   verifier.py54885%30, 38–42, 79, 87–91
app/routes
   connections.py603935%26–40, 56–66, 80–94, 110–121, 140–147
   definitions.py2068360%79–136, 169–170, 247–248, 277–278, 288, 342–343, 353, 360–365, 397–445, 469–470, 509–579, 587–606
   issuer.py135894%63, 94, 154, 187, 204, 313, 326, 358
   jsonld.py624921%29–92, 103–141
   messaging.py21957%31–36, 56–63
   oob.py503236%27–66, 77–89, 113–123
   sse.py321553%37–43, 66–72, 99–107, 136–142, 173–184
   verifier.py1453278%58–60, 65, 103–105, 110, 152, 160–162, 167, 201–205, 214–216, 245–247, 253, 286–288, 293, 323–325, 359–361
   webhooks.py16475%30–34, 53–57
   websocket_endpoint.py18180%1–41
app/routes/admin
   tenants.py15012020%46–156, 165–189, 197–214, 224–234, 243–255, 265–305
app/routes/wallet
   credentials.py785431%31–40, 49–59, 68–78, 87–99, 110–122, 134–143, 152–162, 171–181
   dids.py752271%24–33, 50–51, 71–72, 84–91, 99–105
app/services
   acapy_ledger.py691874%50–51, 77–79, 118–119, 132–151, 204–205
   acapy_wallet.py40490%61–62, 96–97
   revocation_registry.py1202778%247–248, 311–316, 332–343, 352–367, 419–423
   sse.py715523%20–24, 36–49, 62–75, 91–108, 125–142, 160–183
   webhooks.py271833%14–24, 31–39
   websocket.py44440%1–79
app/services/issuer
   acapy_issuer_v1.py911386%31, 58–81, 162–163
   acapy_issuer_v2.py1032180%46–49, 69–103, 141, 187–188, 211
app/services/onboarding
   issuer.py38684%98–100, 117–119
   tenants.py624823%26–92, 102–132
   verifier.py36392%66, 82–86
app/services/onboarding/util
   register_issuer_did.py61789%83–85, 174–176, 191
   set_endorser_metadata.py693746%26–28, 46–48, 70–72, 103–120, 132–141, 153–164, 177–189
app/services/trust_registry
   actors.py107992%94–99, 109, 208–209, 211–216, 281–284
   schemas.py49492%56–61, 91–96
app/services/trust_registry/util
   actor.py31294%26–27
   issuer.py23483%39–40, 48–49
app/services/verifier
   acapy_verifier_v1.py1336849%35, 58–62, 73, 95–99, 104, 112, 136–140, 145, 158–168, 173–175, 181–195, 199–218, 222–234, 238–258
   acapy_verifier_v2.py1407447%38–43, 63–67, 79–84, 106–110, 115, 128–133, 147–151, 156, 169–181, 186–190, 196–210, 214–233, 237–251, 255–275
app/tests/admin
   test_onboarding.py85199%254
app/tests/e2e
   conftest.py23578%38–46
   test_credentials.py991189%96–130
   test_jsonld.py641675%133–168
   test_tenants.py2761395%153, 197–198, 226, 558, 592–593, 602–603, 615–616, 625–626
   test_trust_registry_integration.py63198%111
   test_verifier.py3059170%36, 488–507, 524–557, 574–606, 623–645, 669–723, 904–983
   test_wallet_dids.py671085%92–107
app/tests/issuer
   test_issuer.py160299%295–298
app/tests/services
   test_revocation_registry.py102694%72, 118, 153, 233, 277, 296
app/tests/util
   ecosystem_connections.py1352780%276–295, 312–332, 340–380
   ledger.py491080%34, 42, 54, 62–66, 76, 82
   member_acapy_clients.py36683%47–50, 65–66, 73–74
   trust_registry.py41393%26, 29–30
   webhooks.py25292%13, 57
app/tests/verifier
   utils.py1438938%174–188, 195–214, 226–263, 271–274, 280–291, 297–306, 311–364, 375–427, 440–466, 479–517, 531–569, 583–604, 615–631, 644–650, 664–680, 694–720
app/util
   acapy_issuer_utils.py18194%22
   acapy_verifier_utils.py1348239%40, 48–125, 156, 163–182, 186, 193–197, 205–209, 213–217, 224–254, 260–263
   credentials.py10460%8, 12–15
   retry_method.py16160%1–25
   tenants.py251348%12–19, 34–35, 42–49
endorser
   endorser_processor.py1624373%31–39, 55–56, 65–69, 127–131, 135–139, 162–174, 205–209, 212–216, 227–229, 234–235, 250–251, 261–265, 295–304
   main.py880%1–12
trustregistry
   crud.py17615214%15–30, 34–46, 50–62, 66–78, 82–141, 145–161, 165–194, 200–214, 218–228, 232–252, 256–283, 287–302
   db.py29969%11–15, 19–23
   list_type.py10460%9–12, 15
   main.py411563%23–32, 54–59, 64
trustregistry/registry
   registry_actors.py825829%19–22, 27–38, 45–65, 72–82, 89–99, 106–116, 121–127
   registry_schemas.py654038%24–27, 34–51, 58–92, 97–108, 113–119
webhooks
   models.py532651%37, 48–50, 54, 58, 62, 66, 71–81, 86–96, 125, 142
webhooks/dependencies
   redis_service.py74495%19, 207, 212–213
   sse_manager.py1763381%59–66, 111–121, 152–153, 166–180, 235–239, 245–248, 250–253, 278–279, 322–324, 358, 369–370
webhooks/routers
   receive_events.py32681%37–42, 57–61, 75–79
   sse.py16813718%34–38, 61–96, 121–154, 173–238, 260–301, 324–376
   webhooks.py30293%35, 62
webhooks/tests
   test_sse_manager.py128398%145–146, 152
webhooks/tests/e2e
   test_sse.py81495%121, 147–150
TOTAL8708201177% 

Tests Skipped Failures Errors Time
259 2 💤 16 ❌ 0 🔥 8m 27s ⏱️

Copy link

sonarqubecloud bot commented Feb 6, 2024

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

SECURITY.md Dismissed Show dismissed Hide dismissed
SECURITY.md Dismissed Show dismissed Hide dismissed
Copy link

github-actions bot commented Feb 6, 2024

Coverage

Coverage Report
FileStmtsMissCoverMissing
app
   main.py792667%72–75, 97, 99, 101, 105, 112, 138–143, 150–180
app/dependencies
   acapy_clients.py23291%33, 49
   auth.py561966%31, 37–38, 41, 52–55, 62–63, 68, 74–77, 81–84, 88–89, 94
   role.py34197%56
app/event_handling
   sse_listener.py40880%48–53, 72–77
   websocket_manager.py753257%32–38, 63–67, 86–89, 96–107, 114–124, 138
app/models
   issuer.py41295%34, 43
   tenants.py661380%93, 96, 105–115, 130–138
   verifier.py54885%30, 38–42, 79, 87–91
app/routes
   connections.py603935%26–40, 56–66, 80–94, 110–121, 140–147
   definitions.py2068360%79–136, 169–170, 247–248, 277–278, 288, 342–343, 353, 360–365, 397–445, 469–470, 509–579, 587–606
   issuer.py135894%63, 94, 154, 187, 204, 313, 326, 358
   jsonld.py624921%29–92, 103–141
   messaging.py21957%31–36, 56–63
   oob.py503236%27–66, 77–89, 113–123
   sse.py321553%37–43, 66–72, 99–107, 136–142, 173–184
   verifier.py1453278%58–60, 65, 103–105, 110, 152, 160–162, 167, 201–205, 214–216, 245–247, 253, 286–288, 293, 323–325, 359–361
   webhooks.py16475%30–34, 53–57
   websocket_endpoint.py18667%17–18, 27–28, 38–41
app/routes/admin
   tenants.py15012020%46–156, 165–189, 197–214, 224–234, 243–255, 265–305
app/routes/wallet
   credentials.py785431%31–40, 49–59, 68–78, 87–99, 110–122, 134–143, 152–162, 171–181
   dids.py752271%24–33, 50–51, 71–72, 84–91, 99–105
app/services
   acapy_ledger.py691874%50–51, 77–79, 118–119, 132–151, 204–205
   acapy_wallet.py40490%61–62, 96–97
   revocation_registry.py1202778%247–248, 311–316, 332–343, 352–367, 419–423
   sse.py715523%20–24, 36–49, 62–75, 91–108, 125–142, 160–183
   webhooks.py271833%14–24, 31–39
   websocket.py443423%19–22, 29–36, 45–79
app/services/issuer
   acapy_issuer_v1.py911386%31, 58–81, 162–163
   acapy_issuer_v2.py1032180%46–49, 69–103, 141, 187–188, 211
app/services/onboarding
   issuer.py38684%98–100, 117–119
   tenants.py624823%26–92, 102–132
   verifier.py36392%66, 82–86
app/services/onboarding/util
   register_issuer_did.py61789%83–85, 174–176, 191
   set_endorser_metadata.py693746%26–28, 46–48, 70–72, 103–120, 132–141, 153–164, 177–189
app/services/trust_registry
   actors.py107992%94–99, 109, 208–209, 211–216, 281–284
   schemas.py49492%56–61, 91–96
app/services/trust_registry/util
   actor.py31294%26–27
   issuer.py23483%39–40, 48–49
app/services/verifier
   acapy_verifier_v1.py1336849%35, 58–62, 73, 95–99, 104, 112, 136–140, 145, 158–168, 173–175, 181–195, 199–218, 222–234, 238–258
   acapy_verifier_v2.py1407447%38–43, 63–67, 79–84, 106–110, 115, 128–133, 147–151, 156, 169–181, 186–190, 196–210, 214–233, 237–251, 255–275
app/tests/admin
   test_onboarding.py85199%254
app/tests/e2e
   conftest.py23578%38–46
   test_credentials.py991189%96–130
   test_jsonld.py641675%133–168
   test_tenants.py2761395%153, 197–198, 226, 558, 592–593, 602–603, 615–616, 625–626
   test_trust_registry_integration.py63198%111
   test_verifier.py305199%36
   test_wallet_dids.py671085%92–107
app/tests/issuer
   test_issuer.py160299%295–298
app/tests/services
   test_revocation_registry.py102694%72, 118, 153, 233, 277, 296
app/tests/util
   ecosystem_connections.py1352780%276–295, 312–332, 340–380
   ledger.py491080%34, 42, 54, 62–66, 76, 82
   member_acapy_clients.py36683%47–50, 65–66, 73–74
   trust_registry.py41393%26, 29–30
   webhooks.py25292%13, 57
app/tests/verifier
   utils.py1438938%174–188, 195–214, 226–263, 271–274, 280–291, 297–306, 311–364, 375–427, 440–466, 479–517, 531–569, 583–604, 615–631, 644–650, 664–680, 694–720
app/util
   acapy_issuer_utils.py18194%22
   acapy_verifier_utils.py1348239%40, 48–125, 156, 163–182, 186, 193–197, 205–209, 213–217, 224–254, 260–263
   credentials.py10460%8, 12–15
   retry_method.py16160%1–25
   tenants.py251348%12–19, 34–35, 42–49
endorser
   endorser_processor.py1624373%31–39, 55–56, 65–69, 127–131, 135–139, 162–174, 205–209, 212–216, 227–229, 234–235, 250–251, 261–265, 295–304
   main.py880%1–12
trustregistry
   crud.py17615214%15–30, 34–46, 50–62, 66–78, 82–141, 145–161, 165–194, 200–214, 218–228, 232–252, 256–283, 287–302
   db.py29969%11–15, 19–23
   list_type.py10460%9–12, 15
   main.py411563%23–32, 54–59, 64
trustregistry/registry
   registry_actors.py825829%19–22, 27–38, 45–65, 72–82, 89–99, 106–116, 121–127
   registry_schemas.py654038%24–27, 34–51, 58–92, 97–108, 113–119
webhooks
   models.py532651%37, 48–50, 54, 58, 62, 66, 71–81, 86–96, 125, 142
webhooks/dependencies
   redis_service.py74495%19, 207, 212–213
   sse_manager.py1763381%59–66, 111–121, 152–153, 166–180, 235–239, 245–248, 250–253, 278–279, 322–324, 358, 369–370
webhooks/routers
   receive_events.py32681%37–42, 57–61, 75–79
   sse.py16813718%34–38, 61–96, 121–154, 173–238, 260–301, 324–376
   webhooks.py30293%35, 62
webhooks/tests
   test_sse_manager.py128398%145–146, 152
webhooks/tests/e2e
   test_sse.py81495%121, 147–150
TOTAL8710189978% 

Tests Skipped Failures Errors Time
259 2 💤 0 ❌ 0 🔥 8m 30s ⏱️

@ff137 ff137 merged commit e970f83 into development Feb 6, 2024
44 checks passed
@ff137 ff137 deleted the refactor-auth branch February 6, 2024 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants