Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iam: Phase I: API Key #151

Merged
merged 3 commits into from
Apr 17, 2019
Merged

iam: Phase I: API Key #151

merged 3 commits into from
Apr 17, 2019

Conversation

srl295
Copy link
Contributor

@srl295 srl295 commented Apr 17, 2019

Fixes #147

- iam_endpoint and apikey required
- new CLI options and variables
- test updates
- docs

Fixes: #147
@srl295 srl295 requested review from pgaglani1 and yumaoka April 17, 2019 01:43
@srl295 srl295 self-assigned this Apr 17, 2019
@coveralls
Copy link

coveralls commented Apr 17, 2019

Coverage Status

Coverage decreased (-1.9%) to 87.429% when pulling 603a60a on iam into a578eb8 on master.

var missingField = utils.isMissingField(this._options.credentials, Object.keys(Consts.exampleCredentials));
if (missingField.length !== 0) {
throw new Error("g11n-pipeline: missing credentials fields: \"" + missingField.join(' ') + "\" - expected: " + Consts.exampleCredentialsString);
if(this._options.credentials.apikey) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if apikey is present, assume it is IAM.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the assumption is correct

if(this._options.basicAuth) {
// ignore basicAuth.
// throw Error('basicAuth is not supported'); // TODO: support this- maybe?
if (this._options.credentials.apikey) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if apikey is present, use the IAM interceptor


const authHeader = this.API_KEY + ' ' + this.credentials.apikey;
if(this.VERBOSE) console.log('hmacHeader = ' + authHeader);
obj.headers.Authorization = authHeader;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the actual change.

@srl295
Copy link
Contributor Author

srl295 commented Apr 17, 2019

note that actually iam_endpoint is not actually used, but it will be in the future ( #150 ), so I want to require/document it now.

lib/gp-iam.js Outdated
if(obj.url.indexOf("/swagger.json") !== -1) return obj; // skip for swagger.json

const authHeader = this.API_KEY + ' ' + this.credentials.apikey;
if(this.VERBOSE) console.log('hmacHeader = ' + authHeader);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to log actual API_KEY in console?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only if VERBOSE is on.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that, but I wasn't sure if it should ever be logged, like we never log it in our server side code. So just wanted to make sure it is intentional. I don't know the best practice for JS.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will change it to Authorization: API-KEY **** (using replace to obfuscate the actual apikey)

Copy link

@sid4 sid4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

lib/gp-iam.js Outdated
if(obj.url.indexOf("/swagger.json") !== -1) return obj; // skip for swagger.json

const authHeader = this.API_KEY + ' ' + this.credentials.apikey;
if(this.VERBOSE) console.log('hmacHeader = ' + authHeader);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you really want hmacHeader= here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a debug comment, i can change it to authHeader

@srl295 srl295 requested a review from yumaoka April 17, 2019 19:36
Copy link

@yumaoka yumaoka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@srl295 srl295 merged commit 07059ed into master Apr 17, 2019
@srl295 srl295 deleted the iam branch April 17, 2019 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

js: IAM support phase I (apikey)
4 participants