Meaningless replacing of slashes with dashes in PKI tokens

Bug #1352314 reported by Kirill Zaborsky
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
python-keystoneclient
Fix Released
Medium
Deepti Ramakrishna

Bug Description

It looks like Keystone uses some a bit strange conception of Base64 which does not include slashes - https://github.com/openstack/keystone/commit/bcc0f6d6fc1f674bc4b340d041b28bc1cfddf66a
http://tools.ietf.org/html/rfc4648 shows that slash is a valid Base64 character.

So currently for some unknown reason Keystone replaces slashes with dashes when returning tokens and does the opposite when reading tokens.

I understand that fixing this will break backwards compatibility but it makes sense at least to document this strange behaviour so developers accessing Keystone not with Keystone original bindings (e.g. from othe languages) will not be caught by surprise.

Revision history for this message
Dolph Mathews (dolph) wrote :

I completely agree - the methods doing the string manipulation don't give any clue behind the behavior either.

It's actually being done to ensure URL-safety, despite the existing presence of and lack of compatibility with the base64 module's URL-safe builtin methods:

  https://docs.python.org/2/library/base64.html#base64.urlsafe_b64encode

Changed in keystone:
status: New → Triaged
tags: added: documentation
Changed in keystone:
importance: Undecided → Medium
summary: - Meaningless replacing of slashes with dashes in Keystone tokens
+ Meaningless replacing of slashes with dashes in PKI tokens
tags: added: pki
Revision history for this message
Kirill Zaborsky (qrilka) wrote :

Yes, that incompatibility is the strangest thing to me

Revision history for this message
Adam Young (ayoung) wrote :

Unfortunately, we are stuck with it; changing it would break the working assumptions between Keystone server and client. I made that conversion as a simple way to get the Tokens to marshall via HTTP, and was guilty of not doing my homework. The newer PKIZ token format uses the Python base64 module to perform the url safe encoding. This is the version of tokens that wer are moving toward making standard, and removing the non-compressed, improperly base64 encoded version.

Revision history for this message
Kirill Zaborsky (qrilka) wrote :

My main point was that it makes sense to make it at least properly documented (unlit PKI tokens get deprecated) as the line "signed_text = signed_text.replace('/', '-')" in keystoneclient.common.cms.cms_to_token looks like some arbitrary replacement.

Revision history for this message
Dolph Mathews (dolph) wrote :

+1 for documenting the behavior, along with pretty much everything else in keystoneclient.common.cms

affects: keystone → python-keystoneclient
Changed in python-keystoneclient:
assignee: nobody → Deepti Ramakrishna (dramakri)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-keystoneclient (master)

Fix proposed to branch: master
Review: https://review.openstack.org/176230

Changed in python-keystoneclient:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-keystoneclient (master)

Reviewed: https://review.openstack.org/176230
Committed: https://git.openstack.org/cgit/openstack/python-keystoneclient/commit/?id=d5a39ad14a7505b86df1818fa01abb4225b1be43
Submitter: Jenkins
Branch: master

commit d5a39ad14a7505b86df1818fa01abb4225b1be43
Author: Deepti Ramakrishna <email address hidden>
Date: Tue Apr 21 21:56:25 2015 -0700

    Document non-standard encoding of the PKI token.

    More details by the code author in his blog post at
    http://adam.younglogic.com/2014/02/compressed-tokens/.

    Change-Id: I35c5eca2e04a74236bd8c7fb6daab3ea46b59b0e
    Closes-Bug: #1352314

Changed in python-keystoneclient:
status: In Progress → Fix Committed
Changed in python-keystoneclient:
milestone: none → 1.4.0
Changed in python-keystoneclient:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.