@@ -7,7 +7,8 @@ The java-sdk-core project supports the following types of authentication:
7
7
- Container Authentication
8
8
- VPC Instance Authentication
9
9
- Cloud Pak for Data Authentication
10
- - Multi-Cloud Saas Platform (MCSP) Authentication
10
+ - Multi-Cloud Saas Platform (MCSP) V1 Authentication
11
+ - Multi-Cloud Saas Platform (MCSP) V2 Authentication
11
12
- No Authentication (for testing)
12
13
13
14
The SDK user configures the appropriate type of authentication for use with service instances.
@@ -575,11 +576,11 @@ ExampleService service = ExampleService.newInstance("example_service");
575
576
```
576
577
577
578
578
- ## Multi-Cloud Saas Platform (MCSP) Authentication
579
+ ## Multi-Cloud Saas Platform (MCSP) V1 Authentication
579
580
The ` MCSPAuthenticator ` can be used in scenarios where an application needs to
580
581
interact with an IBM Cloud service that has been deployed to a non-IBM Cloud environment (e.g. AWS).
581
- It accepts a user-supplied apikey and performs the necessary interactions with the
582
- Multi-Cloud Saas Platform token service to obtain a suitable MCSP access token (a bearer token)
582
+ It accepts a user-supplied apikey and invokes the Multi-Cloud Saas Platform token service's
583
+ ` POST /siusermgr/api/1.0/apikeys/ token` operation to obtain a suitable MCSP access token (a bearer token)
583
584
for the specified apikey.
584
585
The authenticator will also obtain a new bearer token when the current token expires.
585
586
The bearer token is then added to each outbound request in the ` Authorization ` header in the
@@ -643,6 +644,106 @@ ExampleService service = ExampleService.newInstance("example_service");
643
644
```
644
645
645
646
647
+ ## Multi-Cloud Saas Platform (MCSP) V2 Authentication
648
+ The ` MCSPV2Authenticator ` can be used in scenarios where an application needs to
649
+ interact with an IBM Cloud service that has been deployed to a non-IBM Cloud environment (e.g. AWS).
650
+ It accepts a user-supplied apikey and invokes the Multi-Cloud Saas Platform token service's
651
+ ` POST /api/2.0/{scopeCollectionType}/{scopeId}/apikeys/token ` operation to obtain a suitable MCSP access token (a bearer token)
652
+ for the specified apikey.
653
+ The authenticator will also obtain a new bearer token when the current token expires.
654
+ The bearer token is then added to each outbound request in the ` Authorization ` header in the
655
+ form:
656
+ ```
657
+ Authorization: Bearer <bearer-token>
658
+ ```
659
+
660
+ ### Properties
661
+
662
+ - apikey: (required) the apikey to be used to obtain an MCSP access token.
663
+
664
+ - url: (required) The URL representing the MCSP token service endpoint's base URL string. Do not include the
665
+ operation path (e.g. ` /siusermgr/api/1.0/apikeys/token ` ) as part of this property's value.
666
+
667
+ - scopeCollectionType: (required) The scope collection type of item(s).
668
+ The valid values are: ` accounts ` , ` subscriptions ` , ` services ` , ` products ` , ` externalservices `
669
+
670
+ - scopeId: (required) The scope identifier of item(s).
671
+
672
+ - includeBuiltinActions: (optional) A flag to include builtin actions in the ` actions ` claim in the MCSP token (default: false).
673
+
674
+ - includeCustomActions: (optional) A flag to include custom actions in the ` actions ` claim in the MCSP token (default: false).
675
+
676
+ - includeRoles: (optional) A flag to include the ` roles ` claim in the MCSP token (default: true).
677
+
678
+ - prefixRoles: (optional) A flag to add a prefix with the scope level where
679
+ the role is defined in the ` roles ` claim (default: false).
680
+
681
+ - callerExtClaim: (optional) A map containing keys and values to be injected into the returned access token
682
+ as the ` callerExt ` claim. The keys used in this map must be enabled in the apikey by setting the
683
+ ` callerExtClaimNames ` property when the apikey is created.
684
+
685
+ - disableSSLVerification: (optional) A flag that indicates whether verification of the server's SSL
686
+ certificate should be disabled or not. The default value is ` false ` .
687
+
688
+ - headers: (optional) A set of key/value pairs that will be sent as HTTP headers in requests
689
+ made to the MCSP token service.
690
+
691
+ ### Usage Notes
692
+ - When constructing an MCSPV2Authenticator instance, the apikey, url, scopeCollectionType, and scopeId properties are required.
693
+
694
+ - If you specify the callerExtClaim map, the keys used in the map must have been previously enabled in the apikey
695
+ by setting the ` callerExtClaimNames ` property when you created the apikey.
696
+ The entries contained in this map will appear in the ` callerExt ` field (claim) of the returned access token.
697
+
698
+ - The authenticator will invoke the token server's ` POST /api/2.0/{scopeCollectionType}/{scopeId}/apikeys/token ` operation to
699
+ exchange the apikey for an MCSP access token (the bearer token).
700
+
701
+ ### Programming example
702
+ ``` java
703
+ import com.ibm.cloud.sdk.core.security.MCSPV2Authenticator ;
704
+ import <sdk_base_package>.ExampleService.v1.ExampleService ;
705
+ ...
706
+ Map<String , String > callerExtClaim = Map . of(" productID" , " prod-123" );
707
+
708
+ // Create the authenticator.
709
+ MCSPV2Authenticator authenticator = new MCSPV2Authenticator .Builder ()
710
+ .apikey(" myapikey" )
711
+ .url(" https://example.mcspv2.token-exchange.com" )
712
+ .scopeCollectionType(" accounts" )
713
+ .scopeId(" global_account" )
714
+ .includeBuiltinActions(true )
715
+ .callerExtClaim(callerExtClaim)
716
+ .build();
717
+
718
+ // Create the service instance.
719
+ ExampleService service = new ExampleService (ExampleService . DEFAULT_SERVICE_NAME , authenticator);
720
+
721
+ // 'service' can now be used to invoke operations.
722
+ ```
723
+
724
+ ### Configuration example
725
+ External configuration:
726
+ ```
727
+ export EXAMPLE_SERVICE_AUTH_TYPE=mcspv2
728
+ export EXAMPLE_SERVICE_APIKEY=myapikey
729
+ export EXAMPLE_SERVICE_AUTH_URL=https://example.mcspv2.token-exchange.com
730
+ export EXAMPLE_SCOPE_COLLECTION_TYPE=accounts
731
+ export EXAMPLE_SCOPE_ID=global_account
732
+ export EXAMPLE_INCLUDE_BUILTIN_ACTIONS=true
733
+ export EXAMPLE_CALLER_EXT_CLAIM={"productID":"prod-123"}
734
+ ```
735
+ Application code:
736
+ ``` java
737
+ import <sdk_base_package>.ExampleService.v1.ExampleService ;
738
+ ...
739
+
740
+ // Create the service instance.
741
+ ExampleService service = ExampleService . newInstance(" example_service" );
742
+
743
+ // 'service' can now be used to invoke operations.
744
+ ```
745
+
746
+
646
747
## No Auth Authentication
647
748
The ` NoAuthAuthenticator ` is a placeholder authenticator which performs no actual authentication function.
648
749
It can be used in situations where authentication needs to be bypassed, perhaps while developing
0 commit comments