Closed pini-gh closed 3 years ago
Adding traces into shub/apps/library/views/helpers.py
I've found out that the culprit is this statement:
return Token.objects.get(key=token.replace("BEARER", "").strip())
In my curl request I use "Bearer". This works for many others APIs. Shouldn't this replace()
instruction be case insensitive?
It usually comes directly (and only) from the Singularity client (which uses all caps) but your use case is valid too, so we can do a regular expression replace instead. Would you like to contribute a PR with the change?
This should do the trick:
re.sub("bearer","", "Bearer 123456", flags=re.IGNORECASE).strip()
And funnily enough, I started out with Bearer
as well (as this is what I'm used to) and the there was an error of this same type because it was in all caps. Seems we just need to accept any casing :)
BTW a few lines above, in the validate_token
method, I see:
token = token.split(" ")[-1] # Get rid of BEARER or Bearer <token>
How about this:
token.lower().replace("bearer", "").strip()
?
In the weird case that someone has capital letters, we wouldn’t want to assume that making it all lowercase will always work.
Hi,
I've just installed an sregistry instance from current master branch for testing purpose, and I'm having a hard time working with the API.
For example, the end point
/v1/collections/{user}/{collection}
with valid user and collection names fails with this traceback in the log:Any help appreciated.