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

Allow using multiple keys and selecting between them via kid #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kfirg-cetu
Copy link

JWT contains a mechanism for selecting the correct key by using an identifier. This commit adds an ability to use a different key based on the parameter in the JWT to verify.

To make sure that the change doesn't introduce any issues a new test script was added to run some sanity tests.

JWT contains a mechanism for selecting the correct key by
using an identifier. This commit adds an ability to use a different
key based on the parameter in the JWT to verify.

To make sure that the change doesn't introduce any issues a new test
script was added to run some sanity tests.
@lnksz
Copy link

lnksz commented Sep 7, 2024

maybe better added (didn't check whether it's already there) in the mainline/integrated C JWT code:

https://github.com/haproxy/haproxy/blob/master/src/jwt.c

## Support for multiple keys

This library support specifying multiple keys values in the JWT token. They should be specified as a JSON array of strings.
You can also accept multiple audience values in the `OAUTH_KID` and `OAUTH_PUBKEY_PATH` environment variables in the **haproxy.cfg** file. Separate each value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace "audience values" with "key identifier values"?

- ./example/haproxy/pem/test.com.pem:/etc/haproxy/pem/test.com.pem
- ./lib/jwtverify.lua:/usr/local/share/lua/5.4/jwtverify.lua
Copy link
Contributor

@NickMRamirez NickMRamirez Sep 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the existing repo, jwtverify.lua gets installed by example/haproxy/install.sh line 120:

install_luaoauth() {
    printf "\r[+] Installing haproxy-lua-oauth\n"
    if [ ! -e $lua_dep_dir ]; then
        mkdir -p $lua_dep_dir;
    fi;

    cp $CWD/lib/*.lua $lua_dep_dir
}

which tests the install script. What's the reason to overwrite that installed lua file with a Docker volume?

@@ -0,0 +1,316 @@
#!/bin/bash

# Function to wait for containers to be up
Copy link
Contributor

@NickMRamirez NickMRamirez Sep 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be good to add a comment at the top that explains generally what test.sh does.

When I ran it, I got an error:

[2024-09-24 22:23:20] [ERROR] test_second_key_usage_pass failed

Am I missing a step? Here is the log.txt

@@ -25,6 +25,7 @@ if not config then
config = {
Copy link
Contributor

@NickMRamirez NickMRamirez Sep 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please copy the updated lib/jwtverify.lua to example/haproxy/lib/jwtverify.lua? It's the same file, but copied into the example.

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

Successfully merging this pull request may close these issues.

3 participants