HomePhabricator
Diffusion Comm 141c4d1346de

[comm-lib][reports] Extract 'authenticated' service trait

Description

[comm-lib][reports] Extract 'authenticated' service trait

Summary:

This diff is large, but smaller parts make no sense without each other.

Introduced two entities:

  • HttpAuthenticatedService trait - to be implemented by services like ReportsService or BlobServiceClient. They do require either CSAM (UserIdentity) or a service-to-service token to work (e.g. make blob calls). But they can still be used in unauthenticated endpoints.
  • Authenticated<S> extractor. This is to be used in HTTP handler functions to get an instance of an aforementioned service - see D12508 for example usage.

The business logic code (FromRequest impl) was already implemented for Reports service. I extracted it into
the above trait and made more flexible. Added lots of in-code comments to better understand.

In the next diff, this will be implemented for Backup service - D12508.

Depends on D12506

Test Plan:
Local reports service:

  • Upload report with valid CSAT - use it to get User ID and for blob service requests
  • Upload report with invalid CSAT - fallback to services-token
  • Upload report with no CSAT - service-to-service token was retrieved.

All reports were large enough to trigger Blob service uploads.

Reviewers: kamil, varun, will

Reviewed By: kamil, varun

Subscribers: ashoat, tomek

Differential Revision: https://phab.comm.dev/D12507

Details

Provenance
bartekAuthored on Wed, Jun 19, 11:32 PM
Reviewer
kamil
Differential Revision
D12507: [comm-lib][reports] Extract 'authenticated' service trait
Parents
rCOMM8a4928e1ee25: [comm-lib] Implement FromRequest for AuthService
Branches
Unknown
Tags
Unknown