ibm-cloud-sdk-core
Advanced tools
Comparing version 2.8.2 to 2.9.0
@@ -22,4 +22,6 @@ /** | ||
username: string; | ||
/** The password used to obtain a bearer token. */ | ||
password: string; | ||
/** The password used to obtain a bearer token [required if apikey not specified]. */ | ||
password?: string; | ||
/** The API key used to obtain a bearer token [required if password not specified]. */ | ||
apikey?: string; | ||
/** The URL representing the Cloud Pak for Data token service endpoint. */ | ||
@@ -29,3 +31,3 @@ url: string; | ||
/** | ||
* The [[CloudPakForDataAuthenticator]] will use the user-supplied url, username and password values to obtain | ||
* The [[CloudPakForDataAuthenticator]] will either use a username/password pair or a username/apikey pair to obtain | ||
* a bearer token from a token server. When the bearer token expires, a new token is obtained from the token server. | ||
@@ -42,2 +44,3 @@ * | ||
private password; | ||
private apikey; | ||
/** | ||
@@ -49,3 +52,4 @@ * Create a new [[CloudPakForDataAuthenticator]] instance. | ||
* @param {string} options.username The username used to obtain a bearer token. | ||
* @param {string} options.password The password used to obtain a bearer token. | ||
* @param {string} [options.password] The password used to obtain a bearer token [required if apikey not specified]. | ||
* @param {string} [options.apikey] The API key used to obtain a bearer token [required if password not specified]. | ||
* @param {boolean} [options.disableSslVerification] A flag that indicates | ||
@@ -52,0 +56,0 @@ * whether verification of the token server's SSL certificate should be |
@@ -32,6 +32,5 @@ "use strict"; | ||
var token_managers_1 = require("../token-managers"); | ||
var utils_1 = require("../utils"); | ||
var token_request_based_authenticator_1 = require("./token-request-based-authenticator"); | ||
/** | ||
* The [[CloudPakForDataAuthenticator]] will use the user-supplied url, username and password values to obtain | ||
* The [[CloudPakForDataAuthenticator]] will either use a username/password pair or a username/apikey pair to obtain | ||
* a bearer token from a token server. When the bearer token expires, a new token is obtained from the token server. | ||
@@ -51,3 +50,4 @@ * | ||
* @param {string} options.username The username used to obtain a bearer token. | ||
* @param {string} options.password The password used to obtain a bearer token. | ||
* @param {string} [options.password] The password used to obtain a bearer token [required if apikey not specified]. | ||
* @param {string} [options.apikey] The API key used to obtain a bearer token [required if password not specified]. | ||
* @param {boolean} [options.disableSslVerification] A flag that indicates | ||
@@ -62,8 +62,9 @@ * whether verification of the token server's SSL certificate should be | ||
var _this = _super.call(this, options) || this; | ||
_this.requiredOptions = ['username', 'password', 'url']; | ||
utils_1.validateInput(options, _this.requiredOptions); | ||
_this.requiredOptions = ['username', 'url']; | ||
_this.username = options.username; | ||
_this.password = options.password; | ||
_this.apikey = options.apikey; | ||
// the param names are shared between the authenticator and the token | ||
// manager so we can just pass along the options object | ||
// manager so we can just pass along the options object. | ||
// also, the token manager will handle input validation | ||
_this.tokenManager = new token_managers_1.Cp4dTokenManager(options); | ||
@@ -70,0 +71,0 @@ return _this; |
@@ -21,6 +21,8 @@ /** | ||
url: string; | ||
/** The username portion of basic authentication. */ | ||
/** The username used to obtain a bearer token. */ | ||
username: string; | ||
/** The password portion of basic authentication. */ | ||
password: string; | ||
/** The password used to obtain a bearer token [required if apikey not specified]. */ | ||
password?: string; | ||
/** The API key used to obtain a bearer token [required if password not specified]. */ | ||
apikey?: string; | ||
} | ||
@@ -49,2 +51,3 @@ export interface CpdTokenData { | ||
private password; | ||
private apikey; | ||
/** | ||
@@ -54,4 +57,5 @@ * Create a new [[Cp4dTokenManager]] instance. | ||
* @param {object} options Configuration options. | ||
* @param {string} options.username The username portion of basic authentication. | ||
* @param {string} options.password The password portion of basic authentication. | ||
* @param {string} options.username The username used to obtain a bearer token. | ||
* @param {string} options.password The password used to obtain a bearer token [required if apikey not specified]. | ||
* @param {string} options.apikey The API key used to obtain a bearer token [required if password not specified]. | ||
* @param {string} options.url The endpoint for CP4D token requests. | ||
@@ -58,0 +62,0 @@ * @param {boolean} [options.disableSslVerification] A flag that indicates |
@@ -46,4 +46,5 @@ "use strict"; | ||
* @param {object} options Configuration options. | ||
* @param {string} options.username The username portion of basic authentication. | ||
* @param {string} options.password The password portion of basic authentication. | ||
* @param {string} options.username The username used to obtain a bearer token. | ||
* @param {string} options.password The password used to obtain a bearer token [required if apikey not specified]. | ||
* @param {string} options.apikey The API key used to obtain a bearer token [required if password not specified]. | ||
* @param {string} options.url The endpoint for CP4D token requests. | ||
@@ -59,6 +60,9 @@ * @param {boolean} [options.disableSslVerification] A flag that indicates | ||
var _this = _super.call(this, options) || this; | ||
_this.requiredOptions = ['username', 'password', 'url']; | ||
_this.tokenName = 'accessToken'; | ||
_this.requiredOptions = ['username', 'url']; | ||
_this.tokenName = 'token'; | ||
if ((!options.password && !options.apikey) || (options.password && options.apikey)) { | ||
throw new Error('Exactly one of `apikey` or `password` must be specified.'); | ||
} | ||
utils_1.validateInput(options, _this.requiredOptions); | ||
var tokenApiPath = '/v1/preauth/validateAuth'; | ||
var tokenApiPath = '/v1/authorize'; | ||
// do not append the path if user already has | ||
@@ -70,2 +74,3 @@ if (_this.url && !_this.url.endsWith(tokenApiPath)) { | ||
_this.password = options.password; | ||
_this.apikey = options.apikey; | ||
return _this; | ||
@@ -76,3 +81,3 @@ } | ||
var requiredHeaders = { | ||
Authorization: utils_1.computeBasicAuthHeader(this.username, this.password), | ||
'Content-Type': 'application/json', | ||
}; | ||
@@ -82,3 +87,8 @@ var parameters = { | ||
url: this.url, | ||
method: 'GET', | ||
body: { | ||
username: this.username, | ||
password: this.password, | ||
api_key: this.apikey, | ||
}, | ||
method: 'POST', | ||
headers: extend(true, {}, this.headers, requiredHeaders), | ||
@@ -85,0 +95,0 @@ rejectUnauthorized: !this.disableSslVerification, |
@@ -0,1 +1,8 @@ | ||
# [2.9.0](https://github.com/IBM/node-sdk-core/compare/v2.8.2...v2.9.0) (2021-03-12) | ||
### Features | ||
* support username/apikey use-case in CloudPakForDataAuthenticator ([#126](https://github.com/IBM/node-sdk-core/issues/126)) ([a7ca3a0](https://github.com/IBM/node-sdk-core/commit/a7ca3a083b3580b1776544a2958c90c1608fcc7c)) | ||
## [2.8.2](https://github.com/IBM/node-sdk-core/compare/v2.8.1...v2.8.2) (2021-03-12) | ||
@@ -2,0 +9,0 @@ |
{ | ||
"name": "ibm-cloud-sdk-core", | ||
"version": "2.8.2", | ||
"version": "2.9.0", | ||
"description": "Core functionality to support SDKs generated with IBM's OpenAPI SDK Generator.", | ||
@@ -5,0 +5,0 @@ "main": "index", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
239820
4274