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

Keys with spaces #10

Open
kw4n opened this issue May 17, 2011 · 7 comments
Open

Keys with spaces #10

kw4n opened this issue May 17, 2011 · 7 comments

Comments

@kw4n
Copy link

kw4n commented May 17, 2011

Keys with spaces aren't showing correctly i.e. "this is a key" doesn't show. You can access it via direct Riak link of course but Rekon UI doesn't work.

@adamhunter
Copy link
Contributor

"this is a key" shouldn't be accessible via the http interface because it doesn't translate to a valid URI. Unfortunately viewing keys that aren't accessible via the http interface is not something that can be worked around (as far as I know). I did discover interesting behavior in the Javascript client when encoding a space with a "+" or "%20" the JS client always uses %20 even though you can have different values at "test+key" and "test%20key" since riak does not decode the url. I'll be working on fixing this behavior with + vs %20.

@kw4n
Copy link
Author

kw4n commented May 18, 2011

Hmm, do you know if there's any good reason in Riak that I shouldn't use keys with spaces at all or is this just a problem with HTTP interface? I mean I'm using RiakJS and PHP Riak Client at the moment and I don't know if either one uses HTTP interface. However, Rekon is something that at least for me finally pushes Riak over Mongo & Couch in development efficiency so awesome job :)

@adamhunter
Copy link
Contributor

I think both of those are using the HTTP interface. The Riak PHP Client may be using protobuffs, but I don't think so. Using the http interface, your key must be part of a valid URI, which means the spaces must be encoded using + or %20.

@jbsmith
Copy link

jbsmith commented Jul 5, 2011

I also ran into this issue, and for me, the primary concern was related to using sessions from the connect middleware in express.

A workaround that I applied was this.

In the connect source code, modify the file at .../connect/lib/middleware/session.js to update the store hash function, and remove any instance of the '+' symbol by modifying the replace applied in the function.

This update makes the sessions viewable with the rekon interface. Might save you some time.

e.g.

~ @ line 221
// session hashing function
store.hash = function(req, base) {
return crypto
.createHmac('sha256', secret)
.update(base + fingerprint(req))
.digest('base64')
.replace(/+=*$/, ''); //<---------------------------------- '+' added to this line ---------->
};

@jbsmith
Copy link

jbsmith commented Jul 5, 2011

Actually,

I had tested this and it seemed to work, but I need to look further. There is something that I have missed, which needs further evaluation. In any case, try to eliminate spaces in your keys, and that should provide a workaround for now, if you can achieve it.

@jbsmith
Copy link

jbsmith commented Jul 5, 2011

This version has been tested further and seems to resolve the issue for sessions.
Actually what I found is that for riak, the '+' and the '/' are being created by the connect middleware for the session key.

The code below replaces those symbols with riak legal ones.

@ ~ line 221
// session hashing function
store.hash = function(req, base) {

return crypto
  .createHmac('sha256', secret)
  .update(base + fingerprint(req))
  .digest('base64')
  .replace(/=*$/g, '')
  .replace(/\+/g, '-')
  .replace(/\//g, '_');

};

@jbsmith
Copy link

jbsmith commented Jul 5, 2011

One final note, I am using express, and it is providing its own copy of the connect node_module.
Please modify the connect source underneath the express install in node_modules if you are using npm to install.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants