OBP-API Documentation

repository·develop·Indexed 23 days ago

https://github.com/openbankproject/obp-api

A banking API platform featuring a Docker-based development environment with hot-reloading and Redis caching. The platform includes an ABAC (Attribute-Based Access Control) Rules Engine for dynamic access control using Scala functions, and supports mTLS reverse proxy topologies via Nginx for secure Third Party Provider (TPP) communication.

Tokens
122.4K
Snippets
197
Records
457
Agent score
83%

What's inside OBP-API

  1. Overview of Open Bank Project (OBP) capabilities

    develop

    The Open Bank Project (OBP) is an open-source RESTful API platform designed for banking compliance (PSD2, XS2A, Open Finance). It acts as a universal API layer that abstracts different core banking systems into a standardized interface.

    Core Capabilities

    • Banking Operations: Account management, real-time balances, transaction history, and multi-account support.
    • Payments: Support for SEPA, COUNTERPARTY, SANDBOX, FREE_FORM, ACCOUNT, and ACCOUNT_OTP transaction types. Includes features like Standing Orders, Direct Debits, and Maker/Checker workflows.
    • Customer & KYC: Comprehensive customer profiles, KYC document management, and PSD2-compliant consent workflows.
    • Security: Granular Role-Based Access Control (RBAC) with 334+ roles, Attribute-Based Access Control (ABAC), and multiple authentication modes (OAuth 2.0, OIDC, Direct Login).
    • Extensibility: Ability to define dynamic endpoints, custom data models (dynamic entities), and custom API documentation without code deployment.
    • Compliance: Support for multiple standards including Berlin Group NextGenPSD2, UK Open Banking, AU CDR, and more.
  2. Explore Open Bank Project Use Cases

    develop

    The Open Bank Project supports various financial service use cases. While the documentation is continuously expanding, key areas of focus include:

    • Variable Recurring Payments (VRP): Managing recurring payment consents and workflows.
    • Account Aggregation: Consolidating financial data from multiple sources.
    • Payment Initiation Services (PIS): Facilitating the movement of funds.
    • Account Information Services (AIS): Providing access to account data.
    • Confirmation of Funds (CoF): Verifying available balances.
    • Dynamic Consent Management: Managing user permissions dynamically.
    • Multi-Bank Operations: Handling transactions across different banking institutions.
  3. Understand the OBP Roadmap and development priorities

    develop

    The OBP Roadmap is a living document organized by Theme and Horizon rather than fixed dates. Development priorities are driven by three factors: Client demand, Regulation (the only source of fixed dates), and Technology shifts (e.g., AI/MCP).

    Horizons:

    • Active: Currently in active development.
    • Next: Committed direction, expected to start after current work or client engagement.
    • Later: On the radar; subject to being pulled forward by demand or regulation.

    For information on existing API functionality, refer to the API catalogs, glossary, and README. For architectural milestones that do not change API signatures, refer to completed_developments.md.

  4. Overview of the ABAC Rules Engine

    develop

    The ABAC (Attribute-Based Access Control) Rules Engine enables fine-grained, dynamic access control by executing Scala functions. It evaluates attributes belonging to users, banks, accounts, transactions, and customers to grant or deny access.

    Core Components

    • AbacRule: The data model for rule storage.
    • AbacRuleProvider: Handles CRUD operations for rules.
    • AbacRuleEngine: The core component responsible for compiling and executing Scala-based rules.
    • AbacRuleEndpoints: The REST API layer for managing and executing rules.
  5. What is OBP-Dispatch and how to run it

    develop

    OBP-Dispatch is a lightweight proxy/router designed to route API requests to different OBP-API implementations (e.g., routing traffic between the legacy Liftweb-based OBP-API, the new http4s-based v7.0.0 APIs, or OBP-Trading).

    It allows for seamless implementation migration and the ability to host different versions of the API under a single entry point.

    # Build
    mvn clean package
    
    # Run
    java -jar target/OBP-API-Dispatch-1.0-SNAPSHOT-jar-with-dependencies.jar
    
    # Docker
    docker run -p 8080:8080 \
      -v /path/to/application.conf:/config/application.conf \
      obp-dispatch:latest
  6. Understand Field-Level Permissions for Dynamic Entities

    develop

    Starting in v7.0.0, OBP Dynamic Entities support field-level read and write permissions. This allows you to restrict specific properties within an entity so that only users with specific roles can view or modify them.

    Key Concepts

    • Write Restriction: Fields marked with a writeRole or writeRoleRequired: true cannot be modified via POST or PUT. They can only be updated using the PATCH method by a caller possessing the required role.
    • Read Restriction: Fields marked with a readRole or readRoleRequired: true are omitted from the response in GET requests (both GET_ONE and GET_ALL) if the caller lacks the necessary role.
    • Role Generation: If writeRoleRequired is set to true without an explicit role name, the system auto-generates a role following the pattern: CanWriteDynamicEntityField_<EntityName>__<FieldName>.
    • Orthogonal Enforcement: Field-level roles work alongside existing entity-level permissions (like CanGet) and row-level scoping (like userId). You must satisfy both to access the data.
  7. Choose a Deployment Topology

    develop

    OBP-API supports two primary deployment models depending on your security and scale requirements:

    Single Server Deployment

    Best for simple setups or development. All components reside on one machine:

    • OBP-API (HTTP4S)
    • PostgreSQL
    • Redis

    Distributed Deployment with Akka Remote

    Designed for high-security environments (e.g., separating the DMZ from the Secure Zone). This requires extra licensing and configuration. It splits the system into:

    • API Layer (DMZ): Runs the OBP-API (HTTP Server) but has no direct database access.
    • Data Layer (Secure Zone): Runs the OBP-API (Connector) which manages access to PostgreSQL and Core Banking Systems.
    • Communication between layers is handled via Akka Remote.
  8. How Variable Recurring Payments (VRP) work

    develop

    Variable Recurring Payments (VRP) allow applications to make multiple payments to a specific beneficiary over time with varying amounts, governed by pre-defined limits. This is ideal for subscriptions, utilities, or loan repayments.

    VRP Workflow

    1. Application creates VRP Consent Request: Uses POST /consumer/vrp-consent-requests to specify the source account, destination account, and limits.
    2. OBP Automation: The system automatically generates a Custom View (e.g., _vrp-xxx), a Counterparty (the beneficiary), and Counterparty Limits.
    3. Account Holder finalizes consent: The user authorizes the request using Strong Customer Authentication (SCA) via POST /consumer/consent-requests/{CONSENT_REQUEST_ID}/{SCA_METHOD}/consents.
    4. Application initiates payments: The application uses the active consent to create transaction requests via POST /banks/{BANK_ID}/accounts/{ACCOUNT_ID}/{VIEW_ID}/transaction-request-types/COUNTERPARTY/transaction-requests.
    ┌─────────────────────────────────────────────────────────────────┐
    │  1. Application creates VRP Consent Request                     │
    │     POST /consumer/vrp-consent-requests                         │
    │     (Specifies: from_account, to_account, limits)               │
    └──────────────────────┬──────────────────────────────────────────┘
                           │
                           ▼
    ┌─────────────────────────────────────────────────────────────────┐
    │  2. OBP automatically creates:                                  │
    │     - Custom View (e.g., _vrp-xxx)                              │
    │     - Counterparty (beneficiary)                                │
    │     - Counterparty Limits                                        │
    └──────────────────────┬──────────────────────────────────────────┘
                           │
                           ▼
    ┌─────────────────────────────────────────────────────────────────┐
    │  3. Account Holder finalizes consent                            │
    │     POST /consumer/consent-requests/CONSENT_REQUEST_ID/         │
    │          IMPLICIT|EMAIL|SMS/consents                            │
    └──────────────────────┬──────────────────────────────────────────┘
                           │
                           ▼
    ┌─────────────────────────────────────────────────────────────────┐
    │  4. Application uses consent to create Transaction Requests     │
    │     POST /banks/BANK_ID/accounts/ACCOUNT_ID/VIEW_ID/            │
    │          transaction-request-types/COUNTERPARTY/                │
    │          transaction-requests                                    │
    │     (Multiple payments within limits)                           │
    └─────────────────────────────────────────────────────────────────┘
  9. Handle Option types safely in ABAC rules

    develop

    Most objects in the ABAC context (except authenticatedUser, authenticatedUserAttributes, and authenticatedUserAuthContext) are wrapped in Scala Option types.

    CRITICAL: Never call .get on an Option without first verifying it is defined, as this will throw a NoSuchElementException.

    Recommended Patterns:

    • Use .exists(condition) to check a property only if the object is present.
    • Use .map(property).getOrElse(default) to safely access values.
    • Use pattern matching (match { case Some(x) => ... }) for complex logic.
    • Use .forall(condition) for negative constraints.
  10. Enable per-field provenance for Dynamic Entities

    develop

    You can opt-in to tracking the 'who' and 'when' for specific fields within a Dynamic Entity (DE). When enabled, the server automatically stamps authoritative audit metadata for each write, and allows the writer to attach an opaque metadata object.

    To enable this, add the trackProvenance keyword to your field definition. Alternatively, you can use trackProvenanceAllFields: true at the entity level to enable it for every field in that entity.

    Note that trackProvenance is independent of access control; a field can be provenance-tracked regardless of whether it has restricted read or write roles.

  11. Configure Dynamic Entity indexing metadata

    develop

    When defining Dynamic Entities, you can specify which fields should be indexed to enable efficient querying. This is done via the indexed metadata in the entity definition.

    Supported Metadata Options:

    • indexed: true: Enables indexing for the field.
    • index: "scalar" | "spatial": Specifies the index type. The default is "scalar".
    • path: "a.b": Used for nested scalar fields (only applicable to scalar types).

    Validation Rules:

    • Spatial Indexing: index: "spatial" is only allowed on json fields (using GeoJSON).
    • Scalar Indexing: If indexed: true is used on a json field, it must use index: "spatial". Otherwise, the definition will be rejected.
    • Pathing: The path option is only valid when using a scalar type.
  12. Understand the Redis rate limiting data structure

    develop

    OBP-API uses Redis to track API call counts across different time windows.

    Key Format

    Rate limiting counters use the pattern {consumer_id}_{PERIOD}.

    • Authorized Consumers: Use their unique consumer_id (e.g., consumer_abc123_PER_MINUTE).
    • Anonymous Access: Uses the client's IP address (e.g., 192.168.1.100_PER_HOUR).

    Value Format

    Each key stores a string representation of the current call count (e.g., "42").

    Time-To-Live (TTL) Mapping

    Redis keys are automatically deleted when their TTL expires, resetting the window. The TTL is set to match the period duration:

    PeriodTTL (seconds)
    PER_SECOND1
    PER_MINUTE60
    PER_HOUR3,600
    PER_DAY86,400
    PER_WEEK604,800
    PER_MONTH2,592,000
    // Example keys
    consumer_abc123_PER_SECOND
    consumer_abc123_PER_MINUTE
    192.168.1.100_PER_HOUR