Skip to content

Commit

Permalink
fix: read iam client id and secret from environment variables (#30)
Browse files Browse the repository at this point in the history
* fix: read iam client id and secret from environment variables

* build: update vulnerable dependency
  • Loading branch information
dpopp07 authored Jun 23, 2019
1 parent 018c075 commit 2247d0a
Show file tree
Hide file tree
Showing 4 changed files with 192 additions and 119 deletions.
12 changes: 12 additions & 0 deletions lib/base_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ export interface Credentials {
iam_access_token?: string;
iam_apikey?: string;
iam_url?: string;
iam_client_id?: string;
iam_client_secret?: string;
authentication_type?: string;
}

Expand Down Expand Up @@ -243,6 +245,12 @@ export class BaseService {
if (this._options.iam_url) {
credentials.iam_url = this._options.iam_url;
}
if (this._options.iam_client_id) {
credentials.iam_client_id = this._options.iam_client_id;
}
if (this._options.iam_client_secret) {
credentials.iam_client_secret = this._options.iam_client_secret;
}
if (this._options.icp4d_access_token) {
credentials.icp4d_access_token = this._options.icp4d_access_token;
}
Expand Down Expand Up @@ -421,6 +429,8 @@ export class BaseService {
const iamAccessToken: string = envObj[`${_name}_IAM_ACCESS_TOKEN`] || envObj[`${nameWithUnderscore}_IAM_ACCESS_TOKEN`];
const iamApiKey: string = envObj[`${_name}_IAM_APIKEY`] || envObj[`${nameWithUnderscore}_IAM_APIKEY`];
const iamUrl: string = envObj[`${_name}_IAM_URL`] || envObj[`${nameWithUnderscore}_IAM_URL`];
const iamClientId: string = envObj[`${_name}_IAM_CLIENT_ID`] || envObj[`${_name}_IAM_CLIENT_ID`];
const iamClientSecret: string = envObj[`${_name}_IAM_CLIENT_SECRET`] || envObj[`${_name}_IAM_CLIENT_SECRET`];
const icp4dAccessToken: string = envObj[`${_name}_ICP4D_ACCESS_TOKEN`] || envObj[`${nameWithUnderscore}_ICP4D_ACCESS_TOKEN`];
const icp4dUrl: string = envObj[`${_name}_ICP4D_URL`] || envObj[`${nameWithUnderscore}_ICP4D_URL`];
const authenticationType: string = envObj[`${_name}_AUTHENTICATION_TYPE`] || envObj[`${nameWithUnderscore}_AUTHENTICATION_TYPE`];
Expand All @@ -432,6 +442,8 @@ export class BaseService {
iam_access_token: iamAccessToken,
iam_apikey: iamApiKey,
iam_url: iamUrl,
iam_client_id: iamClientId,
iam_client_secret: iamClientSecret,
icp4d_access_token: icp4dAccessToken,
icp4d_url: icp4dUrl,
authentication_type: authenticationType,
Expand Down
Loading

0 comments on commit 2247d0a

Please sign in to comment.