core-api / coreapi-cli

An interactive command line client for Core API.
Other
16 stars 5 forks source link

Authentication headers aren't being sent with coreapi 2.3.0, but 2.2.4 works #19

Closed tveastman closed 6 years ago

tveastman commented 7 years ago

The CLI doesn't seem to correctly use coreapi's authentication anymore with the latest coreapi libary.

If I use coreapi cli 1.0.6 and coreapi 2.0.0, the authentication header is being sent (Not my real creds or domain):

$ coreapi get https://xxx.xxx.xxx/ --debug
> GET / HTTP/1.1
> Accept-Encoding: gzip, deflate
> Connection: keep-alive
> Accept: application/coreapi+json, application/vnd.coreapi+json, */*
> Authorization: Basic dG9tOmE=

But if I switch to the latest coreapi 2.3.0, it doesn't get sent:

$ coreapi get https://xxx.xxx.xxx/ --debug
> GET / HTTP/1.1
> Accept-Encoding: gzip, deflate
> Connection: keep-alive
> Accept: application/coreapi+json, application/vnd.coreapi+json, */*
> Host: xxx.xxx.xxx
> User-Agent: coreapi
< 403 Forbidden

For the moment, I'm just reverting to coreapi 2.0.0 as a workaround.

tveastman commented 7 years ago

Authentication works fine when using coreapi-cli and CoreAPI version 2.2.4, so the breaking change is somewhere between 2.2.4 and 2.3.0

bors-ltd commented 7 years ago

Same bug on coreapi 2.3.1, I also reverted to 2.2.4 and it instantly worked. coreapi-cli is version 1.0.6.

njj6666 commented 7 years ago

I degraded coreapi to 2.2.4, and coreapi-cli is 1.0.6. But I still get error of "TypeError: init() missing 1 required positional argument: 'enum'". Any idea? Thanks.

I degraded coreapi to 2.0.0, it works

tyrdavis commented 7 years ago

coreapi-cli is using the deprecated credentials argument for HTTPTransport instead of auth. As you can see from the code here, coreapi 2.3.1 is ingesting that deprecated argument, but then doing nothing with it. This is why this library won't send auth headers anymore.

blueyed commented 7 years ago

See https://github.com/core-api/python-client/pull/146.

pombredanne commented 7 years ago

@blueyed Thanks! @tomchristie It would be awesome if you could have a look into this... atm any coreapi-generated doc will point to use the coreapi client and this is broken :package:

pau-minoves commented 7 years ago

I can confirm this happens with:

coreapi==2.3.3 coreapi-cli==1.0.6

@blueyed @tomchristie any chance we can get this fixed?

blueyed commented 7 years ago

@pau-minoves IIRC https://github.com/core-api/python-client/pull/146 should fix it?! Have you tried it?

pau-minoves commented 7 years ago

hi @blueyed I just tried and I still have the problem. I see that pull request fixes some warnings but not actual logic. Am I right?

blueyed commented 7 years ago

@pau-minoves The first two commits are fixes.

blueyed commented 7 years ago

Make sure to actually use the branch/PR with coreapi-cli when testing it.

pau-minoves commented 7 years ago

@blueyed right, I can confirm that branch works. Thanks!

Any change it gets merged into a regular coreapi release?

bradleyglen commented 6 years ago

Waiting for the fix on the coreapi credentials add <username>:<password> --auth basic command.

For now, downgrading coreapi worked for me:

dominem commented 6 years ago

@bradleyglen Thanks, I can confirm that. With 2.2.4 I'm getting TypeError: __init__() missing 1 required positional argument: 'enum', and with a higher version (2.3.x) it just doesn't work. It adds credential, but does not authenticate. I've only tested it with coreapi credentials add 127.0.0.1 <username>:<password> --auth basic command.

blueyed commented 6 years ago

There is a pending fix already at https://github.com/core-api/python-client/pull/146 - no need to confirm this over and over again.

pombredanne commented 6 years ago

@tomchristie Thank you ++