0012: Targeted API Authentication and Authorization
STATUS
Accepted
CONTEXT
AdAction wants to enable publishers to have secure access to the Targeted API.
Considered Options
- Amazon Cognito and Laravel Sanctum - DECISION
- Single Internal Admin Key and Laravel Sanctum
Option 1: Amazon Cognito and Laravel Sanctum
Description
Integrating Amazon Cognito involves installing and implementing an SDK in the Publisher Dashboard, Targeted API service, and Offer API service. It also requires setting up Laravel Sanctum in the Targeted API service.
Data Flow
Because this option will be iteratively implemented, the data flow will be broken down into phases.
PHASE 1
The first phase will assume Laravel Sanctum only, mimicking the current Offer API authentication integration.
Registering a Targeted API Property
Requesting Targeted Offers
PHASE 2
Because this phase involves refactoring the current flow for registering and authenticating a publisher, sequence diagrams for these data flows is included below. And, because the Offer API is a dependency of the Targeted API, Amazon Cognito can be integrated into the authorization flow for creating and recreating Offer API tokens before integrating Cognito into the Targeted API authorization flow (this will also be part of the process for moving the Offer API out of beta). Diagrams for this refactored sequence are also included.
Registering a Publisher
Authenticating a Publisher
Registering an Offer API Property
Regenerating a Token for an Offer API Property
PHASE 3
Now that the Offer API has integrated Amazon Cognito, the Targeted API can follow suit. Sequence diagrams for these refactored data flows are included below.
Registering a Targeted API Property
Regenerating a Token for a Targeted API Property
Requesting Targeted Offers
Pros
- Sets up a more streamlined authentication and authorization processes for AdGem services.
- Adopts OAuth standards.
- Makes managing user identity and access easier.
Cons
- The scope of implementation would include the publisher dashboard.
Option 2: Single Internal Admin Key and Laravel Sanctum
Description
Integrating this option in the Targeted API involves duplicating the same authentication logic implemented in the Offer API. It also requires setting up Laravel Sanctum in the Targeted API service.
Pros
- Faster implementation because the scope does not include the publisher dashboard.
Cons
- AdGem services remain segregated in their authentication/authorization processes.
- Does not adopt OAuth standards.
DECISION
Choosing option 1 (Amazon Cognito and Laravel Sanctum) would result in more secure authentication/authorization practices for the Targeted API, as well as the publisher dashboard and Offer API (and beyond to other AdGem services in the future).
It also makes access management easier.
CONSEQUENCES
To execute option 1, the publisher dashboard authentication will need to be refactored.
Risks
The pub dashboard will need to be updated to use Amazon Cognito for its authentication, as well as updated to communicate with the Targeted and Offer APIs to retrieve security tokens.
NOTES
References
- PR #49: docs(AGPI-1081): creates draft of Targeted API Authentication adr
- PR #68: fix: Flatten indexes of docs to prep for auto-index merge
- PR #127: docs: backfill PR reference links for existing ADRs
- PR #182: docs(adr): normalize STATUS sections to valid template values
Original Author
Micah Wierenga