Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
00f4561
initial verison of slides
emin63 Apr 9, 2025
3ddbe5e
work in progress
emin63 Apr 9, 2025
5d0f5bd
WIP
emin63 Apr 9, 2025
e636e30
more WIP
emin63 Apr 9, 2025
b73459d
minor tweaks
emin63 Apr 10, 2025
a41200c
Moved slides.org into new docs directory
emin63 Apr 10, 2025
0a2f949
Added images for slides
emin63 Apr 10, 2025
8c3ed10
WIP
emin63 Apr 10, 2025
35bede2
switch to EdDSA + provide python code
emin63 Apr 10, 2025
5f4431c
Provided simple flask app to use as demo
emin63 Apr 15, 2025
c6d5565
added __init__
emin63 Apr 15, 2025
3106bec
added pylint target
emin63 Apr 15, 2025
0993893
Lots more improvements to slides
emin63 Apr 15, 2025
1da75a3
Added images for slides
emin63 Apr 15, 2025
f333319
improved makefile
emin63 Apr 15, 2025
fbd0f6f
Created pyproject.toml file
emin63 Apr 15, 2025
1c1041e
Provide simple test to validate demo
emin63 Apr 15, 2025
e40d3ae
Added basic testing
emin63 Apr 15, 2025
5a2d311
cleanup
emin63 Apr 15, 2025
d3f5a85
add more test targets
emin63 Apr 15, 2025
0569a4b
more docs in README
emin63 Apr 15, 2025
a945fbd
fixed options
emin63 Apr 15, 2025
515c1a1
mnior fix
emin63 Apr 15, 2025
d52d263
more minor tweaks
emin63 Apr 16, 2025
82d98c8
Added issue route example
emin63 Apr 24, 2025
3cdafc1
added test_proxy
emin63 Apr 24, 2025
d3791f0
More work revising slides
emin63 Apr 24, 2025
a18cd11
more improvements to slides
emin63 Apr 28, 2025
f27afad
created slides.html from slides.org
emin63 Apr 28, 2025
d5f8d70
pip install project before make test
emin63 Apr 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/docker-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Run test via makefile
run: make test
run: pip install -e . && make test
60 changes: 53 additions & 7 deletions README.org
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@

#+OPTIONS: ^:{}

* Introduction

The =ox_jwt= repository provides some simple tools for working with JSON Web
Tokens (JWTs).
Tokens (JWTs) as well as illustrating some use cases with =nginx= and =python=.

** nginx

For example, the =nginx= sub-directory contains a fully working
minimal example of how you can setup NGINX to only allow access to
Expand All @@ -21,9 +25,26 @@ This is useful because:
3. All of the encryption/decryption used is open source, verifiable,
and modifiable by you.

** python

The slides in [[file:docs/slides.html][docs/slides.html]] provide a detailed presentation of what
JWTs are and how to use them in python.

You can use JWTs in python with or without nginx. For example, you
could have nginx do validation of the JWT and then provide the decoded
JWT as a header to further python code. Alternatively, you can do JWT
encoding and decoding purely in python.

If you =pip install ox_jwt=, you can then run the command
=test_ox_jwt= to do a simple local test of encoding JWTs and decoding
them with a flask server. See the python files in [[file:src/ox_jwt/][src/ox_jwt/]] to see
how the python example works.

* Quickstart and Demo

For a simple test of the system, you can do something like
** nginx

For a simple test of the nginx system, you can do something like
#+BEGIN_SRC sh
make test
#+END_SRC
Expand All @@ -43,9 +64,34 @@ at the command line to do the following:
6. Uses =curl= to verify that you can only access the protected
location in your NGINX server if you have the appropriate JWT.

** python

For a test of the python implementation, you can do
#+BEGIN_SRC sh
pip install ox_jwt
#+END_SRC
and then run the =test_ox_jwt= command.

Alternatively, you can clone the GitHub repository via something like
#+BEGIN_SRC sh
git clone https://github.com/aocks/ox_jwt.git
#+END_SRC
and then build a virtual env and install dependencies via
#+BEGIN_SRC sh
cd ox_jwt
python3 -m venv venv_ox_jwt
source venv_ox_jwt/bin/activate
pip install -e .
#+END_SRC
and then run the tests/demo via:
#+BEGIN_SRC sh
py.test src/ox_jwt
#+END_SRC


* FAQ

** What are some alternatives to =ox_jwt=?
** What are some alternatives to =ox_jwt= for nginx?

- SSL client certificates
- but [[https://security.stackexchange.com/questions/198837/why-is-client-certificate-authentication-not-more-common][SSL client certificates are difficult to setup and maintain]]
Expand All @@ -59,17 +105,17 @@ at the command line to do the following:
- [[https://www.npmjs.com/package/jwt-simple][jwt-simple]] for javascript (used by this project as well)
- [[https://pyjwt.readthedocs.io/en/stable/][pyjwt]] for general python JWT tools

** Aren't there some other easy alternatives?
** Aren't there some other easy alternatives for nginx?

Not that I am aware of. Most other approaches to JWT validation in
your *APPLICATION* server instead of your *NGINX* server or proxy or
require a commercial (i.e., non-open-source) server.

** Why do JWT validation in NGINX?

Plenty of applications do JWT validation and decoding themselves. That
is a fine and useful thing to do and can also be combined with
validating the JWT in NGINX as well.
Plenty of applications do JWT validation and decoding themselves as
shown in the python examples. That is a fine and useful thing to do
and can also be combined with validating the JWT in NGINX as well.

A few reasons why you might want to do JWT validation in the web
server instead of or in addition to the application include:
Expand Down
Binary file added docs/images/jwt-auth-vs-app-auth-response.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/jwt-auth-vs-app-auth.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/jwt-auth-vs-app-request-app.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/jwt-auth-vs-app-separate.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/jwt-auth-vs-app-start.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/jwt-get-access.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/jwt-get-refresh.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/jwt-revoke.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/jwt-use-access.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/nginx-example.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading