[BACK-AUTH-05] Implementation of B2B Token Validation Endpoint for External Stores
Authorization Microservice (AuthService)
NoteTask Brief
- Repository / Component:
auth_service(Go). - Stack: Go, PostgreSQL (Stores / Tokens Tables).
- Task Type: Backend (API & Access).
- Status: Ready for Implementation
Task Description
As part of moving away from hardcoded tokens for B2B integrations (partner stores), it is necessary to implement an internal endpoint (gRPC/HTTP) that will be invoked by the process service to verify the token validity of a specific store.
Step-by-Step Instructions
- Designing the B2B Data Schema (Migration): Create (or extend) the
b2b_partners / storestable in the authorization database with the following fields:store_id(UUID / INT) — unique identifier of the store.b2b_token(VARCHAR, Indexed) — hashed or strict access token.status(VARCHAR:ACTIVE,SUSPENDED).
- Creating the Verification Endpoint: Implement the
POST /v1/auth/b2b/validatemethod (or a gRPC methodValidateStoreToken). - Developing the Validation Logic:
- Accept
b2b_tokenas input. - Execute a query against the database. If the token is not found, return a
401 Unauthorizedstatus / gRPCUNAUTHENTICATED. - If the store’s status is
SUSPENDED(blocked), return aSTORE_BLOCKEDerror. - If the store is active (
ACTIVE), return200 OKand a metadata structure:{"store_id": 105, "store_name": "Pyaterochka"}.
- Accept