Skip to content

Commit 2b77d0e

Browse files
committed
docs: update container identity integration auth details
1 parent e8939f6 commit 2b77d0e

1 file changed

Lines changed: 33 additions & 28 deletions

File tree

docs/core-services/container-orchestration-provider-usage.md

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ The result should be a single line with all the existing options plus the new on
147147

148148
## Container Identity Integration
149149

150-
The Container Identity Integration feature allows containers to securely authenticate and interact with Kura's REST APIs using temporary credentials. When enabled, Kura automatically manages authentication tokens for containers, eliminating the need for manual credential configuration.
150+
The Container Identity Integration feature allows containers to securely authenticate and interact with Kura's REST APIs using temporary credentials. When enabled, Kura automatically provisions a temporary identity and provides password-based credentials to the container, eliminating the need for manual credential configuration.
151151
152152
### Overview
153153
@@ -157,17 +157,18 @@ When Identity Integration is enabled for a container instance, Kura performs the
157157
158158
2. **Assigns Permissions**: The temporary identity is granted the permissions specified in the **Container Permissions** field.
159159
160-
3. **Provides Credentials**: The container receives two environment variables:
161-
- `KURA_IDENTITY_TOKEN`: The authentication token for accessing Kura's REST APIs
160+
3. **Provides Credentials**: The container receives the following environment variables:
161+
- `KURA_IDENTITY_NAME`: The temporary identity name for accessing Kura's REST APIs
162+
- `KURA_IDENTITY_PASSWORD`: The temporary password for accessing Kura's REST APIs
162163
- `KURA_REST_BASE_URL`: The complete base URL for Kura's REST API endpoints (e.g., `http://172.17.0.1:8080/services` or `https://172.17.0.1:443/services`)
163164

164-
4. **Automatic Cleanup**: When the container stops or is deleted, Kura automatically removes the temporary identity and invalidates the token.
165+
4. **Automatic Cleanup**: When the container stops or is deleted, Kura automatically removes the temporary identity and invalidates its credentials.
165166

166167
### Features
167168

168169
- **Zero Configuration**: Containers automatically receive the correct REST API URL based on the gateway's HTTPS configuration and network mode.
169170
- **Network-Aware**: The REST base URL is automatically adjusted based on the container's networking mode (bridge, host, etc.).
170-
- **Secure**: Tokens are temporary and automatically invalidated when containers stop.
171+
- **Secure**: Credentials are temporary and automatically invalidated when containers stop.
171172
- **Non-Persistent**: Temporary identities exist only in memory and are never persisted to disk.
172173
- **Permission-Based**: Fine-grained access control using Kura's existing permission system.
173174
@@ -179,6 +180,8 @@ To enable Identity Integration for a container:
179180
2. Specify the required permissions in **Container Permissions** field (comma-separated)
180181
3. Apply the configuration
181182
183+
To use the temporary credentials with REST APIs, ensure **Basic Authentication Enabled** is set to `true` in the **RestService** configuration.
184+
182185
The framework will create the temporary identity when the container starts and clean it up when the container stops.
183186
184187
### Available Permissions
@@ -221,15 +224,15 @@ import os
221224
import requests
222225
223226
# Read credentials from environment variables
224-
token = os.environ.get('KURA_IDENTITY_TOKEN')
227+
identity_name = os.environ.get('KURA_IDENTITY_NAME')
228+
identity_password = os.environ.get('KURA_IDENTITY_PASSWORD')
225229
base_url = os.environ.get('KURA_REST_BASE_URL')
226230
227231
# Make authenticated request to get system information
228-
headers = {
229-
'Authorization': f'Bearer {token}'
230-
}
231-
232-
response = requests.get(f'{base_url}/system/info', headers=headers)
232+
response = requests.get(
233+
f'{base_url}/system/info',
234+
auth=(identity_name, identity_password)
235+
)
233236
if response.status_code == 200:
234237
system_info = response.json()
235238
print(f"System info: {system_info}")
@@ -249,14 +252,16 @@ A deployment automation container that can read and update configurations:
249252
```javascript
250253
const axios = require('axios');
251254
252-
const token = process.env.KURA_IDENTITY_TOKEN;
255+
const identityName = process.env.KURA_IDENTITY_NAME;
256+
const identityPassword = process.env.KURA_IDENTITY_PASSWORD;
253257
const baseUrl = process.env.KURA_REST_BASE_URL;
254258
255-
// Configure axios with authentication header
259+
// Configure axios with basic authentication
256260
const api = axios.create({
257261
baseURL: baseUrl,
258-
headers: {
259-
'Authorization': `Bearer ${token}`
262+
auth: {
263+
username: identityName,
264+
password: identityPassword
260265
}
261266
});
262267
@@ -307,12 +312,13 @@ A network diagnostic container that monitors network status:
307312
#!/bin/bash
308313
309314
# Read credentials from environment
310-
TOKEN="${KURA_IDENTITY_TOKEN}"
315+
IDENTITY_NAME="${KURA_IDENTITY_NAME}"
316+
IDENTITY_PASSWORD="${KURA_IDENTITY_PASSWORD}"
311317
BASE_URL="${KURA_REST_BASE_URL}"
312318
313319
# Function to make authenticated API calls
314320
kura_api() {
315-
curl -s -H "Authorization: Bearer ${TOKEN}" "${BASE_URL}$1"
321+
curl -s -u "${IDENTITY_NAME}:${IDENTITY_PASSWORD}" "${BASE_URL}$1"
316322
}
317323
318324
# Get network interfaces status
@@ -341,17 +347,15 @@ import json
341347
342348
class KuraClient:
343349
def __init__(self):
344-
self.token = os.environ.get('KURA_IDENTITY_TOKEN')
350+
self.identity_name = os.environ.get('KURA_IDENTITY_NAME')
351+
self.identity_password = os.environ.get('KURA_IDENTITY_PASSWORD')
345352
self.base_url = os.environ.get('KURA_REST_BASE_URL')
346-
self.headers = {
347-
'Authorization': f'Bearer {self.token}',
348-
'Content-Type': 'application/json'
349-
}
353+
self.auth = (self.identity_name, self.identity_password)
350354
351355
def get(self, endpoint):
352356
"""Make authenticated GET request to Kura API"""
353357
url = f'{self.base_url}{endpoint}'
354-
response = requests.get(url, headers=self.headers)
358+
response = requests.get(url, auth=self.auth)
355359
response.raise_for_status()
356360
return response.json()
357361
@@ -406,9 +410,9 @@ while True:
406410
407411
1. **Principle of Least Privilege**: Only grant permissions that are absolutely necessary for the container's functionality.
408412

409-
2. **Validate Environment Variables**: Always check that `KURA_IDENTITY_TOKEN` and `KURA_REST_BASE_URL` are present before making API calls.
413+
2. **Validate Environment Variables**: Always check that `KURA_IDENTITY_NAME`, `KURA_IDENTITY_PASSWORD`, and `KURA_REST_BASE_URL` are present before making API calls.
410414

411-
3. **Handle Token Lifecycle**: Be prepared for the token to become invalid when the container is stopping or restarting.
415+
3. **Handle Credential Lifecycle**: Be prepared for credentials to become invalid when the container is stopping or restarting.
412416

413417
4. **Error Handling**: Implement proper error handling for API calls, as permissions may be denied if the container doesn't have the required permission.
414418
@@ -426,10 +430,11 @@ while True:
426430
- Ensure the container is reading the environment variables correctly
427431
- Check container logs for authentication errors
428432

429-
**Token authentication fails:**
430-
- Verify the token is being sent in the `Authorization` header as `Bearer <token>`
433+
**Basic authentication fails:**
434+
- Verify the request includes valid Basic credentials (`KURA_IDENTITY_NAME` / `KURA_IDENTITY_PASSWORD`)
431435
- Check that the temporary identity was created successfully in Kura logs
432436
- Ensure the container is using the correct REST base URL
437+
- Verify **Basic Authentication Enabled** is set to `true` in **RestService**
433438

434439
**Permission denied errors:**
435440
- Verify the permission name is correct (case-sensitive)
@@ -447,4 +452,4 @@ To stop the container without deleting the component, set the **Enabled** field
447452

448453
## Container Management Dashboard
449454

450-
The Container Orchestration service also provides the user with an intuitive container dashboard. This dashboard shows all containers running on a gateway, including containers created with the framework and those created manually through the command-line interface. To utilize this dashboard the `org.eclipse.container.orchestration.provider` (ContainerOrchestrationService) must be enabled, and the dashboard can be opened by navigating to Device > Containers.
455+
The Container Orchestration service also provides the user with an intuitive container dashboard. This dashboard shows all containers running on a gateway, including containers created with the framework and those created manually through the command-line interface. To utilize this dashboard the `org.eclipse.container.orchestration.provider` (ContainerOrchestrationService) must be enabled, and the dashboard can be opened by navigating to Device > Containers.

0 commit comments

Comments
 (0)