Giter VIP home page Giter VIP logo

leplusorg / openid-connect-provider-debugger Goto Github PK

View Code? Open in Web Editor NEW
13.0 1.0 6.0 231 KB

A docker image to test OpenID Connect Providers (OP) using a simple Relying Party (RP).

Home Page: https://hub.docker.com/r/leplusorg/openid-connect-provider-debugger

License: Apache License 2.0

Dockerfile 55.68% Shell 7.95% HTML 36.36%
openid-connect openid oauth2 openidconnect openidconnect-client openid-client relying-party identity-provider identityprovider relyingparty debugging-tool authentication authentication-flow nginx openresty idp op rp keycloak testing-tools

openid-connect-provider-debugger's Introduction

OpenID Connect provider debugger

A docker image to test and troubleshoot OpenID Connect (OIDC) Providers (OP). This containers provides a minimalist Relying Party (RP) with verbose logs enabled including all HTTP requests and responses. Used in conjuction with the network logs of your web browser, it provides a full picture of the OP's behavior to help understand and troubleshoot the OIDC flow.

Dockerfile Docker Build Docker Stars Docker Pulls Docker Version

Run

To launch the debugger, you will need to get the following information from the OP:

  1. client ID.
  2. client secret.
  3. discovery URI (usually something like https://www.provider.com/.well-known/openid-configuration).

Also typically your OP will ask you to provide the Redirect URI it should accept (http://localhost:8080/login in our example below).

Using the web UI

Once your have provided and gathered the above information, run the following docker:

docker run -i -p 8080:80 leplusorg/openid-connect-provider-debugger

Finally, open http://localhost:8080 in your favorite browser and follow the instruction on the web page.

You should be redirected to your OP to begin the authentication flow. Remember that if you are already signed in, you may go through the authentication without any prompt. If you authenticate successfully, you should see a JSON document containing all the information received by the debugger from the OP. You can find more details (including the raw tokens) in the logs printed by the docker container.

A successful sign in would result in the display of a JSON document like this one:

{
    "options": {
        "client_id": "debugger",
        "discovery": "http:\/\/192.168.1.10:8081\/realms\/master\/.well-known\/openid-configuration",
        "redirect_uri": "http:\/\/localhost:8080\/login",
        "ssl_verify": "no",
        "client_secret": "835e0717-e0c8-4b57-b044-295fa0e3f61b"
    },
    "id_token": {
        "azp": "debugger",
        "iat": 1590619714,
        "iss": "http:\/\/192.168.1.10:8081\/realms\/master",
        "aud": "debugger",
        "nonce": "1e23537bb06f2b4e324d12d8d51f2c6b",
        "exp": 1590619774,
        "jti": "9a1b5cf6-87ab-4557-a4aa-b771a67af1db",
        "sub": "38b4a290-5332-4c4c-bb8f-46eb2826c7ea",
        "email_verified": false,
        "acr": "1",
        "preferred_username": "tom",
        "auth_time": 1590619714,
        "session_state": "fb3edcc2-f5b3-47fa-84f6-60cbae792cde",
        "typ": "ID"
    },
    "user": {
        "email_verified": false,
        "preferred_username": "tom",
        "sub": "38b4a290-5332-4c4c-bb8f-46eb2826c7ea"
    },
    "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJwbjdtd1B1WDZ5ZjBvSHEtTDFiZ2l6T2FVeGs5aDlGaU8ycjlMcV9LYkNRIn0.eyJleHAiOjE1OTA2MTk3NzQsImlhdCI6MTU5MDYxOTcxNCwiYXV0aF90aW1lIjoxNTkwNjE5NzE0LCJqdGkiOiI5MTk0ODgxZS05ZGMzLTQ1YjItOWExOS1mZDFlZTk3NDY4NjciLCJpc3MiOiJodHRwOi8vMTkyLjE2OC4xLjEwOjgwODEvYXV0aC9yZWFsbXMvbWFzdGVyIiwiYXVkIjpbIm1hc3Rlci1yZWFsbSIsImFjY291bnQiXSwic3ViIjoiMzhiNGEyOTAtNTMzMi00YzRjLWJiOGYtNDZlYjI4MjZjN2VhIiwidHlwIjoiQmVhcmVyIiwiYXpwIjoiZGVidWdnZXIiLCJub25jZSI6IjFlMjM1MzdiYjA2ZjJiNGUzMjRkMTJkOGQ1MWYyYzZiIiwic2Vzc2lvbl9zdGF0ZSI6ImZiM2VkY2MyLWY1YjMtNDdmYS04NGY2LTYwY2JhZTc5MmNkZSIsImFjciI6IjEiLCJyZWFsbV9hY2Nlc3MiOnsicm9sZXMiOlsiY3JlYXRlLXJlYWxtIiwib2ZmbGluZV9hY2Nlc3MiLCJhZG1pbiIsInVtYV9hdXRob3JpemF0aW9uIl19LCJyZXNvdXJjZV9hY2Nlc3MiOnsibWFzdGVyLXJlYWxtIjp7InJvbGVzIjpbInZpZXctcmVhbG0iLCJ2aWV3LWlkZW50aXR5LXByb3ZpZGVycyIsIm1hbmFnZS1pZGVudGl0eS1wcm92aWRlcnMiLCJpbXBlcnNvbmF0aW9uIiwiY3JlYXRlLWNsaWVudCIsIm1hbmFnZS11c2VycyIsInF1ZXJ5LXJlYWxtcyIsInZpZXctYXV0aG9yaXphdGlvbiIsInF1ZXJ5LWNsaWVudHMiLCJxdWVyeS11c2VycyIsIm1hbmFnZS1ldmVudHMiLCJtYW5hZ2UtcmVhbG0iLCJ2aWV3LWV2ZW50cyIsInZpZXctdXNlcnMiLCJ2aWV3LWNsaWVudHMiLCJtYW5hZ2UtYXV0aG9yaXphdGlvbiIsIm1hbmFnZS1jbGllbnRzIiwicXVlcnktZ3JvdXBzIl19LCJhY2NvdW50Ijp7InJvbGVzIjpbIm1hbmFnZS1hY2NvdW50IiwibWFuYWdlLWFjY291bnQtbGlua3MiLCJ2aWV3LXByb2ZpbGUiXX19LCJzY29wZSI6Im9wZW5pZCBwcm9maWxlIGVtYWlsIiwiZW1haWxfdmVyaWZpZWQiOmZhbHNlLCJwcmVmZXJyZWRfdXNlcm5hbWUiOiJ0b20ifQ.NCFiSW3Tt7qQCtE8g46kLg-oSqKiDseg4NCwV1kVPoD5yFa9XunooVE3eO1XgKACb_FFzrxEMYfmStpvypI7VFu-XO5ULkrbXElhDtMmVbEn-aqNILHs_h_Ewo1JdCa-gNL9zav5QhmcwmIUpNYsDsQxm-bN86JgQO2f8ZJ497K6DpPFnIrhd0eT0fa4iw7Tx64PdIDUPXqqYrR2nh0P-D0dkkVTSu-EI14uuwwClYy5Pq9EeKfX9M8SqUp81gprhty-9PneDcFjBpEgFRCfFhecSBn0_c1urlx5QTbN96PnCWlH2t-aGLfRHD8oJcv-xztHt02Zhy-L2B3z-bCfSQ"
}

You can use https://jwt.io to decode the access token.

Using URL parameters

If you prefer to skip the UI, you can pass directly the required values as URL parameters using the following syntax: http://localhost:8080/debug?oidc_client_id=client_id&oidc_client_secret=client_secret&oidc_discovery=discovery_url&oidc_redirect_uri=redirect_uri

See section "Parameters" below for a description of each parameter.

Remember to URL encode the parameter values if they contain any reserved characters ('&', '?', '/' etc.).

Using environment variables

You can pass the parameters to the docker container using environment variales like this:

docker run -i -e 'oidc_client_id=<client_id>' -e 'oidc_client_secret=<client_secret>' -e 'oidc_discovery=<discovery_url>' -e 'oidc_redirect_uri=http://localhost:8080/login' -p 8080:80 leplusorg/openid-connect-provider-debugger

See section "Parameters" below for a description of each parameter.

Then go to http://localhost:8080/debug to skip the UI and initiate the authentication flow.

Parameters

Settings are passed to the docker image using environment variables (e.g. using the -e command-line option) or directly to NGINX using URL parameters.

oidc_client_id

Description: the OpenID Connect Client ID.

Mandatory: yes

Default: none

oidc_client_secret

Description: the OpenID Connect Client Secret (WARNING: this sensitive value will appear in the logs of the docker so please do not share your logs without redacting this value).

Mandatory: yes

Default: none

oidc_discovery

Description: the URI of the OpenID Connect Provider discovery endpoint (usually a URI ending in something like "/.well-known/openid-configuration").

Mandatory: yes

Default: none

oidc_redirect_uri

Description: the OpenID Connect redirect URI (typically if you are running the instance locally on port 8080, it would be http://localhost:8080/login).

Mandatory: yes

Default: none

Test

To test the debugger (or any other Relying Party), you can use JBoss Keycloak as a local OpenID Connect Provider.

Launch Keycloak using the following command (choosing the desired username and password):

docker run -i -e KEYCLOAK_ADMIN=<usename> -e KEYCLOAK_ADMIN_PASSWORD=<password> -p 8081:8080 quay.io/keycloak/keycloak:latest start-dev

Then go to the Keycloak admin console at http://localhost:8081/admin/master/console/#/master/clients and authenticate using the username and password chosen in the above command.

Click the "Create" button to create a new client. Choose a client ID and click "Next". On the next screen, toggle on the Client authentication then click Next again. Then on the final screen you need to provide the "Valid Redirect URIs". Put here the value http://localhost:8080/* assuming that you will be running the debugger on port 8080 (see "Run" section above for details). Click "Save". Then go to the "Credentials" tab and copy the client secret.

Now you can run the debugger (see "Run" section above for details). The client ID is the value that you just chose when creating the client in Keycloak. The client secret is the value that you copied from the Credentials tab. The OpenID Connect Discovery URL will be http://192.168.0.1:8081/realms/master/.well-known/openid-configuration where you need to replace the IP address by your local machine network address. You need to use an IP address that works both from your local machine and from inside the debugger docker container (for the debugger to be able to connect to the OP to retrieve the tokens). This is why you can't use localhost or 127.0.0.1.

Credits

This project is based on NGINX / OpenResty and all the actual OpenID Connect implementation comes from https://github.com/zmartzone/lua-resty-openidc.

Alternatives

If all you need is to do a simple test and you do not need to see the details of each HTTP request and response, you can use this online OIDC debugger: https://oidcdebugger.com. Its source code is available at https://github.com/nbarbettini/oidc-debugger.

Another alternative is the official OpenID Foundation certification tests that can be run online at https://op.certification.openid.net:60000 and https://rp.certification.openid.net:8080, the source code being available at https://github.com/openid-certification/oidctest.

openid-connect-provider-debugger's People

Contributors

dependabot[bot] avatar mend-bolt-for-github[bot] avatar thomasleplus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

openid-connect-provider-debugger's Issues

[Bug]: Env Variables are not read by Application when running via Docker

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Application in Docker container is not reading env variables defined when starting up container.
Consequently, navigating to {url}/login returns a 500 error

Expected Behavior

After setting required env variables, navigating to {url}/login should trigger auth flow

version

leplusorg/openid-connect-provider-debugger:main

Relevant log output

Confirm envs are present in the container

$ docker run -i -e 'oidc_client_id=kbyuFDidLLm280LIwVFiazOqjO3ty8KH' -e 'oidc_client_secret=60Op4HFM0I8ajz0WdiStAbziZ-VFQttXuxixHHs2R7r7-CW8GR79l-mmLqMhc-Sa' -e 'oidc_discovery=https://samples.auth0.com/.well-known/openid-configuration' -e 'oidc_redirect_uri=http://localhost:8111/token' -p 8111:80 leplusorg/openid-connect-provider-debugger:main env
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/openresty/luajit/bin:/usr/local/openresty/nginx/sbin:/usr/local/openresty/bin
HOSTNAME=388aa41521a9
oidc_discovery=https://samples.auth0.com/.well-known/openid-configuration
oidc_redirect_uri=http://localhost:8111/token
oidc_client_id=kbyuFDidLLm280LIwVFiazOqjO3ty8KH
oidc_client_secret=60Op4HFM0I8ajz0WdiStAbziZ-VFQttXuxixHHs2R7r7-CW8GR79l-mmLqMhc-Sa
HOME=/root

Steps To Reproduce

  1. In Docker environment
  2. With this config
docker run -i -e 'oidc_client_id=kbyuFDidLLm280LIwVFiazOqjO3ty8KH' -e 'oidc_client_secret=60Op4HFM0I8ajz0WdiStAbziZ-VFQttXuxixHHs2R7r7-CW8GR79l-mmLqMhc-Sa' -e 'oidc_discovery=https://samples.auth0.com/.well-known/openid-configuration' -e 'oidc_redirect_uri=http://localhost:8111/token' -p 8111:80 leplusorg/openid-connect-provider-debugger:main
  1. Run
docker run -i -e 'oidc_client_id=kbyuFDidLLm280LIwVFiazOqjO3ty8KH' -e 'oidc_client_secret=60Op4HFM0I8ajz0WdiStAbziZ-VFQttXuxixHHs2R7r7-CW8GR79l-mmLqMhc-Sa' -e 'oidc_discovery=https://samples.auth0.com/.well-known/openid-configuration' -e 'oidc_redirect_uri=http://localhost:8111/token' -p 8111:80 leplusorg/openid-connect-provider-debugger:main
  1. Navigate to localhost:8111/login
  2. Observe error
    image
$ docker run -i -e 'oidc_client_id=kbyuFDidLLm280LIwVFiazOqjO3ty8KH' -e 'oidc_client_secret=60Op4HFM0I8ajz0WdiStAbziZ-VFQttXuxixHHs2R7r7-CW8GR79l-mmLqMhc-Sa' -e 'oidc_discovery=https://samples.auth0.com/.well-known/openid-configuration' -e 'oidc_redirect_uri=http://localhost:8111/token' -p 8111:80 leplusorg/openid-connect-provider-debugger:main
2024/05/04 16:05:09 [notice] 1#1: using the "epoll" event method
2024/05/04 16:05:09 [notice] 1#1: openresty/1.25.3.1
2024/05/04 16:05:09 [notice] 1#1: built by gcc 13.2.1 20231014 (Alpine 13.2.1_git20231014)
2024/05/04 16:05:09 [notice] 1#1: OS: Linux 5.4.72-microsoft-standard-WSL2
2024/05/04 16:05:09 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2024/05/04 16:05:09 [notice] 1#1: start worker processes
2024/05/04 16:05:09 [notice] 1#1: start worker process 7
172.17.0.1 - - [04/May/2024:16:05:21 +0000] "GET /login HTTP/1.1" 500 585 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36"
2024/05/04 16:05:21 [debug] 7#7: *1 [lua] default.conf:39):50: options={"ssl_verify":"no"}
2024/05/04 16:05:21 [error] 7#7: *1 [lua] default.conf:39):52: oidc_client_id is not defined, client: 172.17.0.1, server: localhost, request: "GET /login HTTP/1.1", host: "localhost:8111"

Anything else?

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.