Skip to content

Commit 9913071

Browse files
authored
feat(CloudPakForDataServiceInstanceAuthenticator): add new cp4d service instance authenticator (#156)
This commit introduces a new authenticator implementation that supports the "GET /v3/service_instances/{service_instance_id}/token" operation which is part of the Cloud Pak For Data authentication service. This allows users to obtain access tokens for service instances using the username, apikey, and service instance id in CP4D.
1 parent 148b37f commit 9913071

11 files changed

+1064
-4
lines changed

.secrets.baseline

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": "package-lock.json|^.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2021-10-25T15:49:19Z",
6+
"generated_at": "2021-11-17T14:53:46Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"
@@ -104,23 +104,23 @@
104104
"hashed_secret": "d4c3d66fd0c38547a3c7a4c6bdc29c36911bc030",
105105
"is_secret": false,
106106
"is_verified": false,
107-
"line_number": 44,
107+
"line_number": 45,
108108
"type": "Secret Keyword",
109109
"verified_result": null
110110
},
111111
{
112112
"hashed_secret": "8318df9ecda039deac9868adf1944a29a95c7114",
113113
"is_secret": false,
114114
"is_verified": false,
115-
"line_number": 46,
115+
"line_number": 48,
116116
"type": "Secret Keyword",
117117
"verified_result": null
118118
},
119119
{
120120
"hashed_secret": "9a66213cc16d178fdbf9f4da6b7bd92497fda404",
121121
"is_secret": false,
122122
"is_verified": false,
123-
"line_number": 52,
123+
"line_number": 54,
124124
"type": "Secret Keyword",
125125
"verified_result": null
126126
}
@@ -173,6 +173,16 @@
173173
"verified_result": null
174174
}
175175
],
176+
"src/test/java/com/ibm/cloud/sdk/core/test/security/Cp4dServiceInstanceAuthenticatorTest.java": [
177+
{
178+
"hashed_secret": "2207d3f3ac68743290fe4affc71c10bec4962232",
179+
"is_secret": false,
180+
"is_verified": false,
181+
"line_number": 61,
182+
"type": "Secret Keyword",
183+
"verified_result": null
184+
}
185+
],
176186
"src/test/java/com/ibm/cloud/sdk/core/test/security/JsonWebTokenTest.java": [
177187
{
178188
"hashed_secret": "c6ba9cef42f298486a61546fefd03a4177e60a99",
@@ -201,6 +211,16 @@
201211
"verified_result": null
202212
}
203213
],
214+
"src/test/resources/cp4d_service_instance_token.json": [
215+
{
216+
"hashed_secret": "0cadf54eaba861bbe38dadf15ceaa37a98ba68bb",
217+
"is_secret": false,
218+
"is_verified": false,
219+
"line_number": 4,
220+
"type": "JSON Web Token",
221+
"verified_result": null
222+
}
223+
],
204224
"src/test/resources/cp4d_token.json": [
205225
{
206226
"hashed_secret": "0cadf54eaba861bbe38dadf15ceaa37a98ba68bb",
@@ -261,6 +281,16 @@
261281
"verified_result": null
262282
}
263283
],
284+
"src/test/resources/refreshed_cp4d_service_instance_token.json": [
285+
{
286+
"hashed_secret": "78afb9234e91232b50987dd260c09e47eeefc2f5",
287+
"is_secret": false,
288+
"is_verified": false,
289+
"line_number": 4,
290+
"type": "JSON Web Token",
291+
"verified_result": null
292+
}
293+
],
264294
"src/test/resources/refreshed_cp4d_token.json": [
265295
{
266296
"hashed_secret": "78afb9234e91232b50987dd260c09e47eeefc2f5",

src/main/java/com/ibm/cloud/sdk/core/security/Authenticator.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public interface Authenticator {
2828
String AUTHTYPE_IAM = "iam";
2929
String AUTHTYPE_CP4D = "cp4d";
3030
String AUTHTYPE_CP4D_SERVICE = "cp4dService";
31+
String AUTHTYPE_CP4D_SERVICE_INSTANCE = "cp4dServiceInstance";
3132
String AUTHTYPE_BEARER_TOKEN = "bearerToken";
3233
String AUTHTYPE_CONTAINER = "container";
3334
String AUTHTYPE_VPC = "vpc";
@@ -42,6 +43,7 @@ public interface Authenticator {
4243
String PROPNAME_URL = "AUTH_URL";
4344
String PROPNAME_DISABLE_SSL = "AUTH_DISABLE_SSL";
4445
String PROPNAME_APIKEY = "APIKEY";
46+
String PROPNAME_SERVICE_INSTANCE_ID = "SERVICE_INSTANCE_ID";
4547
String PROPNAME_CLIENT_ID = "CLIENT_ID";
4648
String PROPNAME_CLIENT_SECRET = "CLIENT_SECRET";
4749
String PROPNAME_SCOPE = "SCOPE";

0 commit comments

Comments
 (0)