threefoldtech / tf-kyc-verifier

The TFGrid KYC Verifier is a robust identity verification service integrated with iDenfy to ensue secure and compliant user deployments on TFGrid cloud
Apache License 2.0
0 stars 0 forks source link

MVP: KYC Verification Core requirements #3

Open sameh-farouk opened 2 weeks ago

sameh-farouk commented 2 weeks ago

Description:

Implement TFGrid KYC Verifier, a REST API service that integrates with Idenfy to verify users' identities (KYC) before they can access certain functionalities on the TFGrid platform. The service should securely manage the user verification process, store verification results, and expose endpoints for querying a user's verification status. It will act as the source of truth for user verification on TFGrid, enabling other tools to determine what a user can do on the grid.

Related issue:

Functional Requirements:

  1. KYC Verifier Core Endpoints:

    • Token Generation Endpoint: Accepts the user ID (typically the user's public key on TFChain, with proof such as a signature) and generates a token for the verification process.
    • Webhook Endpoint: Receives verification data from Idenfy, including both intermediate and final results.
    • Verification Status Query: Allows checking a user's verification status, which can be verified, unverified, rejected, or pending.
    • Data Retrieval: Enables users to access their verification data.
  2. Token Management:

    • Prevent users from generating new tokens until the final verification result is received via the webhook or until the existing token has expired, to conserve credit usage.
  3. Handling Suspicion:

    • Configure the system to consider a user as verified if their verification status is marked as "suspected," but individual components like the document and face are approved. This should be the default behavior.
  4. Spam Prevention:

    • Require users to maintain a minimum TFT balance before starting the KYC process, with the balance requirement being configurable.
    • Limit the number of requests (e.g., token generation) from a single IP address within a specified time frame to prevent spam attempts, temporarily blocking access if the limit is exceeded. Store the related data in a database (not in memory) to support running multiple instances of the service.
  5. Handling Document Expiration:

    • By default, users with expired documents should be considered unverified, but this setting should be configurable.

Non-Functional Requirements:

  1. Service Reliability:

    • The service must handle potential downtimes and be capable of recovering pending verifications once it is back online.
  2. Data Storage:

    • Store all data received through the webhook, even if it is extensive.
  3. Scalability:

    • The solution must be stateless and scalable to handle an increasing number of verification requests while optimizing credit usage. It should support 100 TPS per instance for querying verification status, though token generation throughput may be limited by Idenfy's service capacity.
  4. Validation:

    • Ensure that incoming webhook notifications are verified to prevent tampering.
  5. Security:

    • Endpoints must use TLS encryption
    • Secure webhook endpoints using IP whitelisting to prevent unauthorized access.
    • Prevent users who have successfully completed verification from initiating another verification.
    • Implement rate-limiting for requests from the same client ID to prevent abuse.

Next Steps:

xmonader commented 10 hours ago

Will handle the encryption transient only, not at rest.

sameh-farouk commented 3 hours ago

Update

a personal testing instance deployed here https://kyc1.gent01.dev.grid.tf/docs

Completed:

Core Endpoints:

Token Management:

Handling Suspicion:

Spam Prevention:

Data Storage:

Network Separation:

WIP

Core:

Security:

Service Reliability: