Coder Social home page Coder Social logo

rcbj / oauth2-oidc-debugger Goto Github PK

View Code? Open in Web Editor NEW
142.0 4.0 40.0 802 KB

An OAuth2 and OpenID Connect Debugger

Home Page: https://goo.gl/3UbeQk

License: MIT License

Dockerfile 0.58% JavaScript 72.97% HTML 25.44% CSS 1.01%
oauth2 openidconnect oidc debugger authentication security

oauth2-oidc-debugger's Introduction

OAuth2 + OpenID Connect (OIDC) Debugger

This is the official home of the community Project.

This is a simple OAuth2 and OpenID Connect (OIDC) debugger (test tool) that I created as part of a Red Hat SSO blog post I wrote in November, 2017. Since then, I have expanded support to include several major Identity Providers (see the complete list below). The blog post uses this debugger for testing the OpenID Connect setup. So, checkout the blog for usage examples. This project builds a docker container that runs the debugger application.

Supported Specs

This project currently supports the following specs:

It also supports a couple of proprietary IdP extensions as described below.

Supported OAuth2 Authorization Grants

The referenced blog posts are the only documentation currently available for the debugger.

The following OAuth2 Authorization Grants are supported:

Supported OIDC Authentication Flows

The following OpenID Connect Authentication Flows are supported

  • Authorization Code Flow (could also use Authorization Code Grant option and scope="openid profile")
  • Implicit Flow (2 variants)
  • Hybrid Flow (3 variants)

Tested Platforms

So far, this tool has been tested with the following OAuth2 or OIDC implementations:

  • Red Hat SSO v7.1 (OAuth2 + OIDC)
  • 3Scale SaaS with self-managed APICast Gateway (OAuth2 + OIDC)
  • Azure Active Directory (v1 endpoints, OIDC + OAuth2)
  • Azure Active Directory (v2 endpoints, OIDC + OAuth2)
  • Apigee Edge (OAuth2, with caveats described here)
  • Ping Federate (OAuth2 + OIDC)
  • AWS Cognito (OAuth2 + OIDC)
  • Facebook (OAuth2)
  • Google+ (OAuth2)
  • KeyCloak (reported to work by third-parties, Red Hat SSO v7.1 is KeyCloak under the Red Hat banner, so it should work)
  • Okta (OIDC + OAuth2)
  • Auth0 (OIDC + OAuth2)

3Scale Usage Notes

The version of 3Scale SaaS + APICast only supports OAuth2; 3Scale can support the OIDC Authorization Code Flow since the response_type and grant_type values match OAuth2's Authorization Code Grant. The other OIDC Authentication Flows are not supported by 3Scale OAuth2. The latest version of 3Scale on-premise has OIDC support. As of 12/3/2017, I haven't been able to test this yet.

Azure Active Directory Usage Notes

Azure Active Directory (v1 endpoints) support OIDC Authorization Code Flow, Implicit Flow, and the Hybrid Flow with response_type="code id_token".

Apigee Edge Usage Notes

Apigee Edge supports OAuth2 by providing the building blogs of an OAuth2 Provider. The developer has much leeway in how the pieces are used. This debugger can only be used with Identity Providers that adhere to the spec.

AWS Cognito Usage Notes

AWS Cognito has been tested with the OIDC Authorization Code Flow (with a user defined in a user pool and with a facebook federation relationship. Cognito supports federation, but has optional parameters that need to be passed in to tell Cognito which Userpool and Identity Provider to use (like Facebook). The debugger does not support passing in these parameters at this time (we'll call that a future enhancement). It appears to have worked because I tested in a browser session where I had previously authenticated against Cognito using Facebook. Also, when the refresh grant is used, it works without issue the first time; however, the refresh grant response does not include a new refresh token. So, the refresh_token is not prepopulated correctly. The original refresh token can be copied into the field and subsequent refresh token calls will work. I admit I didn't test all possible scenarios, but I imagine that once the refresh token expires, it will issue a new refresh token. Another interesting note that mattered a lot in a recent project, each refresh token grant response has a new ID Token--and, access token, of course.

Facebook Usage Notes

Facebook OAuth2 was tested with the OAuth2 Authorization Code Grant. It worked, but there was no refresh token provided in the OAuth2 Token Endpoint response. So, the refresh grant is obviously not going to work. Configuration details can be found here.

Google+ Usage Notes

Google+ login was tested with the Authorization Code3 Grant. It worked. No refresh token was provided. Configuration details can be found here.

General Usage Notes

Note, that all configuration values except for the user password is written to local storage to prepopulate fields later. If this is not desired, clear your browser's local storage for the debugger when done using.

The debugger has been tested with recent versions of Chrome.

Getting Started

If you have docker installed already:

git clone https://github.com/rcbj/oauth2-oidc-debugger.git
cd oauth2-oidc-debugger
sudo CONFIG_FILE=./env/local.js docker-compose build
sudo CONFIG_FILE=./env/local.js docker-compose up

Note, you will need at least 950MB of disk space ree in order to build this Docker image.

From a bash command prompt on Fedora or RHEL 7.x, run the following::

yum install git
git clone https://github.com/rcbj/oauth2-oidc-debugger.git
dnf install docker
systemctl start docker
cd oauth2-oidc-debugger
sudo CONFIG_FILE=./env/local.js docker-compose build
sudo CONFIG_FILE=./env/local.js docker-compose up

Clean Up / Start Over

  • List all containers (only IDs) sudo docker ps -aq
  • Stop all running containers: sudo docker stop $(docker ps -aq)
  • Remove all containers: sudo docker rm $(docker ps -aq)
  • Remove all images: sudo docker rmi $(docker images -q)

On other systems, the commands needed to start the debugger in a local docker container will be similar. The docker Sinatra/Ruby runtime will have to be able to establish connections to remote IdP endpoint (whether locally in other docker containers, on the host VM, or over the network/internet). On the test system, it was necessary to add "--net=host" to the "docker run" args. The network connectivity details for docker may vary from platform-to-platform.

Running

  • Open your favorite browser and enter "http://localhost:3000" in the address bar.
  • Choose the OAuth2 Grant or OIDC Flow that you want to test.
  • Enter the Authorization Endpoint.
  • Enter the Token Endpoint.

OAuth2 AUthorization Grant:

  • Enter the client identifier.
  • Enter the Redirect URI.
  • Enter the scope information.
  • If you need to provide a resource parameter, click the radio button. Then, enter the desired resource parameter.
  • Click the Authorize button.
  • Authenticate the user.
  • Scroll down to the "Exchange Authoriztaion Code for Access Token" Section.
  • Verify that the Code field is filled in below in the Token Step section.
  • Enter the client identifier
  • Enter the client secret if this is a confidential client.
  • Enter the scope information.
  • If a resource is needed, click Yes. Enter the resource information in the Resource field.
  • If the IdP is using a self-signed certificate or a cert issued from a non-public CA, click No next to the "Validate IdP Certificate?" question. Note, certificates signed by public CAs are validated against the trusted CAs included with the Ruby 2.4.0 docker image.
  • Click the Get Token button.
  • The standard tokens that are returned from the token endpoint are displayed at the bottom.

OAuth2 Implicit Grant:

  • Enter the client identifier.
  • Enter the Redirect URI.
  • Enter the scope information.
  • If you need to provide a resource parameter, click the radio button. Then, enter the desired resource parameter.
  • Click the Authorize button.
  • Authenticate the user.
  • The access_token will be listed at the bottom of the screen.

Refresh Token Grant

  • In the configuration section, click the the "Yes" radio button next to "Use Refresh Token". This will make the Refresh Token Section appear.
  • The refresh token is automatically populated from the Token Endpoint call response.
  • Enter the client identifier.
  • Enter the client secret.
  • Enter the scope.
  • Press Enter. For the other grants and flows, similar steps to the above are used.

See the blog posts for more information.

Prerequisites

To run this project you will need to install docker.

Building the docker image

 git clone https://github.com/rcbj/oauth2-oidc-debugger.git
 yum install docker
 system start docker
 cd oauth2-oidc-debugger/client
 docker build -t oauth2-oidc-debugger .
 docker run -p 3000:3000 oauth2-oidc-debugger 

On other systems, the commands needed to start the debugger in a local docker container will be similar. The docker Sinatra/Ruby runtime will have to be able to establish connections to remote IdP endpoint (whether locally in other docker containers, on the host VM, or over the network/internet). On the test system, it was necessary to add "--net=host" to the "docker run" args. The network connectivity details for docker may vary from platform-to-platform.

Additional Feature Information

State Parameters

  • A state parameter can be submitted as part of the authorization endpoint request. The state parameter will be validated when the redirect comes back to the registered callback endpoint. A UUID is used as the state value. This is an optional, but recommended parameter.

Custom Parameters

Various specs & RFCs that build on the OAuth2 & OIDC protocols add additional parameters that must be passed to the Authorization Endpoint and Token Endpoint. The debugger supports passing up to ten custom parameters.

Nonce Parameter

A nonce parameter can be included in the Authorization Endpoint call. A UUID is used as the nonce value.

Token Details

All tokens (Access, Refresh, ID) returned by the IdP can have their details viewed by clicking on the link next to the token on the Debugger2 page.

This feature currently only supports JWT tokens, but in the future will support other token types.

Some caveats to keep in mind:

  • If nothing is displayed, then the requested token retrieved from the endpoint is not a JWT or not a valid JWT.
  • In the future, additional token formats may be added.
  • Although, many leading IdPs use JWT as the format for OAuth2 access tokens and refresh tokens. The spec does not require this.
  • Some IdPs intentionally use opaque tokens that have no deeper meaning than to be a randomly generated identifier that points back to session information stored on the IdP

OIDC RP-Initiated Logout Spec Support

If the Logout URL can be read from the OIDC Discovery Endpoint, it will be automatically populated; otherwise, you will need to manually copy in this URL.

The associated refresh token should be invalidated at this point. The corresponding JWT tokens could still be validated unless you compare them against the Introspection Endpoint.

Version History

  • v0.1 - Red Hat SSO support including all OAuth2 Grants and OIDC Authorization Code Flow
  • v0.2 - 3Scale + APICast support for all OAuth2 Grants and OIDC Authorization Code Flow
  • v0.3 - Azure Active Directory support for OAuth2 Grans and OIDC Authorization Code Flow. Added error reporting logic and support for optional resource parameter. Added additional debug logging code in client. Moved Token Endpoint interaction into server-side (Ruby/Sinatra/Docker); this was necessary because Azure Active Directory does not support CORS (making Javascript interaction from a browser impossible). Disabled IdP server certificate validation in IdP call.
  • v0.4 - Full OpenID Connect support (all variations of Implicit and Hybrid Flows). Support for public clients (ie, no client secret).
  • v0.5 - Refresh Token support. Updates to UI.
  • v0.6 - Rewritten in JavaScript. Ported to AWS for idptools.io website. Numerous enhancements. See Release Notes.
  • v0.7 - PKCE Support added.

Authors

Robert C. Broeckelmann Jr. - Initial work

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

Thanks to the following:

oauth2-oidc-debugger's People

Contributors

1oglop1 avatar bigfleet avatar dekimsey avatar dependabot[bot] avatar rcbjbluemars avatar rcbjlevvel avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

oauth2-oidc-debugger's Issues

Add support for OIDC RP-Initiated (Front-Channel) Logout Spec

This ticket will add a screen that allows the user to logout or end a session (ie, invalidate tokens associated with the session that the debugger has previously created).

It would be interesting to also be able to logout of sessions that were created outside of the browser, but doing this without it being confusing to the user or the logic for the rest of the debugger may be challenging.

See [1] for more information about Relaying Party initiated Logout with OIDC. The spec is only a few pages long and the call that needs to be made to the IdP is straightforward.

Populate as many of the parameters as possible from the OIDC Discovery Endpoint metadata and values collected from the user during the login process.

Reference:
[1] https://openid.net/specs/openid-connect-rpinitiated-1_0.html
[2] https://openid.net/specs/openid-connect-frontchannel-1_0.html

oidc_authorization_code_flow does not work, and redirect_uri should be provided

Thanks for writing this.

I am trying it out to see if my openid implementation works.

Using oidc_authorization_code_flow does not work.
There seems to be no code to retrieve the code from the uri so you can go on to the next step.

Also, I found it very difficult to work out what the redirect uri should be. I tried just /callback, but it seems a bit odd to me. The OAuth2 options (e.g. authorization_grant) seem to expect the parameters to be in window.location.hash, for some reason, instead of in query variables. But if I make the redirect url /callback#, it sort of works. Not sure why I should have to guess what the redirect uri is - surely it should be filled in automatically, as a read-only field?

Shouldn't the code also decode the oidc token returned as well?

When trying to build the docker container"failed to register layer: unlinkat /usr/share/doc/libgdbm-dev: invalid argument"

When I try to start the debugger I get the following error.

docker compose

git clone https://github.com/rcbj/oauth2-oidc-debugger.git
cd oauth2-oidc-debugger
docker-compose up

[+] Running 1/1
 ! oauth2-oidc-debugger Warning                                                                                                                                                                                                                                                                                         1.5s 
[+] Building 26.1s (5/9)                                                                                                                                                                                                                                                                                                     
 => [oauth2-oidc-debugger internal] load build definition from Dockerfile                                                                                                                                                                                                                                               0.1s
 => => transferring dockerfile: 206B                                                                                                                                                                                                                                                                                    0.0s
 => [oauth2-oidc-debugger internal] load .dockerignore                                                                                                                                                                                                                                                                  0.1s
 => => transferring context: 65B                                                                                                                                                                                                                                                                                        0.0s
 => [oauth2-oidc-debugger internal] load metadata for docker.io/library/ruby:2.4.0-onbuild                                                                                                                                                                                                                              1.5s
 => ERROR [oauth2-oidc-debugger 1/1] FROM docker.io/library/ruby:2.4.0-onbuild@sha256:0eaa2bbff1e95d17d7f992160c827cd99b582cef0055f09acae77072a9aa4c69                                                                                                                                                                 24.4s
 => => resolve docker.io/library/ruby:2.4.0-onbuild@sha256:0eaa2bbff1e95d17d7f992160c827cd99b582cef0055f09acae77072a9aa4c69                                                                                                                                                                                             0.0s
 => => sha256:0eaa2bbff1e95d17d7f992160c827cd99b582cef0055f09acae77072a9aa4c69 2.42kB / 2.42kB                                                                                                                                                                                                                          0.0s
 => => sha256:693502eb7dfbc6b94964ae66ebc72d3e32facd981c72995b09794f1e87bac184 51.36MB / 51.36MB                                                                                                                                                                                                                        2.1s
 => => sha256:081cd4bfd5210ff69949cc356db9693d11d103cd2380117cff7d4be6966eafdf 18.54MB / 18.54MB                                                                                                                                                                                                                        0.5s
 => => sha256:5d2dc01312f3714eed4630a1317629f9131f307b3fc6d83506444d3eeebc0e41 42.50MB / 42.50MB                                                                                                                                                                                                                        1.5s
 => => sha256:c573a7880cfbbdce35afb825afccf924c54765aa4650b2aeae8bf3a00494487b 8.39kB / 8.39kB                                                                                                                                                                                                                          0.0s
 => => sha256:54a5f7da9a4f2853a0078d1926f7dbd4d12d09b01b13da4aa808d015024419c8 129.85MB / 129.85MB                                                                                                                                                                                                                      4.1s
 => => sha256:168cf3f33330209b5d659614bc0f85b33bdec178d185d6a9e439e98e2d1a3a95 203B / 203B                                                                                                                                                                                                                              1.8s
 => => sha256:5edf1a65e7e1c714fbdc985045123ee8a0daba4b035e0c03d7a948d3fbda18b8 22.64MB / 22.64MB                                                                                                                                                                                                                        3.1s
 => => extracting sha256:693502eb7dfbc6b94964ae66ebc72d3e32facd981c72995b09794f1e87bac184                                                                                                                                                                                                                               2.5s
 => => sha256:c95fc1e51b4de1dc499978b437b947bdee884a8172ab6b5ae423c5dd00721d85 638.12kB / 638.12kB                                                                                                                                                                                                                      2.6s
 => => sha256:0164b0dd2de176a552c7e00d32d23116f87d9bcf122ed0bd8c88b20f7aac98ef 160B / 160B                                                                                                                                                                                                                              2.8s
 => => sha256:9763c7c578ae48b37d9b9e714c551d0916dd1ce7c73ae6693ad62e903a4d815a 186B / 186B                                                                                                                                                                                                                              3.3s
 => => sha256:5e01c0c2c00740b0de4e03ec08887a7886e79b5a5ac15fb8fa49a92388769e24 126B / 126B                                                                                                                                                                                                                              3.7s
 => => extracting sha256:081cd4bfd5210ff69949cc356db9693d11d103cd2380117cff7d4be6966eafdf                                                                                                                                                                                                                               0.7s
 => => extracting sha256:5d2dc01312f3714eed4630a1317629f9131f307b3fc6d83506444d3eeebc0e41                                                                                                                                                                                                                               1.5s
 => => extracting sha256:54a5f7da9a4f2853a0078d1926f7dbd4d12d09b01b13da4aa808d015024419c8                                                                                                                                                                                                                               3.8s
 => => extracting sha256:168cf3f33330209b5d659614bc0f85b33bdec178d185d6a9e439e98e2d1a3a95                                                                                                                                                                                                                               0.0s
 => => extracting sha256:5edf1a65e7e1c714fbdc985045123ee8a0daba4b035e0c03d7a948d3fbda18b8                                                                                                                                                                                                                               0.8s
 => [oauth2-oidc-debugger internal] load build context                                                                                                                                                                                                                                                                  0.1s
 => => transferring context: 235.53kB                                                                                                                                                                                                                                                                                   0.0s
------
 > [oauth2-oidc-debugger 1/1] FROM docker.io/library/ruby:2.4.0-onbuild@sha256:0eaa2bbff1e95d17d7f992160c827cd99b582cef0055f09acae77072a9aa4c69:
------
failed to solve: failed to register layer: unlinkat /usr/share/doc/libgdbm-dev: invalid argument

docker

git clone https://github.com/rcbj/oauth2-oidc-debugger.git
cd oauth2-oidc-debugger/client
docker build -t oauth2-oidc-debugger .
DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
            Install the buildx component to build images with BuildKit:
            https://docs.docker.com/go/buildx/

Sending build context to Docker daemon  248.8kB
Step 1/4 : FROM ruby:2.4.0-onbuild
2.4.0-onbuild: Pulling from library/ruby
693502eb7dfb: Pull complete 
081cd4bfd521: Pull complete 
5d2dc01312f3: Pull complete 
54a5f7da9a4f: Pull complete 
168cf3f33330: Pull complete 
5edf1a65e7e1: Extracting [==================================================>]  22.64MB/22.64MB
c95fc1e51b4d: Download complete 
0164b0dd2de1: Download complete 
9763c7c578ae: Download complete 
5e01c0c2c007: Download complete 
failed to register layer: unlinkat /usr/share/doc/libgdbm-dev: invalid argument

Same happens with buildx installed.

I an running an arch linux with kernel 6.2.12. Other docker related stuff is running fine so far.

Ruby 2.4.0 "invalid address" error in in6_addr

Hi,

Thank you for an amazingly useful tool!

I found the "Get Token" step failing with "invalid address" error, which looks to be ipv6 related. My machine did not have any ipv6 addresses, so not sure where the error was coming from, but looks to be a bug in ruby 2.4.0/2.4.1. supposedly fixed in 2.4.2 (not tested). I worked around it by downgrading to 2.3.0 in the Dockerfile.

Noting here in case anyone else runs into the same issue.

Thanks!
Ben

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.