|
| 1 | +# Defining the host is optional and defaults to {{{basePath}}} |
| 2 | +# See configuration.py for a list of all supported configuration parameters. |
| 3 | +configuration = {{{packageName}}}.Configuration( |
| 4 | + host = "{{{basePath}}}" |
| 5 | +) |
| 6 | + |
1 | 7 | {{#hasAuthMethods}}
|
| 8 | +# The client must configure the authentication and authorization parameters |
| 9 | +# in accordance with the API server security policy. |
| 10 | +# Examples for each auth method are provided below, use the example that |
| 11 | +# satisfies your auth use case. |
2 | 12 | {{#authMethods}}
|
3 |
| -configuration = {{{packageName}}}.Configuration() |
4 | 13 | {{#isBasic}}
|
5 | 14 | {{#isBasicBasic}}
|
| 15 | + |
6 | 16 | # Configure HTTP basic authorization: {{{name}}}
|
7 |
| -configuration.username = 'YOUR_USERNAME' |
8 |
| -configuration.password = 'YOUR_PASSWORD' |
| 17 | +configuration = {{{packageName}}}.Configuration( |
| 18 | + username = 'YOUR_USERNAME', |
| 19 | + password = 'YOUR_PASSWORD' |
| 20 | +) |
9 | 21 | {{/isBasicBasic}}
|
10 | 22 | {{#isBasicBearer}}
|
| 23 | + |
11 | 24 | # Configure Bearer authorization{{#bearerFormat}} ({{{.}}}){{/bearerFormat}}: {{{name}}}
|
12 |
| -configuration.access_token = 'YOUR_BEARER_TOKEN' |
| 25 | +configuration = {{{packageName}}}.Configuration( |
| 26 | + access_token = 'YOUR_BEARER_TOKEN' |
| 27 | +) |
13 | 28 | {{/isBasicBearer}}
|
14 | 29 | {{#isHttpSignature}}
|
15 |
| -# Configure HTTP signature authorization: {{{name}}} |
16 |
| -# You can specify the signing key-id, private key path, signing scheme, signing algorithm, |
17 |
| -# list of signed headers and signature max validity. |
18 |
| -configuration.signing_info = {{{packageName}}}.signing.HttpSigningConfiguration( |
19 |
| - key_id = 'my-key-id', |
20 |
| - private_key_path = 'rsa.pem', |
21 |
| - signing_scheme = signing.SCHEME_HS2019, |
22 |
| - signing_algorithm = signing.ALGORITHM_RSASSA_PSS, |
23 |
| - signed_headers = [signing.HEADER_REQUEST_TARGET, |
24 |
| - signing.HEADER_CREATED, |
25 |
| - signing.HEADER_EXPIRES, |
26 |
| - signing.HEADER_HOST, |
27 |
| - signing.HEADER_DATE, |
28 |
| - signing.HEADER_DIGEST, |
29 |
| - 'Content-Type', |
30 |
| - 'Content-Length', |
31 |
| - 'User-Agent' |
32 |
| - ], |
33 |
| - signature_max_validity = datetime.timedelta(minutes=5) |
| 30 | + |
| 31 | +# Configure HTTP message signature: {{{name}}} |
| 32 | +# The HTTP Signature Header mechanism that can be used by a client to |
| 33 | +# authenticate the sender of a message and ensure that particular headers |
| 34 | +# have not been modified in transit. |
| 35 | +# |
| 36 | +# You can specify the signing key-id, private key path, signing scheme, |
| 37 | +# signing algorithm, list of signed headers and signature max validity. |
| 38 | +# The 'key_id' parameter is an opaque string that the API server can use |
| 39 | +# to lookup the client and validate the signature. |
| 40 | +# The 'private_key_path' parameter should be the path to a file that |
| 41 | +# contains a DER or base-64 encoded private key. |
| 42 | +# The 'private_key_passphrase' parameter is optional. Set the passphrase |
| 43 | +# if the private key is encrypted. |
| 44 | +# The 'signed_headers' parameter is used to specify the list of |
| 45 | +# HTTP headers included when generating the signature for the message. |
| 46 | +# You can specify HTTP headers that you want to protect with a cryptographic |
| 47 | +# signature. Note that proxies may add, modify or remove HTTP headers |
| 48 | +# for legitimate reasons, so you should only add headers that you know |
| 49 | +# will not be modified. For example, if you want to protect the HTTP request |
| 50 | +# body, you can specify the Digest header. In that case, the client calculates |
| 51 | +# the digest of the HTTP request body and includes the digest in the message |
| 52 | +# signature. |
| 53 | +# The 'signature_max_validity' parameter is optional. It is configured as a |
| 54 | +# duration to express when the signature ceases to be valid. The client calculates |
| 55 | +# the expiration date every time it generates the cryptographic signature |
| 56 | +# of an HTTP request. The API server may have its own security policy |
| 57 | +# that controls the maximum validity of the signature. The client max validity |
| 58 | +# must be lower than the server max validity. |
| 59 | +# The time on the client and server must be synchronized, otherwise the |
| 60 | +# server may reject the client signature. |
| 61 | +# |
| 62 | +# The client must use a combination of private key, signing scheme, |
| 63 | +# signing algorithm and hash algorithm that matches the security policy of |
| 64 | +# the API server. |
| 65 | +# |
| 66 | +# See {{{packageName}}}.signing for a list of all supported parameters. |
| 67 | +configuration = {{{packageName}}}.Configuration( |
| 68 | + host = "{{{basePath}}}", |
| 69 | + signing_info = {{{packageName}}}.signing.HttpSigningConfiguration( |
| 70 | + key_id = 'my-key-id', |
| 71 | + private_key_path = 'private_key.pem', |
| 72 | + private_key_passphrase = 'YOUR_PASSPHRASE', |
| 73 | + signing_scheme = {{{packageName}}}.signing.SCHEME_HS2019, |
| 74 | + signing_algorithm = {{{packageName}}}.signing.ALGORITHM_ECDSA_MODE_FIPS_186_3, |
| 75 | + hash_algorithm = {{{packageName}}}.signing.SCHEME_RSA_SHA256, |
| 76 | + signed_headers = [ |
| 77 | + {{{packageName}}}.signing.HEADER_REQUEST_TARGET, |
| 78 | + {{{packageName}}}.signing.HEADER_CREATED, |
| 79 | + {{{packageName}}}.signing.HEADER_EXPIRES, |
| 80 | + {{{packageName}}}.signing.HEADER_HOST, |
| 81 | + {{{packageName}}}.signing.HEADER_DATE, |
| 82 | + {{{packageName}}}.signing.HEADER_DIGEST, |
| 83 | + 'Content-Type', |
| 84 | + 'Content-Length', |
| 85 | + 'User-Agent' |
| 86 | + ], |
| 87 | + signature_max_validity = datetime.timedelta(minutes=5) |
| 88 | + ) |
34 | 89 | )
|
35 | 90 | {{/isHttpSignature}}
|
36 | 91 | {{/isBasic}}
|
37 | 92 | {{#isApiKey}}
|
| 93 | + |
38 | 94 | # Configure API key authorization: {{{name}}}
|
39 |
| -configuration.api_key['{{{keyParamName}}}'] = 'YOUR_API_KEY' |
| 95 | +configuration = {{{packageName}}}.Configuration( |
| 96 | + host = "{{{basePath}}}", |
| 97 | + api_key = { |
| 98 | + '{{{keyParamName}}}': 'YOUR_API_KEY' |
| 99 | + } |
| 100 | +) |
40 | 101 | # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
41 | 102 | # configuration.api_key_prefix['{{{keyParamName}}}'] = 'Bearer'
|
42 | 103 | {{/isApiKey}}
|
43 | 104 | {{#isOAuth}}
|
| 105 | + |
44 | 106 | # Configure OAuth2 access token for authorization: {{{name}}}
|
| 107 | +configuration = {{{packageName}}}.Configuration( |
| 108 | + host = "{{{basePath}}}" |
| 109 | +) |
45 | 110 | configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
46 | 111 | {{/isOAuth}}
|
47 | 112 | {{/authMethods}}
|
48 |
| - |
49 |
| -# Defining host is optional and default to {{{basePath}}} |
50 |
| -configuration.host = "{{{basePath}}}" |
51 | 113 | {{/hasAuthMethods}}
|
0 commit comments