teracyhq / httpie-jwt-auth Goto Github PK
View Code? Open in Web Editor NEWJWTAuth (JSON Web Tokens) auth plugin for HTTPie
License: BSD 3-Clause "New" or "Revised" License
JWTAuth (JSON Web Tokens) auth plugin for HTTPie
License: BSD 3-Clause "New" or "Revised" License
it's currently really outdated.
It would be helpful if a URL can be specified (using an env var) which is used to obtain the token. Ideally then use the username and password provided via --auth=
.
The token fetch and use sequence would then be triggered upon response header Www-Authenticate:
, which also typically contains keyword JWT
or Bearer
to indicate which prefix was expected.
expected:
$ http --auth-type=jwt --auth=jwt_token example.org
actual:
$ http --auth-type=jwt --auth=jwt_token: example.org
add tests, travis-ci build
it seems that we completed all the expected features and we reach good stability, we can release it as 1.0.0 to mark it as production-ready, backward compatibility is guaranteed for the next 1.x and 2.0.0 releases.
System: Windows 10
Build: Latest Stable (0.2.1)
Hello.
In usage example:
http --auth-type=jwt --auth='<token>:' example.org
So if i type part after --auth in single quotation marks, i get an invalid token:
Bearer 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVC
(this quotation mark should not be after Bearer keyword)
But without quotation marks and with double quotation marks it works fine.
http --auth-type=jwt --auth=<token>: example.org
http --auth-type=jwt --auth="<token>:" example.org
Executing with HTTPie v2.0.0 with Python 3.6 e.g.:
http -v -b --output C:\Directory\JSON_Reply.json --auth-type=jwt --auth="adf21214fds254125" POST http://web_address.com.au/api @C:\Directory\JSON.json
Error:
File....\python36\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File....\python36\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File....\Python36\Scripts\http.exe\__main__.py", line 7, in <module>
File....\python36\lib\site-packages\httpie\__main__.py", line 11, in main
exit_status = main()
File....\python36\lib\site-packages\httpie\core.py", line 36, in main
plugin_manager.load_installed_plugins()
File....\python36\lib\site-packages\httpie\plugins\manager.py", line 34, in load_installed_plugins
plugin = entry_point.load()
File....\python36\lib\site-packages\pkg_resources\__init__.py", line 2444, in load
return self.resolve()
File....\python36\lib\site-packages\pkg_resources\__init__.py", line 2450, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File....\python36\lib\site-packages\httpie_aws_auth.py", line 8, in <module>
from httpie import ExitStatus
ImportError: cannot import name 'ExitStatus'
No issues with HTTPie v1.0.3
v0.3.0 is ready to be shipped
check out how tests are organized in the httpie project
Hello,
I am not sure this has to do with the plugin, but there seems to be some correlation, so apologies if this is the wrong place to raise this issue.
One of the things I love about HTTPie is the colored output. But for some reason the output of requests using --auth-type=jwt
are not colorized. I was wondering if this is a missing feature, a bug or silly me doing something wrong.
Installation output
❯ pip install httpie
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Defaulting to user installation because normal site-packages is not writeable
Collecting httpie
Using cached httpie-2.0.0-py2.py3-none-any.whl (64 kB)
Requirement already satisfied: requests>=2.22.0 in ./.local/lib/python2.7/site-packages (from httpie) (2.22.0)
Requirement already satisfied: Pygments>=2.5.2 in ./.local/lib/python2.7/site-packages (from httpie) (2.5.2)
Requirement already satisfied: certifi>=2017.4.17 in ./.local/lib/python2.7/site-packages (from requests>=2.22.0->httpie) (2019.11.28)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in ./.local/lib/python2.7/site-packages (from requests>=2.22.0->httpie) (3.0.4)
Requirement already satisfied: idna<2.9,>=2.5 in ./.local/lib/python2.7/site-packages (from requests>=2.22.0->httpie) (2.8)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in ./.local/lib/python2.7/site-packages (from requests>=2.22.0->httpie) (1.25.8)
Installing collected packages: httpie
Successfully installed httpie-2.0.0
❯ pip install httpie-jwt-auth
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Defaulting to user installation because normal site-packages is not writeable
Collecting httpie-jwt-auth
Using cached httpie_jwt_auth-0.3.0-py2.py3-none-any.whl (8.3 kB)
Requirement already satisfied: httpie>=0.9.7 in ./.local/lib/python2.7/site-packages (from httpie-jwt-auth) (2.0.0)
Requirement already satisfied: requests>=2.22.0 in ./.local/lib/python2.7/site-packages (from httpie>=0.9.7->httpie-jwt-auth) (2.22.0)
Requirement already satisfied: Pygments>=2.5.2 in ./.local/lib/python2.7/site-packages (from httpie>=0.9.7->httpie-jwt-auth) (2.5.2)
Requirement already satisfied: certifi>=2017.4.17 in ./.local/lib/python2.7/site-packages (from requests>=2.22.0->httpie>=0.9.7->httpie-jwt-auth) (2019.11.28)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in ./.local/lib/python2.7/site-packages (from requests>=2.22.0->httpie>=0.9.7->httpie-jwt-auth) (3.0.4)
Requirement already satisfied: idna<2.9,>=2.5 in ./.local/lib/python2.7/site-packages (from requests>=2.22.0->httpie>=0.9.7->httpie-jwt-auth) (2.8)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in ./.local/lib/python2.7/site-packages (from requests>=2.22.0->httpie>=0.9.7->httpie-jwt-auth) (1.25.8)
Installing collected packages: httpie-jwt-auth
Successfully installed httpie-jwt-auth-0.3.0
Test
❯ http --auth-type=jwt --auth="token" 127.0.0.1:32769
Traceback (most recent call last):
File "/home/user/.local/bin/http", line 8, in <module>
sys.exit(main())
File "/home/user/.local/lib/python2.7/site-packages/httpie/__main__.py", line 10, in main
from .core import main
File "/home/user/.local/lib/python2.7/site-packages/httpie/core.py", line 21
args: List[Union[str, bytes]] = sys.argv,
^
SyntaxError: invalid syntax
❯ python --version
Python 2.7.17
It would be more useful to have (the bulky) JWT token be loaded from a file.
Hi,
I'm using django + djangorestframework + djangorestframework-jwt
In curl I can get the articles list with the following command:
curl -H "Authorization: JWT <token>" http://127.0.0.1:8000/api/articles/
Is there a way to do it with httpie-jwt-auth?
I tried the following command with no success:
http --auth-type=jwt --auth="<token>" http://127.0.0.1:8000/api/articles/ -h
HTTP/1.0 401 Unauthorized
Allow: GET, HEAD, OPTIONS
Content-Type: application/json
Server: WSGIServer/0.2 CPython/3.4.4
Vary: Accept, Cookie
WWW-Authenticate: JWT realm="api"
X-Frame-Options: SAMEORIGIN
After installed httpie-jwt-auth, still could not find jwt auth type
I installed latest version but getting this error
http: error: argument --auth-type/-A: invalid choice: 'jwt' (choose from 'basic', 'digest')
from: #5 (comment)
we use Docker for development
INFO:coveralls:{"message":"Couldn't find a repository matching this job.","error":true}
regression from #17
it's ready to be shipped
as I'm working on a client project that support JWT with auth prefix of JWT
not Bearer
, we should allow override this (by environment var JWT_AUTH_PREFIX or an optional option --auth-prefix=XXX)
optional option should override environment var
If not setting, default auth prefix Bearer
should be used.
We should have Docker image available for usage.
These images are built from the https://github.com/teracyhq/docker-files project
For this project, we need to add Docker image usage instruction only.
I was having an issue with using this extension in a flask app.
http :5000/secret --auth-type=jwt --auth="Authorization: JWT "
Tried a lot of things. Ultimately this worked
JWT_AUTH_PREFIX=JWT JWT_AUTH_TOKEN= http :5000/secret --auth-type=jwt -v
Thought this may be helpful for someone who is having an issue.
Note: I did not use && between the environmental variables as was mentioned in the docs.
add acceptance tests to make sure it works as expected.
Authorization
header when send jwt auth requestsA declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.