Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for namespaces #27

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ docs/KeyRestrictions.md
docs/KeyType.md
docs/LogLevel.md
docs/LoggingConfig.md
docs/NamespaceItem.md
docs/NetworkConfig.md
docs/Pcr.md
docs/PrivateKey.md
Expand Down Expand Up @@ -73,6 +74,7 @@ src/models/key_type.rs
src/models/log_level.rs
src/models/logging_config.rs
src/models/mod.rs
src/models/namespace_item.rs
src/models/network_config.rs
src/models/pcr.rs
src/models/private_key.rs
Expand Down
2 changes: 1 addition & 1 deletion .openapi-generator/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.6.0-SNAPSHOT
7.8.0-SNAPSHOT
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@

## Unreleased

### Features

- Add support for namespaces by adding the `namespaces_get`, `namespaces_namespace_id_delete`, `namespaces_namespace_id_put`, `users_user_id_post` API calls

### Bugfixes

- Return `Error::ResponseError` instead of `Error::Transport` for API errors ([#21](https://github.com/Nitrokey/nethsm-sdk-rs/issues/21))
- Fix multipart requests, namely `system_restore_post` ([#20](https://github.com/Nitrokey/nethsm-sdk-rs/issues/20))
- Add authentication for `system_restore_post` ([#15](https://github.com/Nitrokey/nethsm-sdk-rs/issues/15))

### Changes
### Other Changes

- Add `AkPub` and `Pcr` schemas

Expand Down
136 changes: 129 additions & 7 deletions docs/DefaultApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ Method | HTTP request | Description
[**keys_post**](DefaultApi.md#keys_post) | **POST** /keys |
[**lock_post**](DefaultApi.md#lock_post) | **POST** /lock |
[**metrics_get**](DefaultApi.md#metrics_get) | **GET** /metrics |
[**namespaces_get**](DefaultApi.md#namespaces_get) | **GET** /namespaces |
[**namespaces_namespace_id_delete**](DefaultApi.md#namespaces_namespace_id_delete) | **DELETE** /namespaces/{NamespaceID} |
[**namespaces_namespace_id_put**](DefaultApi.md#namespaces_namespace_id_put) | **PUT** /namespaces/{NamespaceID} |
[**provision_post**](DefaultApi.md#provision_post) | **POST** /provision |
[**random_post**](DefaultApi.md#random_post) | **POST** /random |
[**system_backup_post**](DefaultApi.md#system_backup_post) | **POST** /system/backup |
Expand All @@ -58,6 +61,7 @@ Method | HTTP request | Description
[**users_user_id_delete**](DefaultApi.md#users_user_id_delete) | **DELETE** /users/{UserID} |
[**users_user_id_get**](DefaultApi.md#users_user_id_get) | **GET** /users/{UserID} |
[**users_user_id_passphrase_post**](DefaultApi.md#users_user_id_passphrase_post) | **POST** /users/{UserID}/passphrase |
[**users_user_id_post**](DefaultApi.md#users_user_id_post) | **POST** /users/{UserID} |
[**users_user_id_put**](DefaultApi.md#users_user_id_put) | **PUT** /users/{UserID} |
[**users_user_id_tags_get**](DefaultApi.md#users_user_id_tags_get) | **GET** /users/{UserID}/tags |
[**users_user_id_tags_tag_delete**](DefaultApi.md#users_user_id_tags_tag_delete) | **DELETE** /users/{UserID}/tags/{Tag} |
Expand Down Expand Up @@ -610,7 +614,7 @@ No authorization required
> crate::models::CreateResourceId keys_generate_post(key_generate_request_data)


Generate a pair of public and private key and store it in NetHSM. KeyID is optional as a parameter and will be generated by NetHSM if not present.
Generate a pair of public and private key and store it in NetHSM. KeyID is optional as a parameter and will be generated by NetHSM if not present. The key is stored in the caller's namespace.

### Parameters

Expand Down Expand Up @@ -640,7 +644,7 @@ Name | Type | Description | Required | Notes
> Vec<crate::models::KeyItem> keys_get(filter)


Get a list of the identifiers of all keys that are currently stored in NetHSM. Separate requests need to be made to request the individual key data.
Get a list of the identifiers of all keys that are currently stored in NetHSM. If the caller is in a namespace, only keys in that namespace are returned. Separate requests need to be made to request the individual key data.

### Parameters

Expand Down Expand Up @@ -944,7 +948,7 @@ Name | Type | Description | Required | Notes
> keys_key_id_put(key_id, private_key)


Import a private key into NetHSM and store it under the *KeyID* path. The public key will be automatically derived. The parameters of the key can be passed as a PEM file or a JSON object.
Import a private key into NetHSM and store it under the *KeyID* path. The public key will be automatically derived. The parameters of the key can be passed as a PEM file or a JSON object. The key is stored in the caller's namespace.

### Parameters

Expand Down Expand Up @@ -1068,7 +1072,7 @@ Name | Type | Description | Required | Notes
> crate::models::CreateResourceId keys_post(private_key)


Import a private key into NetHSM and let NetHSM generate a KeyID. The public key will be automatically derived. The parameters of the key can be passed as a PEM file or a JSON object.
Import a private key into NetHSM and let NetHSM generate a KeyID. The public key will be automatically derived. The parameters of the key can be passed as a PEM file or a JSON object. The key is stored in the caller's namespace.

### Parameters

Expand Down Expand Up @@ -1147,6 +1151,93 @@ This endpoint does not need any parameter.
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)


## namespaces_get

> Vec<crate::models::NamespaceItem> namespaces_get()


Get a list of all created namespaces. Note that users may be assigned namespaces not present in this list, as long as the namespace has not been created.

### Parameters

This endpoint does not need any parameter.

### Return type

[**Vec<crate::models::NamespaceItem>**](NamespaceItem.md)

### Authorization

[basic](../README.md#basic)

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: application/json

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)


## namespaces_namespace_id_delete

> namespaces_namespace_id_delete(namespace_id)


Delete a namespace. **WARNING: all keys from that namespace are deleted.**

### Parameters


Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**namespace_id** | **String** | | [required] |

### Return type

(empty response body)

### Authorization

[basic](../README.md#basic)

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: Not defined

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)


## namespaces_namespace_id_put

> namespaces_namespace_id_put(namespace_id)


Create a namespace on keyfender. All users in that namespace can now be used, and all user management power is delegated to admins in that namespace.

### Parameters


Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**namespace_id** | **String** | | [required] |

### Return type

(empty response body)

### Authorization

[basic](../README.md#basic)

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: Not defined

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)


## provision_post

> provision_post(provision_request_data)
Expand Down Expand Up @@ -1492,7 +1583,7 @@ No authorization required
> Vec<crate::models::UserItem> users_get()


Get a list of all user ids that have accounts on NetHSM.
Get a list of all user ids that have accounts on NetHSM. If the caller is in a namespace, return only users in that namespace.

### Parameters

Expand All @@ -1519,7 +1610,7 @@ This endpoint does not need any parameter.
> crate::models::CreateResourceId users_post(user_post_data)


Create a new user on NetHSM. The user-ID is generated by NetHSM.
Create a new user on NetHSM, inheriting the caller's namespace. The user-ID is generated by NetHSM.

### Parameters

Expand Down Expand Up @@ -1635,12 +1726,43 @@ Name | Type | Description | Required | Notes
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)


## users_user_id_post

> crate::models::CreateResourceId users_user_id_post(user_id, user_post_data)


Create a new user on NetHSM, in the namespace specified as a prefix in the path with the format 'namespace~'. For example, a POST request on \"https://nethsm.local/v1/users/namespace1~\" will generate a user-ID and create that user in \"namespace1\". The namespace prefix *must* be present: for creating users without a namespace, use a POST on \"/v1/users\".

### Parameters


Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**user_id** | **String** | | [required] |
**user_post_data** | [**UserPostData**](UserPostData.md) | | [required] |

### Return type

[**crate::models::CreateResourceId**](CreateResourceId.md)

### Authorization

[basic](../README.md#basic)

### HTTP request headers

- **Content-Type**: application/json
- **Accept**: application/json

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)


## users_user_id_put

> users_user_id_put(user_id, user_post_data)


Create a user on keyfender.
Create a user on keyfender. The new user must either be in the same namespace as the caller, or be in a namespace not created yet if the caller has no namespace.

### Parameters

Expand Down
11 changes: 11 additions & 0 deletions docs/NamespaceItem.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# NamespaceItem

## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **String** | |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


Loading
Loading