You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by GitBox <gi...@apache.org> on 2020/05/27 03:22:17 UTC

[GitHub] [libcloud] grimpy opened a new pull request #1462: G8driver refreshtoken

grimpy opened a new pull request #1462:
URL: https://github.com/apache/libcloud/pull/1462


   ## G8driver refreshtoken
   
   ### Description
   
   Update g8 driver fixed some small issues when creating portforwards
   And adds functionality to update the apitoken
   
   
   ### Status
   - done, ready for review
   
   ### Checklist (tick everything that applies)
   
   - [ ] [Code linting](http://libcloud.readthedocs.org/en/latest/development.html#code-style-guide) (required, can be done after the PR checks)
   - [x] [Tests](http://libcloud.readthedocs.org/en/latest/testing.html)
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [libcloud] grimpy commented on a change in pull request #1462: G8driver refreshtoken

Posted by GitBox <gi...@apache.org>.
grimpy commented on a change in pull request #1462:
URL: https://github.com/apache/libcloud/pull/1462#discussion_r430073307



##########
File path: libcloud/common/gig_g8.py
##########
@@ -26,6 +35,74 @@ def add_default_headers(self, headers):
         """
         Add headers that are necessary for every request
         """
+        self.driver.key = maybe_update_jwt(self.driver.key)
         headers['Authorization'] = "bearer {}".format(self.driver.key)
         headers['Content-Type'] = 'application/json'
         return headers
+
+
+def base64url_decode(input):
+    """
+    Helper method to base64url_decode a string.
+
+    :param input: Input to decode
+    :type  input: str
+
+    :rtype: str
+    """
+    rem = len(input) % 4
+
+    if rem > 0:
+        input += b'=' * (4 - rem)
+    return base64.urlsafe_b64decode(input)
+
+
+def is_jwt_expired(jwt):

Review comment:
       I added a test for expire and none expired scenarios, not sure what to do about 'forms of input string' the method would pretty much crash with split or encoding errors if you pass invalid formats




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [libcloud] Kami merged pull request #1462: G8driver refreshtoken

Posted by GitBox <gi...@apache.org>.
Kami merged pull request #1462:
URL: https://github.com/apache/libcloud/pull/1462


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [libcloud] Kami commented on pull request #1462: G8driver refreshtoken

Posted by GitBox <gi...@apache.org>.
Kami commented on pull request #1462:
URL: https://github.com/apache/libcloud/pull/1462#issuecomment-634925563


   Merged, thanks.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [libcloud] Kami commented on a change in pull request #1462: G8driver refreshtoken

Posted by GitBox <gi...@apache.org>.
Kami commented on a change in pull request #1462:
URL: https://github.com/apache/libcloud/pull/1462#discussion_r430063434



##########
File path: libcloud/common/gig_g8.py
##########
@@ -26,6 +35,74 @@ def add_default_headers(self, headers):
         """
         Add headers that are necessary for every request
         """
+        self.driver.key = maybe_update_jwt(self.driver.key)
         headers['Authorization'] = "bearer {}".format(self.driver.key)
         headers['Content-Type'] = 'application/json'
         return headers
+
+
+def base64url_decode(input):
+    """
+    Helper method to base64url_decode a string.
+
+    :param input: Input to decode
+    :type  input: str
+
+    :rtype: str
+    """
+    rem = len(input) % 4
+
+    if rem > 0:
+        input += b'=' * (4 - rem)
+    return base64.urlsafe_b64decode(input)
+
+
+def is_jwt_expired(jwt):

Review comment:
       Can you please add some unit tests for this function (covering both expired and non expired scenario, etc.).

##########
File path: libcloud/common/gig_g8.py
##########
@@ -26,6 +35,74 @@ def add_default_headers(self, headers):
         """
         Add headers that are necessary for every request
         """
+        self.driver.key = maybe_update_jwt(self.driver.key)
         headers['Authorization'] = "bearer {}".format(self.driver.key)
         headers['Content-Type'] = 'application/json'
         return headers
+
+
+def base64url_decode(input):
+    """
+    Helper method to base64url_decode a string.
+
+    :param input: Input to decode
+    :type  input: str
+
+    :rtype: str
+    """
+    rem = len(input) % 4
+
+    if rem > 0:
+        input += b'=' * (4 - rem)
+    return base64.urlsafe_b64decode(input)
+
+
+def is_jwt_expired(jwt):

Review comment:
       Can you please add some unit tests for this function (covering both expired and non expired scenario, various forms of input string, etc.).

##########
File path: libcloud/common/gig_g8.py
##########
@@ -26,6 +35,74 @@ def add_default_headers(self, headers):
         """
         Add headers that are necessary for every request
         """
+        self.driver.key = maybe_update_jwt(self.driver.key)
         headers['Authorization'] = "bearer {}".format(self.driver.key)
         headers['Content-Type'] = 'application/json'
         return headers
+
+
+def base64url_decode(input):
+    """
+    Helper method to base64url_decode a string.
+
+    :param input: Input to decode
+    :type  input: str
+
+    :rtype: str
+    """
+    rem = len(input) % 4
+
+    if rem > 0:
+        input += b'=' * (4 - rem)
+    return base64.urlsafe_b64decode(input)
+
+
+def is_jwt_expired(jwt):

Review comment:
       Thanks.
   
   This should be fine for now.
   
   With different forms of input strings, I meant thing such as JWT string payload missing some fields, being corrupted, etc. and making sure we handle that correctly.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org