You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Authentication.md
+92-6Lines changed: 92 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,7 @@ The python-sdk-core project supports the following types of authentication:
3
3
- Basic Authentication
4
4
- Bearer Token Authentication
5
5
- Identity and Access Management (IAM) Authentication
6
+
- VPC Instance Authentication
6
7
- Container Authentication
7
8
- Cloud Pak for Data Authentication
8
9
- No Authentication
@@ -13,13 +14,10 @@ so it is important for the SDK user to consult with the appropriate service docu
13
14
to understand which authenticators are supported for that service.
14
15
15
16
The python-sdk-core allows an authenticator to be specified in one of two ways:
16
-
1. programmatically - the SDK user invokes the appropriate function(s) to create an instance of the
17
-
desired authenticator and then passes the authenticator instance when constructing an instance of the service client.
17
+
1. programmatically - the SDK user invokes the appropriate function(s) to create an instance of the
18
+
desired authenticator and then passes the authenticator instance when constructing an instance of the service.
18
19
2. configuration - the SDK user provides external configuration information (in the form of environment variables
19
-
or a credentials file) to indicate the type of authenticator, along with the configuration of the necessary properties
20
-
for that authenticator.
21
-
The SDK user then invokes the configuration-based service client constructor method
22
-
to construct an instance of the authenticator and service client that reflect the external configuration information.
20
+
or a credentials file) to indicate the type of authenticator, along with the configuration of the necessary properties for that authenticator. The SDK user then invokes the configuration-based service client constructor method to construct an instance of the authenticator and service client that reflect the external configuration information.
23
21
24
22
The sections below will provide detailed information for each authenticator
25
23
which will include the following:
@@ -145,6 +143,15 @@ form:
145
143
146
144
- url: (optional) The URL representing the IAM token service endpoint. If not specified, a suitable
147
145
default value is used.
146
+
Make sure that you use an IAM token service endpoint that is appropriate for the
147
+
location of the service being used by your application.
148
+
For example, if you are using an instance of a service in the "production" environment
then you would also need to configure the authenticator to use the IAM token service "staging"
247
+
endpoint as well (`https://iam.test.cloud.ibm.com`).
232
248
233
249
- client_id/client_secret: (optional) The `client_id` and `client_secret` fields are used to form a
234
250
"basic auth" Authorization header for interactions with the IAM token server. If neither field
@@ -277,6 +293,76 @@ service = ExampleServiceV1.new_instance(service_name='example_service')
277
293
```
278
294
279
295
296
+
## VPC Instance Authentication
297
+
The `VpcInstanceAuthenticator` is intended to be used by application code
298
+
running inside a VPC-managed compute resource (virtual server instance) that has been configured
299
+
to use the "compute resource identity" feature.
300
+
The compute resource identity feature allows you to assign a trusted IAM profile to the compute resource as its "identity".
301
+
This, in turn, allows applications running within the compute resource to take on this identity when interacting with
302
+
IAM-secured IBM Cloud services.
303
+
This results in a simplified security model that allows the application developer to:
304
+
- avoid storing credentials in application code, configuraton files or a password vault
305
+
- avoid managing or rotating credentials
306
+
307
+
The `VpcInstanceAuthenticator` will invoke the appropriate operations on the compute resource's locally-available
308
+
VPC Instance Metadata Service to (1) retrieve an instance identity token
309
+
and then (2) exchange that instance identity token for an IAM access token.
310
+
The authenticator will repeat these steps to obtain a new IAM access token whenever the current access token expires.
311
+
The IAM access token is added to each outbound request in the `Authorization` header in the form:
312
+
```
313
+
Authorization: Bearer <IAM-access-token>
314
+
```
315
+
316
+
### Properties
317
+
318
+
- iam_profile_crn: (optional) the crn of the linked trusted IAM profile to be used when obtaining the IAM access token.
319
+
320
+
- iam_profile_id: (optional) the id of the linked trusted IAM profile to be used when obtaining the IAM access token.
321
+
322
+
- url: (optional) The VPC Instance Metadata Service's base URL.
323
+
The default value of this property is `http://169.254.169.254`, and should not need to be specified in normal situations.
324
+
325
+
Usage Notes:
326
+
1. At most one of `iam_profile_crn` or `iam_profile_id` may be specified. The specified value must map
327
+
to a trusted IAM profile that has been linked to the compute resource (virtual server instance).
328
+
329
+
2. If both `iam_profile_crn` and `iam_profile_id` are specified, then an error occurs.
330
+
331
+
3. If neither `iam_profile_crn` nor `iam_profile_id` are specified, then the default trusted profile linked to the compute resource will be used to perform the IAM token exchange.
332
+
If no default trusted profile is defined for the compute resource, then an error occurs.
333
+
334
+
335
+
### Programming example
336
+
```python
337
+
from ibm_cloud_sdk_core.authenticators import VPCInstanceAuthenticator
0 commit comments