Add authentication

This commit is contained in:
Quentin 2022-09-12 17:13:43 +02:00
parent 82769b6dbb
commit b916cc1b32
Signed by: quentin
GPG key ID: E9602264D639FF68
9 changed files with 217 additions and 59 deletions

View file

@ -1,6 +1,5 @@
.gitignore
.gitlab-ci.yml
.openapi-generator-ignore
.travis.yml
README.md
docs/ClusterLayout.md
@ -55,22 +54,4 @@ setup.cfg
setup.py
test-requirements.txt
test/__init__.py
test/test_cluster_layout.py
test/test_connect_post200_response_inner.py
test/test_key_api.py
test/test_key_get_request.py
test/test_key_id_access_key_delete_request.py
test/test_key_id_access_key_delete_request_allow.py
test/test_key_import_post_request.py
test/test_key_info.py
test/test_key_info_buckets_inner.py
test/test_key_info_buckets_inner_permissions.py
test/test_key_info_permissions.py
test/test_layout_api.py
test/test_layout_version.py
test/test_list_keys200_response_inner.py
test/test_membership_api.py
test/test_node_cluster_info.py
test/test_node_network_info.py
test/test_status_get200_response.py
tox.ini

View file

@ -64,6 +64,15 @@ configuration = openapi_client.Configuration(
host = "http://localhost:3903/v0"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure Bearer authorization: bearerAuth
configuration = openapi_client.Configuration(
access_token = 'YOUR_BEARER_TOKEN'
)
# Enter a context with an instance of the API client
@ -126,7 +135,11 @@ Class | Method | HTTP request | Description
## Documentation For Authorization
All endpoints do not require authorization.
## bearerAuth
- **Type**: Bearer authentication
## Author

View file

@ -22,6 +22,7 @@ Imports an existing API key. This feature must only be used for migrations and b
### Example
* Bearer Authentication (bearerAuth):
```python
import time
@ -36,9 +37,18 @@ configuration = openapi_client.Configuration(
host = "http://localhost:3903/v0"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure Bearer authorization: bearerAuth
configuration = openapi_client.Configuration(
access_token = 'YOUR_BEARER_TOKEN'
)
# Enter a context with an instance of the API client
with openapi_client.ApiClient() as api_client:
with openapi_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = key_api.KeyApi(api_client)
key_import_post_request = KeyImportPostRequest(
@ -70,7 +80,7 @@ Name | Type | Description | Notes
### Authorization
No authorization required
[bearerAuth](../README.md#bearerAuth)
### HTTP request headers
@ -97,6 +107,7 @@ Creates a new API access key.
### Example
* Bearer Authentication (bearerAuth):
```python
import time
@ -111,9 +122,18 @@ configuration = openapi_client.Configuration(
host = "http://localhost:3903/v0"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure Bearer authorization: bearerAuth
configuration = openapi_client.Configuration(
access_token = 'YOUR_BEARER_TOKEN'
)
# Enter a context with an instance of the API client
with openapi_client.ApiClient() as api_client:
with openapi_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = key_api.KeyApi(api_client)
key_get_request = KeyGetRequest(
@ -143,7 +163,7 @@ Name | Type | Description | Notes
### Authorization
No authorization required
[bearerAuth](../README.md#bearerAuth)
### HTTP request headers
@ -168,6 +188,7 @@ Delete a key
### Example
* Bearer Authentication (bearerAuth):
```python
import time
@ -180,9 +201,18 @@ configuration = openapi_client.Configuration(
host = "http://localhost:3903/v0"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure Bearer authorization: bearerAuth
configuration = openapi_client.Configuration(
access_token = 'YOUR_BEARER_TOKEN'
)
# Enter a context with an instance of the API client
with openapi_client.ApiClient() as api_client:
with openapi_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = key_api.KeyApi(api_client)
access_key = "GK31c2f218a2e44f485b94239e" # str | The exact API access key generated by Garage
@ -208,7 +238,7 @@ void (empty response body)
### Authorization
No authorization required
[bearerAuth](../README.md#bearerAuth)
### HTTP request headers
@ -234,6 +264,7 @@ Return information about a specific key and return its information
### Example
* Bearer Authentication (bearerAuth):
```python
import time
@ -247,9 +278,18 @@ configuration = openapi_client.Configuration(
host = "http://localhost:3903/v0"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure Bearer authorization: bearerAuth
configuration = openapi_client.Configuration(
access_token = 'YOUR_BEARER_TOKEN'
)
# Enter a context with an instance of the API client
with openapi_client.ApiClient() as api_client:
with openapi_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = key_api.KeyApi(api_client)
access_key = "GK31c2f218a2e44f485b94239e" # str | The exact API access key generated by Garage
@ -276,7 +316,7 @@ Name | Type | Description | Notes
### Authorization
No authorization required
[bearerAuth](../README.md#bearerAuth)
### HTTP request headers
@ -302,6 +342,7 @@ Updates information about the specified API access key.
### Example
* Bearer Authentication (bearerAuth):
```python
import time
@ -316,9 +357,18 @@ configuration = openapi_client.Configuration(
host = "http://localhost:3903/v0"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure Bearer authorization: bearerAuth
configuration = openapi_client.Configuration(
access_token = 'YOUR_BEARER_TOKEN'
)
# Enter a context with an instance of the API client
with openapi_client.ApiClient() as api_client:
with openapi_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = key_api.KeyApi(api_client)
access_key = "GK31c2f218a2e44f485b94239e" # str | The exact API access key generated by Garage
@ -364,7 +414,7 @@ Name | Type | Description | Notes
### Authorization
No authorization required
[bearerAuth](../README.md#bearerAuth)
### HTTP request headers
@ -391,6 +441,7 @@ Find the first key matching the given pattern based on its identifier aor friend
### Example
* Bearer Authentication (bearerAuth):
```python
import time
@ -404,9 +455,18 @@ configuration = openapi_client.Configuration(
host = "http://localhost:3903/v0"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure Bearer authorization: bearerAuth
configuration = openapi_client.Configuration(
access_token = 'YOUR_BEARER_TOKEN'
)
# Enter a context with an instance of the API client
with openapi_client.ApiClient() as api_client:
with openapi_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = key_api.KeyApi(api_client)
pattern = "test-k" # str | A pattern (beginning or full string) corresponding to a key identifier or friendly name
@ -433,7 +493,7 @@ Name | Type | Description | Notes
### Authorization
No authorization required
[bearerAuth](../README.md#bearerAuth)
### HTTP request headers
@ -459,6 +519,7 @@ Returns all API access keys in the cluster.
### Example
* Bearer Authentication (bearerAuth):
```python
import time
@ -472,9 +533,18 @@ configuration = openapi_client.Configuration(
host = "http://localhost:3903/v0"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure Bearer authorization: bearerAuth
configuration = openapi_client.Configuration(
access_token = 'YOUR_BEARER_TOKEN'
)
# Enter a context with an instance of the API client
with openapi_client.ApiClient() as api_client:
with openapi_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = key_api.KeyApi(api_client)
@ -497,7 +567,7 @@ This endpoint does not need any parameter.
### Authorization
No authorization required
[bearerAuth](../README.md#bearerAuth)
### HTTP request headers

View file

@ -19,6 +19,7 @@ Applies to the cluster the layout changes currently registered as staged layout
### Example
* Bearer Authentication (bearerAuth):
```python
import time
@ -32,9 +33,18 @@ configuration = openapi_client.Configuration(
host = "http://localhost:3903/v0"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure Bearer authorization: bearerAuth
configuration = openapi_client.Configuration(
access_token = 'YOUR_BEARER_TOKEN'
)
# Enter a context with an instance of the API client
with openapi_client.ApiClient() as api_client:
with openapi_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = layout_api.LayoutApi(api_client)
layout_version = LayoutVersion(
@ -63,7 +73,7 @@ void (empty response body)
### Authorization
No authorization required
[bearerAuth](../README.md#bearerAuth)
### HTTP request headers
@ -90,6 +100,7 @@ Returns the cluster's current layout, including: - Currently configured cluste
### Example
* Bearer Authentication (bearerAuth):
```python
import time
@ -103,9 +114,18 @@ configuration = openapi_client.Configuration(
host = "http://localhost:3903/v0"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure Bearer authorization: bearerAuth
configuration = openapi_client.Configuration(
access_token = 'YOUR_BEARER_TOKEN'
)
# Enter a context with an instance of the API client
with openapi_client.ApiClient() as api_client:
with openapi_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = layout_api.LayoutApi(api_client)
@ -128,7 +148,7 @@ This endpoint does not need any parameter.
### Authorization
No authorization required
[bearerAuth](../README.md#bearerAuth)
### HTTP request headers
@ -154,6 +174,7 @@ Send modifications to the cluster layout. These modifications will be included i
### Example
* Bearer Authentication (bearerAuth):
```python
import time
@ -167,9 +188,18 @@ configuration = openapi_client.Configuration(
host = "http://localhost:3903/v0"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure Bearer authorization: bearerAuth
configuration = openapi_client.Configuration(
access_token = 'YOUR_BEARER_TOKEN'
)
# Enter a context with an instance of the API client
with openapi_client.ApiClient() as api_client:
with openapi_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = layout_api.LayoutApi(api_client)
request_body = {
@ -198,7 +228,7 @@ void (empty response body)
### Authorization
No authorization required
[bearerAuth](../README.md#bearerAuth)
### HTTP request headers
@ -225,6 +255,7 @@ Clears all of the staged layout changes.
### Example
* Bearer Authentication (bearerAuth):
```python
import time
@ -238,9 +269,18 @@ configuration = openapi_client.Configuration(
host = "http://localhost:3903/v0"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure Bearer authorization: bearerAuth
configuration = openapi_client.Configuration(
access_token = 'YOUR_BEARER_TOKEN'
)
# Enter a context with an instance of the API client
with openapi_client.ApiClient() as api_client:
with openapi_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = layout_api.LayoutApi(api_client)
layout_version = LayoutVersion(
@ -269,7 +309,7 @@ void (empty response body)
### Authorization
No authorization required
[bearerAuth](../README.md#bearerAuth)
### HTTP request headers

View file

@ -17,6 +17,7 @@ Instructs this Garage node to connect to other Garage nodes at specified `<node_
### Example
* Bearer Authentication (bearerAuth):
```python
import time
@ -30,9 +31,18 @@ configuration = openapi_client.Configuration(
host = "http://localhost:3903/v0"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure Bearer authorization: bearerAuth
configuration = openapi_client.Configuration(
access_token = 'YOUR_BEARER_TOKEN'
)
# Enter a context with an instance of the API client
with openapi_client.ApiClient() as api_client:
with openapi_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = membership_api.MembershipApi(api_client)
request_body = ["ec79480e0ce52ae26fd00c9da684e4fa56658d9c64cdcecb094e936de0bfe71f@10.0.0.11:3901","4a6ae5a1d0d33bf895f5bb4f0a418b7dc94c47c0dd2eb108d1158f3c8f60b0ff@10.0.0.12:3901"] # [str] | (optional)
@ -60,7 +70,7 @@ Name | Type | Description | Notes
### Authorization
No authorization required
[bearerAuth](../README.md#bearerAuth)
### HTTP request headers
@ -87,6 +97,7 @@ Returns the cluster's current status, including: - ID of the node being queried
### Example
* Bearer Authentication (bearerAuth):
```python
import time
@ -100,9 +111,18 @@ configuration = openapi_client.Configuration(
host = "http://localhost:3903/v0"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure Bearer authorization: bearerAuth
configuration = openapi_client.Configuration(
access_token = 'YOUR_BEARER_TOKEN'
)
# Enter a context with an instance of the API client
with openapi_client.ApiClient() as api_client:
with openapi_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = membership_api.MembershipApi(api_client)
@ -125,7 +145,7 @@ This endpoint does not need any parameter.
### Authorization
No authorization required
[bearerAuth](../README.md#bearerAuth)
### HTTP request headers

View file

@ -42,7 +42,9 @@ class KeyApi(object):
self.key_import_post_endpoint = _Endpoint(
settings={
'response_type': (KeyInfo,),
'auth': [],
'auth': [
'bearerAuth'
],
'endpoint_path': '/key/import',
'operation_id': 'key_import_post',
'http_method': 'POST',
@ -90,7 +92,9 @@ class KeyApi(object):
self.key_post_endpoint = _Endpoint(
settings={
'response_type': (KeyInfo,),
'auth': [],
'auth': [
'bearerAuth'
],
'endpoint_path': '/key',
'operation_id': 'key_post',
'http_method': 'POST',
@ -138,7 +142,9 @@ class KeyApi(object):
self.keyidaccess_key_delete_endpoint = _Endpoint(
settings={
'response_type': None,
'auth': [],
'auth': [
'bearerAuth'
],
'endpoint_path': '/key?id={access_key}',
'operation_id': 'keyidaccess_key_delete',
'http_method': 'DELETE',
@ -185,7 +191,9 @@ class KeyApi(object):
self.keyidaccess_key_get_endpoint = _Endpoint(
settings={
'response_type': (KeyInfo,),
'auth': [],
'auth': [
'bearerAuth'
],
'endpoint_path': '/key?id={access_key}',
'operation_id': 'keyidaccess_key_get',
'http_method': 'GET',
@ -234,7 +242,9 @@ class KeyApi(object):
self.keyidaccess_key_post_endpoint = _Endpoint(
settings={
'response_type': (KeyInfo,),
'auth': [],
'auth': [
'bearerAuth'
],
'endpoint_path': '/key?id={access_key}',
'operation_id': 'keyidaccess_key_post',
'http_method': 'POST',
@ -289,7 +299,9 @@ class KeyApi(object):
self.keysearchpattern_get_endpoint = _Endpoint(
settings={
'response_type': (KeyInfo,),
'auth': [],
'auth': [
'bearerAuth'
],
'endpoint_path': '/key?search={pattern}',
'operation_id': 'keysearchpattern_get',
'http_method': 'GET',
@ -338,7 +350,9 @@ class KeyApi(object):
self.list_keys_endpoint = _Endpoint(
settings={
'response_type': ([ListKeys200ResponseInner],),
'auth': [],
'auth': [
'bearerAuth'
],
'endpoint_path': '/key',
'operation_id': 'list_keys',
'http_method': 'GET',

View file

@ -40,7 +40,9 @@ class LayoutApi(object):
self.layout_apply_post_endpoint = _Endpoint(
settings={
'response_type': None,
'auth': [],
'auth': [
'bearerAuth'
],
'endpoint_path': '/layout/apply',
'operation_id': 'layout_apply_post',
'http_method': 'POST',
@ -86,7 +88,9 @@ class LayoutApi(object):
self.layout_get_endpoint = _Endpoint(
settings={
'response_type': (ClusterLayout,),
'auth': [],
'auth': [
'bearerAuth'
],
'endpoint_path': '/layout',
'operation_id': 'layout_get',
'http_method': 'GET',
@ -128,7 +132,9 @@ class LayoutApi(object):
self.layout_post_endpoint = _Endpoint(
settings={
'response_type': None,
'auth': [],
'auth': [
'bearerAuth'
],
'endpoint_path': '/layout',
'operation_id': 'layout_post',
'http_method': 'POST',
@ -174,7 +180,9 @@ class LayoutApi(object):
self.layout_revert_post_endpoint = _Endpoint(
settings={
'response_type': None,
'auth': [],
'auth': [
'bearerAuth'
],
'endpoint_path': '/layout/revert',
'operation_id': 'layout_revert_post',
'http_method': 'POST',

View file

@ -39,7 +39,9 @@ class MembershipApi(object):
self.connect_post_endpoint = _Endpoint(
settings={
'response_type': ([ConnectPost200ResponseInner],),
'auth': [],
'auth': [
'bearerAuth'
],
'endpoint_path': '/connect',
'operation_id': 'connect_post',
'http_method': 'POST',
@ -87,7 +89,9 @@ class MembershipApi(object):
self.status_get_endpoint = _Endpoint(
settings={
'response_type': (StatusGet200Response,),
'auth': [],
'auth': [
'bearerAuth'
],
'endpoint_path': '/status',
'operation_id': 'status_get',
'http_method': 'GET',

View file

@ -76,6 +76,7 @@ class Configuration(object):
:param ssl_ca_cert: str - the path to a file of concatenated CA certificates
in PEM format
:Example:
"""
_default = None
@ -369,6 +370,13 @@ class Configuration(object):
:return: The Auth Settings information dict.
"""
auth = {}
if self.access_token is not None:
auth['bearerAuth'] = {
'type': 'bearer',
'in': 'header',
'key': 'Authorization',
'value': 'Bearer ' + self.access_token
}
return auth
def to_debug_report(self):