Skip to content

Commit d890106

Browse files
authored
docs: container temporary credentials (#6152)
* docs: Document container temporary credentials and identity integration feature This commit adds comprehensive documentation for the container temporary credentials feature introduced in the Container Orchestration Provider. The documentation covers: - Container Identity Integration feature in container-orchestration-provider-usage.md - Configuration parameters (Identity Integration Enabled, Container Permissions) - Detailed overview of how the feature works - Complete usage examples in Python, JavaScript, Shell Script - Best practices and troubleshooting guide - Updated container-orchestration-provider.md to list Identity Integration as a key feature - New how-to-use-temporary-identity-service.md for Java developers - TemporaryIdentityService API reference - Usage examples for OSGi bundles - Best practices and security considerations - Common use cases including container authentication - Updated authentication-and-authorization.md with new Temporary Identities section - Key characteristics of temporary identities - Differences from regular identities - API overview and usage example - Cross-references to related documentation - Updated mkdocs.yml navigation to include the new Java development guide The documentation provides developers and users with a complete understanding of how to leverage temporary credentials for secure container-to-Kura communication. * docs: update container identity integration auth details * docs: align temporary identity docs with current implementation * docs(container.provider): add firewall note for REST access from containers * Refactor usage examples for container orchestration Updated usage examples section to remove redundant examples and improve clarity. * docs(identity): align temporary identity auth docs with certificate and password support
1 parent ec77ff3 commit d890106

File tree

5 files changed

+321
-3
lines changed

5 files changed

+321
-3
lines changed

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

Lines changed: 116 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ To begin configuring the container, look under **Services** and select the item
9090

9191
- **Restart Container On Failure** - A boolean that tells the container engine to automatically restart the container when it has failed or shut down.
9292

93+
- **Identity Integration Enabled** - When enabled, Kura automatically creates a temporary identity with the specified permissions and provides the container with authentication credentials to access Kura's REST APIs. See [Container Identity Integration](#container-identity-integration) for more details.
94+
95+
- **Container Permissions (optional)** - A comma-separated list of permission names to grant to the container's temporary identity (e.g., `rest.system,rest.configuration`). This field is only used when **Identity Integration Enabled** is set to true. See [Container Identity Integration](#container-identity-integration) for available permissions and usage examples.
96+
9397
After specifying container parameters, ensure to set **Enabled** to **true** and press **Apply**. The container engine will then pull the respective image, spin up and start the container. If the gateway or the framework is power cycled, and the container and Container Orchestration Service are set to **enabled**, the framework will automatically start the container again upon startup.
9498

9599
![Container Orchestration Provider Container Configuration](./images/container-orchestration-provider-container-configuration.png)
@@ -141,6 +145,117 @@ The result should be a single line with all the existing options plus the new on
141145
!!! warning
142146
Modifying the bootloader options incorrectly may prevent the system from booting. Please ensure to back up any important data before making changes to these settings.
143147

148+
## Container Identity Integration
149+
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.
151+
152+
### Overview
153+
154+
When Identity Integration is enabled for a container instance, Kura performs the following operations:
155+
156+
1. **Creates a Temporary Identity**: A temporary, non-persistent identity is created specifically for the container with a unique name based on the container name (e.g., `container_myapp` for a container named `myapp`).
157+
158+
2. **Assigns Permissions**: The temporary identity is granted the permissions specified in the **Container Permissions** field.
159+
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
163+
- `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`)
164+
165+
4. **Automatic Cleanup**: When the container stops or is deleted, Kura automatically removes the temporary identity and invalidates its credentials.
166+
167+
### Features
168+
169+
- **Zero Configuration**: Containers automatically receive the correct REST API URL based on the gateway's HTTPS configuration and network mode.
170+
- **Network-Aware**: The REST base URL is automatically adjusted based on the container's networking mode (bridge, host, etc.).
171+
- **Secure**: Credentials are temporary and automatically invalidated when containers stop.
172+
- **Non-Persistent**: Temporary identities exist only in memory and are never persisted to disk.
173+
- **Permission-Based**: Fine-grained access control using Kura's existing permission system.
174+
175+
### Configuration
176+
177+
To enable Identity Integration for a container:
178+
179+
1. Set **Identity Integration Enabled** to `true`
180+
2. Specify the required permissions in **Container Permissions** field (comma-separated)
181+
3. Apply the configuration
182+
183+
To use the temporary credentials with REST APIs, ensure **Basic Authentication Enabled** is set to `true` in the **RestService** configuration.
184+
185+
The framework will create the temporary identity when the container starts and clean it up when the container stops.
186+
187+
### Available Permissions
188+
189+
For a complete list of available permissions, use the [REST Identity API](/references/rest-apis/rest-identity-api-v2/#get-defined-permissions) to query defined permissions in your system.
190+
191+
### Usage Example
192+
193+
#### Example: Container with Read-Only System Access
194+
195+
A monitoring container that needs to read system information but cannot modify configuration:
196+
197+
**Container Configuration:**
198+
- **Identity Integration Enabled**: `true`
199+
- **Container Permissions**: `rest.system`
200+
201+
**Container Code (Python):**
202+
```python
203+
import os
204+
import requests
205+
206+
# Read credentials from environment variables
207+
identity_name = os.environ.get('KURA_IDENTITY_NAME')
208+
identity_password = os.environ.get('KURA_IDENTITY_PASSWORD')
209+
base_url = os.environ.get('KURA_REST_BASE_URL')
210+
211+
# Make authenticated request to get system information
212+
response = requests.get(
213+
f'{base_url}/system/info',
214+
auth=(identity_name, identity_password)
215+
)
216+
if response.status_code == 200:
217+
system_info = response.json()
218+
print(f"System info: {system_info}")
219+
else:
220+
print(f"Failed to get system info: {response.status_code}")
221+
```
222+
223+
### Best Practices
224+
225+
1. **Principle of Least Privilege**: Only grant permissions that are absolutely necessary for the container's functionality.
226+
227+
2. **Validate Environment Variables**: Always check that `KURA_IDENTITY_NAME`, `KURA_IDENTITY_PASSWORD`, and `KURA_REST_BASE_URL` are present before making API calls.
228+
229+
3. **Handle Credential Lifecycle**: Be prepared for credentials to become invalid when the container is stopping or restarting.
230+
231+
4. **Error Handling**: Implement proper error handling for API calls, as permissions may be denied if the container doesn't have the required permission.
232+
233+
5. **Network Mode Considerations**: The REST base URL is automatically adjusted based on network mode:
234+
- **bridge mode** (default): Uses the Docker bridge gateway IP (typically `172.17.0.1`)
235+
- **host mode**: Uses `localhost`
236+
237+
6. **HTTPS Support**: The REST base URL automatically uses HTTPS if enabled in Kura's HTTP Service configuration.
238+
239+
### Troubleshooting
240+
241+
**Container cannot access Kura APIs:**
242+
- Verify that **Identity Integration Enabled** is set to `true`
243+
- Check that the container has been granted the necessary permissions in **Container Permissions**
244+
- Ensure the container is reading the environment variables correctly
245+
- If Kura firewall is installed and enabled, allow traffic from container networks (for example `docker0` or user-defined Docker bridges) to the Kura REST API port
246+
- Check container logs for authentication errors
247+
248+
**Basic authentication fails:**
249+
- Verify the request includes valid Basic credentials (`KURA_IDENTITY_NAME` / `KURA_IDENTITY_PASSWORD`)
250+
- Check that the temporary identity was created successfully in Kura logs
251+
- Ensure the container is using the correct REST base URL
252+
- Verify **Basic Authentication Enabled** is set to `true` in **RestService**
253+
254+
**Permission denied errors:**
255+
- Verify the permission name is correct (case-sensitive)
256+
- Ensure the permission exists in the system (use the REST Identity API to list defined permissions)
257+
- Check that the permission was correctly added to the **Container Permissions** field
258+
144259
## Stopping the container
145260

146261
!!! warning
@@ -152,4 +267,4 @@ To stop the container without deleting the component, set the **Enabled** field
152267

153268
## Container Management Dashboard
154269

155-
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.
270+
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.

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,14 @@
22

33
The Container Orchestration Provider allows Kura to manage Docker. With this tool, you can arbitrarily pull and deploy containerized software packages and run them on your gateway. This Service allows the user to create, configure, start, and stop containers all from the browser. The bundle will also restart containers if the gateway is restarted.
44

5-
The feature is composed of two bundles, one that exposes APIs for container management and one that implements those APIs. This API is exposed so that you can leverage it to implement containerization in your own Kura plugins.
5+
The feature is composed of two bundles, one that exposes APIs for container management and one that implements those APIs. This API is exposed so that you can leverage it to implement containerization in your own Kura plugins.
6+
7+
## Key Features
8+
9+
- **Container Lifecycle Management**: Create, start, stop, and manage Docker containers through Kura's web interface
10+
- **Image Management**: Pull images from Docker Hub or authenticated registries with automatic retry and timeout configuration
11+
- **Resource Control**: Configure CPU, memory, GPU allocation, and cgroup settings for containers
12+
- **Network Configuration**: Support for various Docker networking modes (bridge, host, custom networks)
13+
- **Security**: Container image signature verification and allowlist enforcement
14+
- **Identity Integration**: Automatic provisioning of temporary credentials for containers to securely access Kura's REST APIs
15+
- **Persistence**: Automatic container restart after gateway reboot if configured

docs/gateway-configuration/authentication-and-authorization.md

Lines changed: 97 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,102 @@ Starting from Kura 5.5 the following restrictions will be applied by the Identit
6767
- must be at least 3 and at most 255 characters long.
6868
- can only be composed by one or more sequences of alphanumeric characters (`[A-Za-z0-9]+`) separated by the dot symbol, the dot is not allowed at the beginning or at the end of the permission name (examples of valid permission names are `foo1.bAr`, `foo`, `a.b.c`).
6969

70+
## Temporary Identities
71+
72+
Kura 6 introduces temporary identity support in the **IdentityService**, a set of APIs for creating and managing temporary, non-persistent identities. Temporary identities are designed for short-lived authentication scenarios where identity persistence is not required.
73+
74+
### Key Characteristics
75+
76+
- **Non-Persistent**: Temporary identities exist only in memory and are never persisted to disk or configuration snapshots
77+
- **Authentication Flexibility**: Temporary identities can be used with the same authentication mechanisms supported by regular identities (for example password-based and certificate-based REST authentication, depending on RestService configuration)
78+
- **Automatic Lifecycle Management**: Temporary identities can be programmatically created and deleted as needed
79+
- **Permission-Based Authorization**: Temporary identities support the same permission model as regular identities
80+
81+
### Primary Use Case: Container Identity Integration
82+
83+
The main use case for temporary identities is the **Container Identity Integration** feature, which automatically provisions authentication credentials for containerized applications. When a container is configured with identity integration enabled:
84+
85+
1. Kura creates a temporary identity with the specified permissions
86+
2. Generates a temporary password for the identity
87+
3. Provides the identity name and password to the container via environment variables
88+
4. Automatically cleans up the temporary identity when the container stops
89+
90+
This allows containers to securely access Kura's REST APIs without manual credential configuration or exposing persistent credentials. Container Identity Integration provisions password credentials, so password-based REST authentication requires **Basic Authentication Enabled** in the **RestService** configuration. Temporary identities can also be used with certificate-based REST authentication when certificate authentication is enabled and the certificate CN matches the identity name.
91+
92+
### Temporary Identity API
93+
94+
Temporary identities are managed through the `IdentityService` APIs using an `IdentityConfiguration` and a lifetime:
95+
96+
#### Create Temporary Identity
97+
```java
98+
void createTemporaryIdentity(IdentityConfiguration configuration, Duration lifetime)
99+
```
100+
Creates a temporary identity with the given configuration and lifetime.
101+
102+
#### Delete Temporary Identity
103+
```java
104+
boolean deleteIdentity(String identityName)
105+
```
106+
Deletes a temporary identity by name (also works for regular identities).
107+
108+
### Usage Example
109+
110+
```java
111+
import java.time.Duration;
112+
import java.util.Arrays;
113+
import java.util.Optional;
114+
import org.eclipse.kura.identity.IdentityConfiguration;
115+
import org.eclipse.kura.identity.IdentityService;
116+
import org.eclipse.kura.identity.Permission;
117+
import org.eclipse.kura.identity.PasswordConfiguration;
118+
import org.eclipse.kura.identity.AssignedPermissions;
119+
120+
// Create temporary identity with specific permissions
121+
Set<Permission> permissions = new HashSet<>();
122+
permissions.add(new Permission("rest.system"));
123+
permissions.add(new Permission("rest.configuration"));
124+
125+
final String identityName = "container_myapp";
126+
final char[] password = "temporary-password".toCharArray();
127+
128+
PasswordConfiguration passwordConfiguration = new PasswordConfiguration(false, true, Optional.of(password), Optional.empty());
129+
AssignedPermissions assignedPermissions = new AssignedPermissions(permissions);
130+
IdentityConfiguration configuration = new IdentityConfiguration(
131+
identityName,
132+
Arrays.asList(passwordConfiguration, assignedPermissions)
133+
);
134+
135+
identityService.createTemporaryIdentity(configuration, Duration.ofHours(1));
136+
137+
// Identity name and password can now be used for REST API authentication
138+
139+
// Clean up when no longer needed
140+
identityService.deleteIdentity(identityName);
141+
```
142+
143+
### Differences from Regular Identities
144+
145+
| Aspect | Regular Identity | Temporary Identity |
146+
|--------|-----------------|-------------------|
147+
| Persistence | Stored in configuration snapshots | Memory only, never persisted |
148+
| Authentication | Password-based and certificate-based | Password-based and certificate-based |
149+
| Lifecycle | Manual creation/deletion via UI or API | Programmatic creation/deletion |
150+
| Use Case | Long-term user accounts | Short-lived service authentication |
151+
| Management | Web UI, REST API, MQTT | Java API only |
152+
153+
### Security Considerations
154+
155+
- Temporary identities follow the same permission model as regular identities
156+
- Passwords and client certificates should be treated as sensitive credentials and not logged or persisted
157+
- Temporary identities are automatically removed from memory when deleted
158+
- Best practice: delete temporary identities as soon as they are no longer needed
159+
160+
### Further Reading
161+
162+
- [Container Identity Integration](../core-services/container-orchestration-provider-usage.md#container-identity-integration) - Detailed guide on using temporary identities with containers
163+
- [How to Use Temporary Identities](../java-application-development/how-to-use-temporary-identity-service.md) - Developer guide for using IdentityService temporary identity APIs
164+
- [REST Identity API](../references/rest-apis/rest-identity-api-v2.md) - REST APIs for identity management (regular identities only)
165+
70166
## UserAdmin persistence
71167

72168
The `org.eclipse.kura.internal.useradmin.store.RoleRepositoryStoreImpl` Kura service allows to persist the UserAdmin state in Kura configuration snapshot, this includes the defined identities and permissions.
@@ -216,4 +312,4 @@ Example:
216312
"name": "kura.permission.kura.wires.admin",
217313
"basicMembers": ["kura.user.appadmin"]
218314
}
219-
```
315+
```
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# How to Use Temporary Identities
2+
3+
Temporary identities are short-lived, non-persistent identities created in memory. They are intended for scenarios such as containerized applications that need limited access to Kura REST APIs without storing long-term credentials.
4+
5+
## Overview
6+
7+
Temporary identities are managed through the `IdentityService` using an `IdentityConfiguration` and a lifetime:
8+
9+
- A temporary identity is created with an `IdentityConfiguration` and assigned permissions.
10+
- The identity exists only in memory and is removed explicitly or when the lifetime expires.
11+
- REST access can use password-based or certificate-based authentication, depending on RestService configuration.
12+
13+
## API Reference
14+
15+
### Create Temporary Identity
16+
17+
```java
18+
void createTemporaryIdentity(IdentityConfiguration configuration, Duration lifetime)
19+
```
20+
21+
Creates a temporary identity with the given configuration and lifetime.
22+
23+
### Delete Identity
24+
25+
```java
26+
boolean deleteIdentity(String identityName)
27+
```
28+
29+
Deletes a temporary identity by name (also works for regular identities).
30+
31+
## Usage Example
32+
33+
```java
34+
import java.time.Duration;
35+
import java.util.Arrays;
36+
import java.util.HashSet;
37+
import java.util.Optional;
38+
import java.util.Set;
39+
40+
import org.eclipse.kura.identity.AssignedPermissions;
41+
import org.eclipse.kura.identity.IdentityConfiguration;
42+
import org.eclipse.kura.identity.IdentityService;
43+
import org.eclipse.kura.identity.Permission;
44+
import org.eclipse.kura.identity.PasswordConfiguration;
45+
46+
public class TemporaryIdentityExample {
47+
48+
private IdentityService identityService;
49+
50+
public void createTemporaryIdentity() throws Exception {
51+
Set<Permission> permissions = new HashSet<>();
52+
permissions.add(new Permission("rest.system"));
53+
permissions.add(new Permission("rest.configuration"));
54+
55+
String identityName = "container_myapp";
56+
char[] password = "temporary-password".toCharArray();
57+
58+
PasswordConfiguration passwordConfiguration = new PasswordConfiguration(
59+
false,
60+
true,
61+
Optional.of(password),
62+
Optional.empty()
63+
);
64+
65+
AssignedPermissions assignedPermissions = new AssignedPermissions(permissions);
66+
IdentityConfiguration configuration = new IdentityConfiguration(
67+
identityName,
68+
Arrays.asList(passwordConfiguration, assignedPermissions)
69+
);
70+
71+
identityService.createTemporaryIdentity(configuration, Duration.ofHours(1));
72+
73+
// Use identityName and password to access REST APIs via Basic auth
74+
}
75+
76+
public void cleanupTemporaryIdentity() throws Exception {
77+
identityService.deleteIdentity("container_myapp");
78+
}
79+
}
80+
```
81+
82+
## REST Authentication Example
83+
84+
```bash
85+
curl -k -u "${KURA_IDENTITY_NAME}:${KURA_IDENTITY_PASSWORD}" \
86+
"${KURA_REST_BASE_URL}/system/info"
87+
```
88+
89+
Basic authentication must be enabled in the **RestService** configuration for password-based access. Certificate-based access requires certificate authentication to be enabled and a client certificate whose CN matches the temporary identity name.
90+
91+
## Best Practices
92+
93+
1. **Least Privilege**: Grant only the permissions required by the application.
94+
2. **Short Lifetimes**: Use the minimum lifetime needed for the use case.
95+
3. **Cleanup**: Delete temporary identities when they are no longer needed.
96+
4. **Secrets Handling**: Do not log or persist temporary passwords.

0 commit comments

Comments
 (0)