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

feat: add new token manager for ICP4D #26

Merged
merged 19 commits into from
Jun 5, 2019
Merged

Conversation

dpopp07
Copy link
Member

@dpopp07 dpopp07 commented May 28, 2019

Changes:

  • Introduced a constructor parameter, authentication_type, for specifying the authentication pattern. This will be required for using ICP4D
  • A new token manager is added, handling ICP4D-style requests
  • I created a new generic class, called JwtTokenManager for all token-managing needs. This is a base class for the new ICP token manager. I also refactored the IAM token manger to extend the new JWT class too

I still need to write tests but want to start getting feedback on the implementation now, so I don't have to re-write the tests too many times

TODO:

  • Write tests
  • Add documentation to the README for using authentication_type
  • Add a second URL parameter for ICP4D authentication

cc @ehdsouza @mediumTaj @lpatino10 @mamoonraja

Introduce a constructor parameter, `authentication_type`, for specifying the authentication pattern. Required for using ICP4D
@dpopp07 dpopp07 changed the title feat: add new token manager for ICP4D feat: add new token manager for ICP4D - DO NOT MERGE May 28, 2019
@dpopp07 dpopp07 changed the title feat: add new token manager for ICP4D - DO NOT MERGE feat: add new token manager for ICP4D - IN PROGRESS May 28, 2019
Copy link
Contributor

@mkistler mkistler left a comment

Choose a reason for hiding this comment

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

Here's a first batch of comments.

auth/icp-token-manager.ts Outdated Show resolved Hide resolved
auth/icp-token-manager.ts Outdated Show resolved Hide resolved
auth/icp-token-manager.ts Outdated Show resolved Hide resolved
auth/jwt-token-manager.ts Outdated Show resolved Hide resolved
auth/jwt-token-manager.ts Outdated Show resolved Hide resolved
auth/jwt-token-manager.ts Outdated Show resolved Hide resolved
auth/icp-token-manager.ts Outdated Show resolved Hide resolved
iam-token-manager/v1.ts Show resolved Hide resolved
auth/jwt-token-manager.ts Outdated Show resolved Hide resolved
@lpatino10
Copy link

Should we rename the IcpTokenManagerV1 class to something like Icp4dTokenManagerV1? The name's kind of obnoxious but I think it might be more clear, since ICP and ICP4D are different and use different auth methods. I could see someone getting tripped up by that.

@dpopp07
Copy link
Member Author

dpopp07 commented May 28, 2019

It is ICP4D specific, so that's definitely not a bad idea. I'll make that change, unless anyone disagrees. Definitely a bit of an obnoxious name haha

@codecov
Copy link

codecov bot commented May 29, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@6d24f0a). Click here to learn what that means.
The diff coverage is 99.26%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master      #26   +/-   ##
=========================================
  Coverage          ?   93.26%           
=========================================
  Files             ?       12           
  Lines             ?      505           
  Branches          ?      147           
=========================================
  Hits              ?      471           
  Misses            ?       33           
  Partials          ?        1
Impacted Files Coverage Δ
lib/requestwrapper.ts 84.49% <ø> (ø)
auth/jwt-token-manager-v1.ts 100% <100%> (ø)
auth/utils.ts 100% <100%> (ø)
iam-token-manager/v1.ts 100% <100%> (ø)
auth/icp4d-token-manager-v1.ts 100% <100%> (ø)
auth/index.ts 100% <100%> (ø)
auth/iam-token-manager-v1.ts 100% <100%> (ø)
lib/base_service.ts 92.3% <96.29%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6d24f0a...dc3165d. Read the comment docs.

@dpopp07 dpopp07 changed the title feat: add new token manager for ICP4D - IN PROGRESS feat: add new token manager for ICP4D May 31, 2019
@dpopp07
Copy link
Member Author

dpopp07 commented May 31, 2019

Okay last minute (small) changes have been made and all tests have been added. Officially ready for final review

@germanattanasio @mkistler @padamstx

Copy link
Contributor

@mkistler mkistler left a comment

Choose a reason for hiding this comment

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

I left a few comments that I hope you will address, but in any event I think the code here is okay to merge.

@@ -0,0 +1,158 @@
/**
* Copyright 2015 IBM Corp. All Rights Reserved.
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to check copyright date on this file.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that's certainly wrong. The IAM token manager was originally written in 2018 but this specific file in this repo was added in 2019. So - should it be 2018, 2019 or 2019?

auth/jwt-token-manager-v1.ts Show resolved Hide resolved
auth/jwt-token-manager-v1.ts Outdated Show resolved Hide resolved
lib/base_service.ts Outdated Show resolved Hide resolved
Copy link
Member

@mediumTaj mediumTaj left a comment

Choose a reason for hiding this comment

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

👍 looks good! There are a few references to refresh tokens - Are we still refreshing tokens or are all of these meant for compatibility?

@dpopp07
Copy link
Member Author

dpopp07 commented Jun 4, 2019

We're not using refresh tokens anymore. We are requesting a new token when the token is expired and I might have referred to that as a "refresh" but I agree that may be misleading. I'll update that

@dpopp07 dpopp07 changed the title feat: add new token manager for ICP4D WIP: feat: add new token manager for ICP4D Jun 5, 2019
@germanattanasio germanattanasio changed the title WIP: feat: add new token manager for ICP4D feat: add new token manager for ICP4D Jun 5, 2019
lib/base_service.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@germanattanasio germanattanasio left a comment

Choose a reason for hiding this comment

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

left a few comments but looks OK

Copy link
Member

@padamstx padamstx left a comment

Choose a reason for hiding this comment

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

LGTM

@germanattanasio germanattanasio merged commit 2097a64 into master Jun 5, 2019
ibm-devx-automation pushed a commit that referenced this pull request Jun 5, 2019
# [0.3.0](v0.2.8...v0.3.0) (2019-06-05)

### Features

* add `IcpTokenManagerV1` as a top-level export of the package ([cfa3e1b](cfa3e1b))
* add new token manager for ICP4D ([ee1ddad](ee1ddad))
* add new token manager for ICP4D ([#26](#26)) ([2097a64](2097a64))
* carry `disable_ssl_verification` through to token managers ([4f2f789](4f2f789))
@ibm-devx-automation
Copy link

🎉 This PR is included in version 0.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@dpopp07 dpopp07 deleted the icp4d-authentication branch June 5, 2019 21:27
@germanattanasio
Copy link
Contributor

@dpopp07 can you add an icon to ibm-devx-automation 😛 ?

@esminerva
Copy link
Contributor

no

@dpopp07
Copy link
Member Author

dpopp07 commented Jun 6, 2019

Haha I would if I could 🤷‍♂

@dpopp07
Copy link
Member Author

dpopp07 commented Jun 6, 2019

@germanattanasio Oh wait, it looks like it does have an icon!

JurajNyiri pushed a commit to JurajNyiri/node-sdk-core that referenced this pull request Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants