Authentication and Authorization
Understanding the security model
CoreBanq implements a robust, multi-layered security model to ensure that only authorized users can access the API and perform actions on resources. This document outlines the authentication and authorization process.
Authentication
Authentication in CoreBanq is handled using JSON Web Tokens (JWT). Here’s the process:
- A user submits their credentials - user id (usually email) and password to the
/authenticate
endpoint. - If the credentials are valid, the server generates a JWT token.
- This token should be included in the
Authorization
header of subsequent requests as a Bearer token.
Authorization
Once authenticated, the system performs several checks to authorize each API request:
- Rate Limiting: Checks if the request rate exceeds defined limits.
- API Access: Verifies if the user (or their roles) has permission to call the specific API endpoint.
- Record Access: For data operations, checks if the user has the appropriate CRUD permissions for the specific record.
API Endpoint Registration
All API endpoints are registered in the database. This allows for centralized management of API access control.
Record Type Registration
All record types (e.g., users, customers, accounts) are registered in the database. This facilitates fine-grained access control at the record level.
Permission Checks
For each API call, the system performs the following checks in order:
- Rate Limiting: Checks against general rules for public endpoints and specific rules stored in the database for private endpoints.
- Public Endpoint: If it’s a public endpoint (e.g.,
/authenticate
), no further checks are needed. - Token Validation: For private endpoints, validates the Bearer token.
- API Access: Checks if the user is granted access to execute this API.
- Record Access: For data operations, verifies if the user is granted the specific action (Create, Read, Update, Delete) on the record. A special
CanReadAll
flag determines if record filtering should be applied.
This multi-layered approach ensures that each request is thoroughly vetted before being processed, maintaining the security and integrity of the system.