ibm-cloud-sdk-core 5.0.1 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.secrets.baseline +128 -24
- package/Authentication.md +146 -21
- package/CHANGELOG.md +14 -0
- package/README.md +3 -2
- package/auth/authenticators/authenticator.d.ts +1 -0
- package/auth/authenticators/authenticator.js +1 -0
- package/auth/authenticators/basic-authenticator.d.ts +1 -1
- package/auth/authenticators/basic-authenticator.js +3 -1
- package/auth/authenticators/bearer-token-authenticator.js +2 -0
- package/auth/authenticators/container-authenticator.d.ts +6 -0
- package/auth/authenticators/container-authenticator.js +8 -0
- package/auth/authenticators/iam-assume-authenticator.d.ts +82 -0
- package/auth/authenticators/iam-assume-authenticator.js +92 -0
- package/auth/authenticators/iam-authenticator.d.ts +6 -0
- package/auth/authenticators/iam-authenticator.js +8 -0
- package/auth/authenticators/iam-request-based-authenticator-immutable.d.ts +64 -0
- package/auth/authenticators/iam-request-based-authenticator-immutable.js +74 -0
- package/auth/authenticators/iam-request-based-authenticator.d.ts +19 -47
- package/auth/authenticators/iam-request-based-authenticator.js +28 -36
- package/auth/authenticators/index.d.ts +4 -1
- package/auth/authenticators/index.js +3 -1
- package/auth/authenticators/token-request-based-authenticator-immutable.d.ts +71 -0
- package/auth/authenticators/token-request-based-authenticator-immutable.js +91 -0
- package/auth/authenticators/token-request-based-authenticator.d.ts +4 -42
- package/auth/authenticators/token-request-based-authenticator.js +5 -40
- package/auth/token-managers/container-token-manager.d.ts +6 -0
- package/auth/token-managers/container-token-manager.js +18 -50
- package/auth/token-managers/cp4d-token-manager.js +6 -1
- package/auth/token-managers/iam-assume-token-manager.d.ts +101 -0
- package/auth/token-managers/iam-assume-token-manager.js +220 -0
- package/auth/token-managers/iam-request-based-token-manager.d.ts +3 -9
- package/auth/token-managers/iam-request-based-token-manager.js +5 -9
- package/auth/token-managers/iam-token-manager.d.ts +8 -2
- package/auth/token-managers/iam-token-manager.js +10 -2
- package/auth/token-managers/index.d.ts +4 -2
- package/auth/token-managers/index.js +6 -3
- package/auth/token-managers/mcsp-token-manager.js +6 -1
- package/auth/token-managers/token-manager.js +7 -3
- package/auth/token-managers/vpc-instance-token-manager.js +4 -1
- package/auth/utils/get-authenticator-from-environment.js +3 -0
- package/auth/utils/helpers.d.ts +18 -23
- package/auth/utils/helpers.js +50 -30
- package/auth/utils/read-external-sources.js +2 -0
- package/docs/ibm-cloud-sdk-core.api.json +787 -404
- package/es/auth/authenticators/authenticator.d.ts +1 -0
- package/es/auth/authenticators/authenticator.js +1 -0
- package/es/auth/authenticators/basic-authenticator.d.ts +1 -1
- package/es/auth/authenticators/basic-authenticator.js +3 -1
- package/es/auth/authenticators/bearer-token-authenticator.js +2 -0
- package/es/auth/authenticators/container-authenticator.d.ts +6 -0
- package/es/auth/authenticators/container-authenticator.js +8 -0
- package/es/auth/authenticators/iam-assume-authenticator.d.ts +82 -0
- package/es/auth/authenticators/iam-assume-authenticator.js +70 -0
- package/es/auth/authenticators/iam-authenticator.d.ts +6 -0
- package/es/auth/authenticators/iam-authenticator.js +8 -0
- package/es/auth/authenticators/iam-request-based-authenticator-immutable.d.ts +64 -0
- package/es/auth/authenticators/iam-request-based-authenticator-immutable.js +51 -0
- package/es/auth/authenticators/iam-request-based-authenticator.d.ts +19 -47
- package/es/auth/authenticators/iam-request-based-authenticator.js +26 -35
- package/es/auth/authenticators/index.d.ts +4 -1
- package/es/auth/authenticators/index.js +1 -0
- package/es/auth/authenticators/token-request-based-authenticator-immutable.d.ts +71 -0
- package/es/auth/authenticators/token-request-based-authenticator-immutable.js +65 -0
- package/es/auth/authenticators/token-request-based-authenticator.d.ts +4 -42
- package/es/auth/authenticators/token-request-based-authenticator.js +3 -37
- package/es/auth/token-managers/container-token-manager.d.ts +6 -0
- package/es/auth/token-managers/container-token-manager.js +18 -24
- package/es/auth/token-managers/cp4d-token-manager.js +6 -1
- package/es/auth/token-managers/iam-assume-token-manager.d.ts +101 -0
- package/es/auth/token-managers/iam-assume-token-manager.js +164 -0
- package/es/auth/token-managers/iam-request-based-token-manager.d.ts +3 -9
- package/es/auth/token-managers/iam-request-based-token-manager.js +5 -9
- package/es/auth/token-managers/iam-token-manager.d.ts +8 -2
- package/es/auth/token-managers/iam-token-manager.js +10 -2
- package/es/auth/token-managers/index.d.ts +4 -2
- package/es/auth/token-managers/index.js +4 -2
- package/es/auth/token-managers/mcsp-token-manager.js +6 -1
- package/es/auth/token-managers/token-manager.js +7 -3
- package/es/auth/token-managers/vpc-instance-token-manager.js +4 -1
- package/es/auth/utils/get-authenticator-from-environment.js +4 -1
- package/es/auth/utils/helpers.d.ts +18 -23
- package/es/auth/utils/helpers.js +35 -27
- package/es/auth/utils/read-external-sources.js +2 -0
- package/es/lib/base-service.js +2 -0
- package/es/lib/private-helpers.d.ts +22 -0
- package/es/lib/private-helpers.js +58 -0
- package/es/lib/request-wrapper.d.ts +43 -1
- package/es/lib/request-wrapper.js +113 -14
- package/etc/ibm-cloud-sdk-core.api.md +46 -28
- package/ibm-cloud-sdk-core.d.ts +306 -68
- package/lib/base-service.js +2 -0
- package/lib/private-helpers.d.ts +22 -0
- package/lib/private-helpers.js +62 -0
- package/lib/request-wrapper.d.ts +43 -1
- package/lib/request-wrapper.js +113 -14
- package/package.json +5 -4
- package/sdk-test-utilities/package-lock.json +8 -5
- package/sdk-test-utilities/package.json +3 -0
|
@@ -25,6 +25,7 @@ export declare class Authenticator implements AuthenticatorInterface {
|
|
|
25
25
|
static AUTHTYPE_BASIC: string;
|
|
26
26
|
static AUTHTYPE_BEARERTOKEN: string;
|
|
27
27
|
static AUTHTYPE_IAM: string;
|
|
28
|
+
static AUTHTYPE_IAM_ASSUME: string;
|
|
28
29
|
static AUTHTYPE_CONTAINER: string;
|
|
29
30
|
static AUTHTYPE_CP4D: string;
|
|
30
31
|
static AUTHTYPE_NOAUTH: string;
|
|
@@ -45,6 +45,7 @@ export class Authenticator {
|
|
|
45
45
|
Authenticator.AUTHTYPE_BASIC = 'basic';
|
|
46
46
|
Authenticator.AUTHTYPE_BEARERTOKEN = 'bearerToken';
|
|
47
47
|
Authenticator.AUTHTYPE_IAM = 'iam';
|
|
48
|
+
Authenticator.AUTHTYPE_IAM_ASSUME = 'iamAssume';
|
|
48
49
|
Authenticator.AUTHTYPE_CONTAINER = 'container';
|
|
49
50
|
Authenticator.AUTHTYPE_CP4D = 'cp4d';
|
|
50
51
|
Authenticator.AUTHTYPE_NOAUTH = 'noAuth';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* (C) Copyright IBM Corp. 2019,
|
|
2
|
+
* (C) Copyright IBM Corp. 2019, 2024.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import extend from 'extend';
|
|
17
17
|
import { computeBasicAuthHeader, validateInput } from '../utils/helpers';
|
|
18
18
|
import { Authenticator } from './authenticator';
|
|
19
|
+
import logger from '../../lib/logger';
|
|
19
20
|
/**
|
|
20
21
|
* The BasicAuthenticator is used to add basic authentication information to
|
|
21
22
|
* requests.
|
|
@@ -55,6 +56,7 @@ export class BasicAuthenticator extends Authenticator {
|
|
|
55
56
|
authenticate(requestOptions) {
|
|
56
57
|
return new Promise((resolve) => {
|
|
57
58
|
requestOptions.headers = extend(true, {}, requestOptions.headers, this.authHeader);
|
|
59
|
+
logger.debug(`Authenticated outbound request (type=${this.authenticationType()})`);
|
|
58
60
|
resolve();
|
|
59
61
|
});
|
|
60
62
|
}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import extend from 'extend';
|
|
17
17
|
import { validateInput } from '../utils/helpers';
|
|
18
18
|
import { Authenticator } from './authenticator';
|
|
19
|
+
import logger from '../../lib/logger';
|
|
19
20
|
/**
|
|
20
21
|
* The BearerTokenAuthenticator will set a user-provided bearer token
|
|
21
22
|
* in requests.
|
|
@@ -60,6 +61,7 @@ export class BearerTokenAuthenticator extends Authenticator {
|
|
|
60
61
|
return new Promise((resolve) => {
|
|
61
62
|
const authHeader = { Authorization: `Bearer ${this.bearerToken}` };
|
|
62
63
|
requestOptions.headers = extend(true, {}, requestOptions.headers, authHeader);
|
|
64
|
+
logger.debug(`Authenticated outbound request (type=${this.authenticationType()})`);
|
|
63
65
|
resolve();
|
|
64
66
|
});
|
|
65
67
|
}
|
|
@@ -81,4 +81,10 @@ export declare class ContainerAuthenticator extends IamRequestBasedAuthenticator
|
|
|
81
81
|
* @returns a string that indicates the authenticator's type
|
|
82
82
|
*/
|
|
83
83
|
authenticationType(): string;
|
|
84
|
+
/**
|
|
85
|
+
* Return the most recently stored refresh token.
|
|
86
|
+
*
|
|
87
|
+
* @returns the refresh token string
|
|
88
|
+
*/
|
|
89
|
+
getRefreshToken(): string;
|
|
84
90
|
}
|
|
@@ -93,4 +93,12 @@ export class ContainerAuthenticator extends IamRequestBasedAuthenticator {
|
|
|
93
93
|
authenticationType() {
|
|
94
94
|
return Authenticator.AUTHTYPE_CONTAINER;
|
|
95
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Return the most recently stored refresh token.
|
|
98
|
+
*
|
|
99
|
+
* @returns the refresh token string
|
|
100
|
+
*/
|
|
101
|
+
getRefreshToken() {
|
|
102
|
+
return this.tokenManager.getRefreshToken();
|
|
103
|
+
}
|
|
96
104
|
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* (C) Copyright IBM Corp. 2024.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { IamAssumeTokenManager } from '../token-managers';
|
|
17
|
+
import { IamRequestOptions, IamRequestBasedAuthenticatorImmutable } from './iam-request-based-authenticator-immutable';
|
|
18
|
+
/** Configuration options for IAM Assume authentication. */
|
|
19
|
+
export interface Options extends IamRequestOptions {
|
|
20
|
+
/** The IAM api key */
|
|
21
|
+
apikey: string;
|
|
22
|
+
/**
|
|
23
|
+
* Specify exactly one of [iamProfileId, iamProfileCrn, or iamProfileName] to
|
|
24
|
+
* identify the trusted profile whose identity should be used. If iamProfileId
|
|
25
|
+
* or iamProfileCrn is used, the trusted profile must exist in the same account.
|
|
26
|
+
* If and only if iamProfileName is used, then iamAccountId must also be
|
|
27
|
+
* specified to indicate the account that contains the trusted profile.
|
|
28
|
+
*/
|
|
29
|
+
iamProfileId?: string;
|
|
30
|
+
iamProfileCrn?: string;
|
|
31
|
+
iamProfileName?: string;
|
|
32
|
+
/**
|
|
33
|
+
* If and only if iamProfileName is used to specify the trusted profile, then
|
|
34
|
+
* iamAccountId must also be specified to indicate the account that contains
|
|
35
|
+
* the trusted profile.
|
|
36
|
+
*/
|
|
37
|
+
iamAccountId?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The IamAssumeAuthenticator obtains an IAM access token using the IAM "get-token"
|
|
41
|
+
* operation's "assume" grant type. The authenticator obtains an initial IAM access
|
|
42
|
+
* token from a user-supplied apikey, then exchanges this initial IAM access token
|
|
43
|
+
* for another IAM access token that has "assumed the identity" of the specified
|
|
44
|
+
* trusted profile.
|
|
45
|
+
*
|
|
46
|
+
* The bearer token will be sent as an Authorization header in the form:
|
|
47
|
+
*
|
|
48
|
+
* Authorization: Bearer \<bearer-token\>
|
|
49
|
+
*/
|
|
50
|
+
export declare class IamAssumeAuthenticator extends IamRequestBasedAuthenticatorImmutable {
|
|
51
|
+
protected tokenManager: IamAssumeTokenManager;
|
|
52
|
+
/**
|
|
53
|
+
*
|
|
54
|
+
* Create a new IamAssumeAuthenticator instance.
|
|
55
|
+
*
|
|
56
|
+
* @param options - Configuration options for IAM authentication.
|
|
57
|
+
* This should be an object containing these fields:
|
|
58
|
+
* - apikey: (required) the IAM api key for initial token request
|
|
59
|
+
* - iamProfileId: (optional) the ID of the trusted profile to use
|
|
60
|
+
* - iamProfileCrn: (optional) the CRN of the trusted profile to use
|
|
61
|
+
* - iamProfileName: (optional) the name of the trusted profile to use (must be specified with iamAccountId)
|
|
62
|
+
* - iamAccountId: (optional) the ID of the account the trusted profile is in (must be specified with iamProfileName)
|
|
63
|
+
* - url: (optional) the endpoint URL for the token service
|
|
64
|
+
* - disableSslVerification: (optional) a flag that indicates whether verification of the token server's SSL certificate
|
|
65
|
+
* should be disabled or not
|
|
66
|
+
* - headers: (optional) a set of HTTP headers to be sent with each request to the token service
|
|
67
|
+
* - clientId: (optional) the "clientId" and "clientSecret" fields are used to form a Basic
|
|
68
|
+
* Authorization header to be included in each request to the token service
|
|
69
|
+
* - clientSecret: (optional) the "clientId" and "clientSecret" fields are used to form a Basic
|
|
70
|
+
* Authorization header to be included in each request to the token service
|
|
71
|
+
* - scope: (optional) the "scope" parameter to use when fetching the bearer token from the token service
|
|
72
|
+
*
|
|
73
|
+
* @throws Error: the configuration options are not valid.
|
|
74
|
+
*/
|
|
75
|
+
constructor(options: Options);
|
|
76
|
+
/**
|
|
77
|
+
* Returns the authenticator's type ('iamAssume').
|
|
78
|
+
*
|
|
79
|
+
* @returns a string that indicates the authenticator's type
|
|
80
|
+
*/
|
|
81
|
+
authenticationType(): string;
|
|
82
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* (C) Copyright IBM Corp. 2024.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { Authenticator } from './authenticator';
|
|
17
|
+
import { IamAssumeTokenManager } from '../token-managers';
|
|
18
|
+
import { IamRequestBasedAuthenticatorImmutable, } from './iam-request-based-authenticator-immutable';
|
|
19
|
+
/**
|
|
20
|
+
* The IamAssumeAuthenticator obtains an IAM access token using the IAM "get-token"
|
|
21
|
+
* operation's "assume" grant type. The authenticator obtains an initial IAM access
|
|
22
|
+
* token from a user-supplied apikey, then exchanges this initial IAM access token
|
|
23
|
+
* for another IAM access token that has "assumed the identity" of the specified
|
|
24
|
+
* trusted profile.
|
|
25
|
+
*
|
|
26
|
+
* The bearer token will be sent as an Authorization header in the form:
|
|
27
|
+
*
|
|
28
|
+
* Authorization: Bearer \<bearer-token\>
|
|
29
|
+
*/
|
|
30
|
+
export class IamAssumeAuthenticator extends IamRequestBasedAuthenticatorImmutable {
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* Create a new IamAssumeAuthenticator instance.
|
|
34
|
+
*
|
|
35
|
+
* @param options - Configuration options for IAM authentication.
|
|
36
|
+
* This should be an object containing these fields:
|
|
37
|
+
* - apikey: (required) the IAM api key for initial token request
|
|
38
|
+
* - iamProfileId: (optional) the ID of the trusted profile to use
|
|
39
|
+
* - iamProfileCrn: (optional) the CRN of the trusted profile to use
|
|
40
|
+
* - iamProfileName: (optional) the name of the trusted profile to use (must be specified with iamAccountId)
|
|
41
|
+
* - iamAccountId: (optional) the ID of the account the trusted profile is in (must be specified with iamProfileName)
|
|
42
|
+
* - url: (optional) the endpoint URL for the token service
|
|
43
|
+
* - disableSslVerification: (optional) a flag that indicates whether verification of the token server's SSL certificate
|
|
44
|
+
* should be disabled or not
|
|
45
|
+
* - headers: (optional) a set of HTTP headers to be sent with each request to the token service
|
|
46
|
+
* - clientId: (optional) the "clientId" and "clientSecret" fields are used to form a Basic
|
|
47
|
+
* Authorization header to be included in each request to the token service
|
|
48
|
+
* - clientSecret: (optional) the "clientId" and "clientSecret" fields are used to form a Basic
|
|
49
|
+
* Authorization header to be included in each request to the token service
|
|
50
|
+
* - scope: (optional) the "scope" parameter to use when fetching the bearer token from the token service
|
|
51
|
+
*
|
|
52
|
+
* @throws Error: the configuration options are not valid.
|
|
53
|
+
*/
|
|
54
|
+
constructor(options) {
|
|
55
|
+
super(options);
|
|
56
|
+
// The param names are shared between the authenticator and the token
|
|
57
|
+
// manager so we can just pass along the options object. This will
|
|
58
|
+
// also perform input validation on the options.
|
|
59
|
+
this.tokenManager = new IamAssumeTokenManager(options);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Returns the authenticator's type ('iamAssume').
|
|
63
|
+
*
|
|
64
|
+
* @returns a string that indicates the authenticator's type
|
|
65
|
+
*/
|
|
66
|
+
// eslint-disable-next-line class-methods-use-this
|
|
67
|
+
authenticationType() {
|
|
68
|
+
return Authenticator.AUTHTYPE_IAM_ASSUME;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -61,4 +61,10 @@ export declare class IamAuthenticator extends IamRequestBasedAuthenticator {
|
|
|
61
61
|
* @returns a string that indicates the authenticator's type
|
|
62
62
|
*/
|
|
63
63
|
authenticationType(): string;
|
|
64
|
+
/**
|
|
65
|
+
* Return the most recently stored refresh token.
|
|
66
|
+
*
|
|
67
|
+
* @returns the refresh token string
|
|
68
|
+
*/
|
|
69
|
+
getRefreshToken(): string;
|
|
64
70
|
}
|
|
@@ -66,4 +66,12 @@ export class IamAuthenticator extends IamRequestBasedAuthenticator {
|
|
|
66
66
|
authenticationType() {
|
|
67
67
|
return Authenticator.AUTHTYPE_IAM;
|
|
68
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Return the most recently stored refresh token.
|
|
71
|
+
*
|
|
72
|
+
* @returns the refresh token string
|
|
73
|
+
*/
|
|
74
|
+
getRefreshToken() {
|
|
75
|
+
return this.tokenManager.getRefreshToken();
|
|
76
|
+
}
|
|
69
77
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* (C) Copyright IBM Corp. 2024.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { IamRequestBasedTokenManager } from '../token-managers/iam-request-based-token-manager';
|
|
17
|
+
import { BaseOptions, TokenRequestBasedAuthenticatorImmutable } from './token-request-based-authenticator-immutable';
|
|
18
|
+
/** Configuration options for IAM Request based authentication. */
|
|
19
|
+
export interface IamRequestOptions extends BaseOptions {
|
|
20
|
+
/**
|
|
21
|
+
* The `clientId` and `clientSecret` fields are used to form a "basic"
|
|
22
|
+
* authorization header for IAM token requests.
|
|
23
|
+
*/
|
|
24
|
+
clientId?: string;
|
|
25
|
+
/**
|
|
26
|
+
* The `clientId` and `clientSecret` fields are used to form a "basic"
|
|
27
|
+
* authorization header for IAM token requests.
|
|
28
|
+
*/
|
|
29
|
+
clientSecret?: string;
|
|
30
|
+
/**
|
|
31
|
+
* The "scope" parameter to use when fetching the bearer token from the IAM token server.
|
|
32
|
+
*/
|
|
33
|
+
scope?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The IamRequestBasedAuthenticatorImmutable provides shared configuration and functionality
|
|
37
|
+
* for authenticators that interact with the IAM token service. This authenticator
|
|
38
|
+
* is not meant for use on its own.
|
|
39
|
+
*/
|
|
40
|
+
export declare class IamRequestBasedAuthenticatorImmutable extends TokenRequestBasedAuthenticatorImmutable {
|
|
41
|
+
protected tokenManager: IamRequestBasedTokenManager;
|
|
42
|
+
protected clientId: string;
|
|
43
|
+
protected clientSecret: string;
|
|
44
|
+
protected scope: string;
|
|
45
|
+
/**
|
|
46
|
+
*
|
|
47
|
+
* Create a new IamRequestBasedAuthenticatorImmutable instance.
|
|
48
|
+
*
|
|
49
|
+
* @param options - Configuration options for IAM authentication.
|
|
50
|
+
* This should be an object containing these fields:
|
|
51
|
+
* - url: (optional) the endpoint URL for the token service
|
|
52
|
+
* - disableSslVerification: (optional) a flag that indicates whether verification of the token server's SSL certificate
|
|
53
|
+
* should be disabled or not
|
|
54
|
+
* - headers: (optional) a set of HTTP headers to be sent with each request to the token service
|
|
55
|
+
* - clientId: (optional) the "clientId" and "clientSecret" fields are used to form a Basic
|
|
56
|
+
* Authorization header to be included in each request to the token service
|
|
57
|
+
* - clientSecret: (optional) the "clientId" and "clientSecret" fields are used to form a Basic
|
|
58
|
+
* Authorization header to be included in each request to the token service
|
|
59
|
+
* - scope: (optional) the "scope" parameter to use when fetching the bearer token from the token service
|
|
60
|
+
*
|
|
61
|
+
* @throws Error: the configuration options are not valid.
|
|
62
|
+
*/
|
|
63
|
+
constructor(options: IamRequestOptions);
|
|
64
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* (C) Copyright IBM Corp. 2024.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { IamRequestBasedTokenManager } from '../token-managers/iam-request-based-token-manager';
|
|
17
|
+
import { TokenRequestBasedAuthenticatorImmutable, } from './token-request-based-authenticator-immutable';
|
|
18
|
+
/**
|
|
19
|
+
* The IamRequestBasedAuthenticatorImmutable provides shared configuration and functionality
|
|
20
|
+
* for authenticators that interact with the IAM token service. This authenticator
|
|
21
|
+
* is not meant for use on its own.
|
|
22
|
+
*/
|
|
23
|
+
export class IamRequestBasedAuthenticatorImmutable extends TokenRequestBasedAuthenticatorImmutable {
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* Create a new IamRequestBasedAuthenticatorImmutable instance.
|
|
27
|
+
*
|
|
28
|
+
* @param options - Configuration options for IAM authentication.
|
|
29
|
+
* This should be an object containing these fields:
|
|
30
|
+
* - url: (optional) the endpoint URL for the token service
|
|
31
|
+
* - disableSslVerification: (optional) a flag that indicates whether verification of the token server's SSL certificate
|
|
32
|
+
* should be disabled or not
|
|
33
|
+
* - headers: (optional) a set of HTTP headers to be sent with each request to the token service
|
|
34
|
+
* - clientId: (optional) the "clientId" and "clientSecret" fields are used to form a Basic
|
|
35
|
+
* Authorization header to be included in each request to the token service
|
|
36
|
+
* - clientSecret: (optional) the "clientId" and "clientSecret" fields are used to form a Basic
|
|
37
|
+
* Authorization header to be included in each request to the token service
|
|
38
|
+
* - scope: (optional) the "scope" parameter to use when fetching the bearer token from the token service
|
|
39
|
+
*
|
|
40
|
+
* @throws Error: the configuration options are not valid.
|
|
41
|
+
*/
|
|
42
|
+
constructor(options) {
|
|
43
|
+
// all parameters are optional
|
|
44
|
+
options = options || {};
|
|
45
|
+
super(options);
|
|
46
|
+
this.clientId = options.clientId;
|
|
47
|
+
this.clientSecret = options.clientSecret;
|
|
48
|
+
this.scope = options.scope;
|
|
49
|
+
this.tokenManager = new IamRequestBasedTokenManager(options);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* (C) Copyright IBM Corp. 2019,
|
|
2
|
+
* (C) Copyright IBM Corp. 2019, 2024.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -13,54 +13,17 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
* The `clientId` and `clientSecret` fields are used to form a "basic"
|
|
22
|
-
* authorization header for IAM token requests.
|
|
23
|
-
*/
|
|
24
|
-
clientId?: string;
|
|
25
|
-
/**
|
|
26
|
-
* The `clientId` and `clientSecret` fields are used to form a "basic"
|
|
27
|
-
* authorization header for IAM token requests.
|
|
28
|
-
*/
|
|
29
|
-
clientSecret?: string;
|
|
30
|
-
/**
|
|
31
|
-
* The "scope" parameter to use when fetching the bearer token from the IAM token server.
|
|
32
|
-
*/
|
|
33
|
-
scope?: string;
|
|
34
|
-
}
|
|
16
|
+
/// <reference types="node" />
|
|
17
|
+
import { OutgoingHttpHeaders } from 'http';
|
|
18
|
+
import { IamRequestBasedAuthenticatorImmutable } from './iam-request-based-authenticator-immutable';
|
|
19
|
+
/** Shared configuration options for IAM Request based authentication. */
|
|
20
|
+
export { IamRequestOptions } from './iam-request-based-authenticator-immutable';
|
|
35
21
|
/**
|
|
36
22
|
* The IamRequestBasedAuthenticator provides shared configuration and functionality
|
|
37
23
|
* for authenticators that interact with the IAM token service. This authenticator
|
|
38
24
|
* is not meant for use on its own.
|
|
39
25
|
*/
|
|
40
|
-
export declare class IamRequestBasedAuthenticator extends
|
|
41
|
-
protected tokenManager: IamRequestBasedTokenManager;
|
|
42
|
-
protected clientId: string;
|
|
43
|
-
protected clientSecret: string;
|
|
44
|
-
protected scope: string;
|
|
45
|
-
/**
|
|
46
|
-
*
|
|
47
|
-
* Create a new IamRequestBasedAuthenticator instance.
|
|
48
|
-
*
|
|
49
|
-
* @param options - Configuration options for IAM authentication.
|
|
50
|
-
* This should be an object containing these fields:
|
|
51
|
-
* - url: (optional) the endpoint URL for the token service
|
|
52
|
-
* - disableSslVerification: (optional) a flag that indicates whether verification of the token server's SSL certificate
|
|
53
|
-
* should be disabled or not
|
|
54
|
-
* - headers: (optional) a set of HTTP headers to be sent with each request to the token service
|
|
55
|
-
* - clientId: (optional) the "clientId" and "clientSecret" fields are used to form a Basic
|
|
56
|
-
* Authorization header to be included in each request to the token service
|
|
57
|
-
* - clientSecret: (optional) the "clientId" and "clientSecret" fields are used to form a Basic
|
|
58
|
-
* Authorization header to be included in each request to the token service
|
|
59
|
-
* - scope: (optional) the "scope" parameter to use when fetching the bearer token from the token service
|
|
60
|
-
*
|
|
61
|
-
* @throws Error: the configuration options are not valid.
|
|
62
|
-
*/
|
|
63
|
-
constructor(options: IamRequestOptions);
|
|
26
|
+
export declare class IamRequestBasedAuthenticator extends IamRequestBasedAuthenticatorImmutable {
|
|
64
27
|
/**
|
|
65
28
|
* Setter for the mutually inclusive "clientId" and the "clientSecret" fields.
|
|
66
29
|
* @param clientId - the "clientId" value used to form a Basic Authorization header for IAM token requests
|
|
@@ -74,9 +37,18 @@ export declare class IamRequestBasedAuthenticator extends TokenRequestBasedAuthe
|
|
|
74
37
|
*/
|
|
75
38
|
setScope(scope: string): void;
|
|
76
39
|
/**
|
|
77
|
-
*
|
|
40
|
+
* Set the flag that indicates whether verification of the server's SSL
|
|
41
|
+
* certificate should be disabled or not.
|
|
42
|
+
*
|
|
43
|
+
* @param value - a flag that indicates whether verification of the
|
|
44
|
+
* token server's SSL certificate should be disabled or not.
|
|
45
|
+
*/
|
|
46
|
+
setDisableSslVerification(value: boolean): void;
|
|
47
|
+
/**
|
|
48
|
+
* Set headers.
|
|
78
49
|
*
|
|
79
|
-
* @
|
|
50
|
+
* @param headers - a set of HTTP headers to be sent with each outbound token server request.
|
|
51
|
+
* Overwrites previous default headers.
|
|
80
52
|
*/
|
|
81
|
-
|
|
53
|
+
setHeaders(headers: OutgoingHttpHeaders): void;
|
|
82
54
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* (C) Copyright IBM Corp. 2019,
|
|
2
|
+
* (C) Copyright IBM Corp. 2019, 2024.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -13,41 +13,13 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
17
|
-
import { TokenRequestBasedAuthenticator } from './token-request-based-authenticator';
|
|
16
|
+
import { IamRequestBasedAuthenticatorImmutable } from './iam-request-based-authenticator-immutable';
|
|
18
17
|
/**
|
|
19
18
|
* The IamRequestBasedAuthenticator provides shared configuration and functionality
|
|
20
19
|
* for authenticators that interact with the IAM token service. This authenticator
|
|
21
20
|
* is not meant for use on its own.
|
|
22
21
|
*/
|
|
23
|
-
export class IamRequestBasedAuthenticator extends
|
|
24
|
-
/**
|
|
25
|
-
*
|
|
26
|
-
* Create a new IamRequestBasedAuthenticator instance.
|
|
27
|
-
*
|
|
28
|
-
* @param options - Configuration options for IAM authentication.
|
|
29
|
-
* This should be an object containing these fields:
|
|
30
|
-
* - url: (optional) the endpoint URL for the token service
|
|
31
|
-
* - disableSslVerification: (optional) a flag that indicates whether verification of the token server's SSL certificate
|
|
32
|
-
* should be disabled or not
|
|
33
|
-
* - headers: (optional) a set of HTTP headers to be sent with each request to the token service
|
|
34
|
-
* - clientId: (optional) the "clientId" and "clientSecret" fields are used to form a Basic
|
|
35
|
-
* Authorization header to be included in each request to the token service
|
|
36
|
-
* - clientSecret: (optional) the "clientId" and "clientSecret" fields are used to form a Basic
|
|
37
|
-
* Authorization header to be included in each request to the token service
|
|
38
|
-
* - scope: (optional) the "scope" parameter to use when fetching the bearer token from the token service
|
|
39
|
-
*
|
|
40
|
-
* @throws Error: the configuration options are not valid.
|
|
41
|
-
*/
|
|
42
|
-
constructor(options) {
|
|
43
|
-
// all parameters are optional
|
|
44
|
-
options = options || {};
|
|
45
|
-
super(options);
|
|
46
|
-
this.clientId = options.clientId;
|
|
47
|
-
this.clientSecret = options.clientSecret;
|
|
48
|
-
this.scope = options.scope;
|
|
49
|
-
this.tokenManager = new IamRequestBasedTokenManager(options);
|
|
50
|
-
}
|
|
22
|
+
export class IamRequestBasedAuthenticator extends IamRequestBasedAuthenticatorImmutable {
|
|
51
23
|
/**
|
|
52
24
|
* Setter for the mutually inclusive "clientId" and the "clientSecret" fields.
|
|
53
25
|
* @param clientId - the "clientId" value used to form a Basic Authorization header for IAM token requests
|
|
@@ -70,11 +42,30 @@ export class IamRequestBasedAuthenticator extends TokenRequestBasedAuthenticator
|
|
|
70
42
|
this.tokenManager.setScope(scope);
|
|
71
43
|
}
|
|
72
44
|
/**
|
|
73
|
-
*
|
|
45
|
+
* Set the flag that indicates whether verification of the server's SSL
|
|
46
|
+
* certificate should be disabled or not.
|
|
47
|
+
*
|
|
48
|
+
* @param value - a flag that indicates whether verification of the
|
|
49
|
+
* token server's SSL certificate should be disabled or not.
|
|
50
|
+
*/
|
|
51
|
+
setDisableSslVerification(value) {
|
|
52
|
+
// if they try to pass in a non-boolean value,
|
|
53
|
+
// use the "truthy-ness" of the value
|
|
54
|
+
this.disableSslVerification = Boolean(value);
|
|
55
|
+
this.tokenManager.setDisableSslVerification(this.disableSslVerification);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Set headers.
|
|
74
59
|
*
|
|
75
|
-
* @
|
|
60
|
+
* @param headers - a set of HTTP headers to be sent with each outbound token server request.
|
|
61
|
+
* Overwrites previous default headers.
|
|
76
62
|
*/
|
|
77
|
-
|
|
78
|
-
|
|
63
|
+
setHeaders(headers) {
|
|
64
|
+
if (typeof headers !== 'object') {
|
|
65
|
+
// do nothing, for now
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
this.headers = headers;
|
|
69
|
+
this.tokenManager.setHeaders(this.headers);
|
|
79
70
|
}
|
|
80
71
|
}
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
*
|
|
20
20
|
* Basic Authentication
|
|
21
21
|
* Bearer Token
|
|
22
|
-
* Identity and Access Management (IAM)
|
|
22
|
+
* Identity and Access Management (IAM, grant type: apikey)
|
|
23
|
+
* Identity and Access Management (IAM, grant type: assume)
|
|
23
24
|
* Container (IKS, etc)
|
|
24
25
|
* VPC Instance
|
|
25
26
|
* Cloud Pak for Data
|
|
@@ -35,6 +36,7 @@
|
|
|
35
36
|
* BearerTokenAuthenticator: Authenticator for passing supplied bearer token to service endpoint.
|
|
36
37
|
* CloudPakForDataAuthenticator: Authenticator for passing CP4D authentication information to service endpoint.
|
|
37
38
|
* IAMAuthenticator: Authenticator for passing IAM authentication information to service endpoint.
|
|
39
|
+
* IAMAssumeAuthenticator: Authenticator for passing IAM authentication information to service endpoint, assuming a trusted profile.
|
|
38
40
|
* ContainerAuthenticator: Authenticator for passing IAM authentication to a service, based on a token living on the container.
|
|
39
41
|
* VpcInstanceAuthenticator: Authenticator that uses the VPC Instance Metadata Service API to retrieve an IAM token.
|
|
40
42
|
* McspAuthenticator: Authenticator for passing MCSP authentication to a service endpoint.
|
|
@@ -52,3 +54,4 @@ export { IamRequestBasedAuthenticator } from './iam-request-based-authenticator'
|
|
|
52
54
|
export { TokenRequestBasedAuthenticator } from './token-request-based-authenticator';
|
|
53
55
|
export { VpcInstanceAuthenticator } from './vpc-instance-authenticator';
|
|
54
56
|
export { McspAuthenticator } from './mcsp-authenticator';
|
|
57
|
+
export { IamAssumeAuthenticator } from './iam-assume-authenticator';
|
|
@@ -24,3 +24,4 @@ export { IamRequestBasedAuthenticator } from './iam-request-based-authenticator'
|
|
|
24
24
|
export { TokenRequestBasedAuthenticator } from './token-request-based-authenticator';
|
|
25
25
|
export { VpcInstanceAuthenticator } from './vpc-instance-authenticator';
|
|
26
26
|
export { McspAuthenticator } from './mcsp-authenticator';
|
|
27
|
+
export { IamAssumeAuthenticator } from './iam-assume-authenticator';
|