Skip to content

Commit c1d25b1

Browse files
authored
chore: api keys document updates (#407)
1 parent 4593097 commit c1d25b1

File tree

1 file changed

+46
-8
lines changed

1 file changed

+46
-8
lines changed

docs/tutorials/2.devops/2.auth-and-access-control/0.api-keys.md

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,20 @@
22

33
## Introduction
44

5-
API Keys can be used by external applications to access DIAL Core resources such as models, applications, toolsets and routes. DIAL Core uses them for server-to-server authentication and access control. In this document, you can learn how to define API keys, give access to resources in DIAL and define access limits.
5+
API Keys can be used by external applications to access DIAL Core resources such as models, applications, toolsets and routes. DIAL Core uses them for server-to-server authentication and access control.
6+
7+
You can define API key in DIAL Admin and via a direct configuration of DIAL Core. This document describes how to add and configure API keys in DIAL Core.
8+
9+
> * Refer to [DIAL Admin](/docs/tutorials/3.admin/access-management-keys.md) to learn how to add and manage API keys via the administrator UI.
10+
> * Refer to [DIAL Core](https://github.com/epam/ai-dial-core/blob/development/docs/dynamic-settings/keys.md) to see the complete configuration example.
611
712
## Step 1: Define API Keys
813

914
To use API keys, you need to define them. API keys can be defined in DIAL Core dynamic settings and by DIAL administrators in [DIAL Admin](/docs/tutorials/3.admin/access-management-keys.md).
1015

1116
##### DIAL Core configuration
1217

13-
API keys can be defined in the `keys.<core_key>` section in the [DIAL Core configuration file](https://github.com/epam/ai-dial-core/blob/development/docs/dynamic-settings/keys.md).
18+
API keys can be defined in the `keys.<core_key>` section in the [aidial.config.json](https://github.com/epam/ai-dial-core/blob/development/sample/aidial.config.json) configuration file.
1419

1520
> Refer to [DIAL Core documentation](https://github.com/epam/ai-dial-core/blob/development/docs/dynamic-settings/keys.md) to get familiar with the description of the configuration parameters of API keys.
1621
@@ -39,16 +44,14 @@ Access control in DIAL rests upon the concept of Objects of access (what we prot
3944

4045
API Keys are Subjects used by external applications to access DIAL Core resources. DIAL Core uses them for server-to-server authentication and access control.
4146

47+
The configuration in the previous step gives access to a private space of API key and resources in the public space that are not limited by roles or available for a role `"myRole"`.
48+
4249
> * Refer to [Authentication](/docs/platform/3.core/1.auth-intro.md) to learn more about authentication in DIAL.
4350
> * Refer to [Access Control](/docs/platform/3.core/2.access-control-intro.md) to learn more about access control in DIAL.
4451
45-
The configuration in the previous step gives access to for a private space of API key and resources in the public space that are not limited by roles or available for a role `"myRole"`.
46-
47-
> Refer to [Access Control](/docs/platform/3.core/2.access-control-intro.md) to learn more about access control in DIAL.
48-
4952
##### DIAL Core configuration
5053

51-
To provide access to additional resources in DIAL Core, you need to associate the role assigned to the API key with specific resources. You can do this by adding the API key role to the `userRoles` parameter of a corresponding deployment in DIAL Core configuration.
54+
To provide access to additional resources in DIAL Core, you need to associate the role assigned to the API key with specific resources. You can do this by adding the API key role to the `userRoles` parameter of a corresponding deployment (e.g. application or AI model) in DIAL Core configuration.
5255

5356
In the following example, the `"myRole"` role is granted access to the `chat-gpt-35-turbo` language model. Using the same pattern, you can define user access to [applications](https://github.com/epam/ai-dial-core/blob/development/docs/dynamic-settings/applications.md), [toolset](https://github.com/epam/ai-dial-core/blob/development/docs/dynamic-settings/toolsets.md) and [routes](https://github.com/epam/ai-dial-core/blob/development/docs/dynamic-settings/routes.md).
5457

@@ -284,6 +287,40 @@ Sharing limits can be defined in the `roles.<role_name>.share` section of the DI
284287
}
285288
}
286289
```
290+
### IP Address Range
291+
292+
For security purposes, you can restrict the usage of API keys to certain networks by defining `allowedIpAddressRanges` with a list of allowed IP addresses in the `keys.<key_name>` section of the DIAL Core dynamic settings.
293+
294+
295+
##### DIAL Core configuration
296+
297+
> Refer to [DIAL Core documentation](https://github.com/epam/ai-dial-core/blob/development/docs/dynamic-settings/keys.md) to see configuration guidelines.
298+
299+
A list of allowed IP addresses can be defined in the `keys.<key_name>.allowedIpAddressRanges` section of the DIAL Core dynamic settings.
300+
301+
Any provided IP address (IPv4 or IPv6) must follow a CIDR notation in form of: `ip_address/prefix`, where
302+
303+
* `ip_address`: string representation of IP address.
304+
* `prefix`: number of consecutive leading 1 bits in the network mask.
305+
306+
```json
307+
"keys": {
308+
"myApiKey": {
309+
"project": "MyProject",
310+
"role": "myRole",
311+
"allowedIpAddressRanges": ["198.51.100.14/24", "2001:db8:1234::/48"]
312+
}
313+
},
314+
```
315+
316+
##### How it works
317+
318+
* **undefined**: Client from any IP address can use the API key.
319+
* `null ` (default): Client from any IP address can use the API key.
320+
* **empty list**: API key is not usable from any IP address.
321+
* **a list is defined**: Client from the specified IP addresses can use the API key.
322+
323+
If a client tries to access DIAL Core using the API key from an IP address which is out of the range, DIAL Core returns HTTP error code: `403(Forbidden) Access is forbidden from IP address {}`
287324

288325
## Full Configuration Example
289326

@@ -292,7 +329,8 @@ Sharing limits can be defined in the `roles.<role_name>.share` section of the DI
292329
"keys": {
293330
"myApiKey": { //API key
294331
"project": "MyProject",
295-
"role": "myRole" // the name of the role
332+
"role": "myRole", // the name of the role
333+
"allowedIpAddressRanges": ["198.51.100.14/24", "2001:db8:1234::/48"],
296334
}
297335
},
298336
"models": {

0 commit comments

Comments
 (0)