Skip to content

Commit f2dd7cd

Browse files
committed
doc: approach for ACS
1 parent 71c8551 commit f2dd7cd

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
To build an access control system using Keycloak based on our resource model, here’s how we can approach this issue:
2+
3+
### 1. How should the access control system reflect in my APIs?
4+
5+
The APIs should reflect the access control system through the following mechanisms:
6+
7+
- **Resource-Based Access Control**: We can define each resource (User, Bank Account, FPAccountAccess, TPOAccountAccess) in Keycloak as a resource. Each resource should have associated scopes (e.g., `POST`, `GET`, `PUT`, `DELETE`).
8+
9+
- **Scopes and Permissions**: We can implement scopes for each resource. For example, a `Bank Account` resource could have scopes like `view`, `create`, `update`, and `delete`.
10+
11+
- **Endpoint Protection**: We can use Keycloak to protect our API endpoints. For example:
12+
- `GET /user` should require the `view` scope for the User resource.
13+
- `POST /bank-account` should require the `create` scope for the Bank Account resource.
14+
15+
- **Token Validation**: APIs should validate access tokens issued by Keycloak. This ensures that only users with the appropriate permissions can access certain endpoints.
16+
17+
### 2. How do we integrate the following access control schemes: PIN/TAN, API Key / OAuth2, Public key based access?
18+
19+
- **PIN/TAN**:
20+
- This can be implemented as an additional authentication layer. After the user logs in via OAuth2, prompt them for a PIN/TAN to authorize specific actions (like transactions).
21+
- Store and validate these codes securely, and link them to user sessions or actions.
22+
23+
- **API Key / OAuth2**:
24+
- We can use OAuth2 for user authentication and authorization. Each client application can be given an API Key which can be validated against Keycloak.
25+
- We can implement client credentials grant type for server-to-server communication where an API Key is used to obtain an access token.
26+
27+
- **Public Key Based Access**:
28+
- Use JWT (JSON Web Tokens) signed with a public/private key pair. Keycloak can be configured to sign tokens with a private key, and our APIs can verify these using the public key.
29+
- This ensures that tokens cannot be tampered with and provides a secure way to validate the identity of the requester.
30+
31+
### 3. What policies are great for this scenario?
32+
33+
- **Role-Based Access Control (RBAC)**: Define roles (e.g., Admin, User, TPP) and assign permissions based on these roles. This simplifies permission management.
34+
35+
- **Scope-Based Policies**: We could create policies that grant permissions based on the scopes required for each action. For example:
36+
- A policy that allows access to a resource if the user has the `view` scope for that resource.
37+
38+
- **Attribute-Based Access Control (ABAC)**: If our resources have attributes that affect access (e.g., user status, account type), we could implement policies that consider these attributes.
39+
40+
- **Time-Based Access Control**: If certain actions should only be allowed during specific times (e.g., banking hours), we could create time-based policies.
41+
42+
- **Contextual Policies**: We could use contextual information (e.g., IP address, device type) to enforce additional security measures.
43+
44+
### Implementation Steps
45+
46+
1. **Define Resources and Scopes**: Set up resources in Keycloak and define the necessary scopes.
47+
2. **Create Roles**: Establish roles and assign the appropriate permissions to each role.
48+
3. **Set Up Policies**: Implement the policies mentioned above in Keycloak.
49+
4. **Configure Client Applications**: Ensure that client applications are set up to use OAuth2 and can handle access tokens appropriately.
50+
5. **Test and Validate**: Thoroughly test the access control implementation to ensure that it meets our security requirements.
51+

0 commit comments

Comments
 (0)