[BACK-AUTH-05] Implementation of B2B Token Validation Endpoint for External Stores

Authorization Microservice (AuthService)

Published

October 14, 2026

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

  1. Designing the B2B Data Schema (Migration): Create (or extend) the b2b_partners / stores table 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).
  2. Creating the Verification Endpoint: Implement the POST /v1/auth/b2b/validate method (or a gRPC method ValidateStoreToken).
  3. Developing the Validation Logic:
    • Accept b2b_token as input.
    • Execute a query against the database. If the token is not found, return a 401 Unauthorized status / gRPC UNAUTHENTICATED.
    • If the store’s status is SUSPENDED (blocked), return a STORE_BLOCKED error.
    • If the store is active (ACTIVE), return 200 OK and a metadata structure: {"store_id": 105, "store_name": "Pyaterochka"}.