Skip to content

Commit b75180d

Browse files
committed
Add browser dashboard to spec/dummy for exercising OIDC endpoints
Replace the DummyController root redirect with a single-page dashboard that drives every OpenID Connect endpoint from the browser, removing the need for rails console + curl when trying the gem out by hand. - Setup: create users and OAuth applications via plain Rails forms (CSRF tokens are auto-attached, so it works in development without RAILS_ENV=test) - Discovery: openid-configuration, JWKS and WebFinger - Authorization: code / implicit / form_post with nonce, PKCE, prompt and max_age; the callback hands the code/token back to the dashboard - Token exchange, UserInfo, Introspection and Revocation via fetch() - ID Token header/payload decoded client-side with labelled claims skip_authorization is enabled only in development so a GET to /oauth/authorize redirects straight back with a code; the test environment is unchanged (controller specs stub skip_authorization? themselves). Adds a minimal development environment file. No new tests (dummy UI only).
1 parent 75d1613 commit b75180d

8 files changed

Lines changed: 458 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- [#304] allow handle auth_time per grant
55
- [#305] Document the `auth_time_from_access_token` config option in the README (per-grant `auth_time`), clarifying that it only affects the ID Token `auth_time` claim and not `max_age` enforcement
66
- [#307] Fix `bundle exec rake server` for the test application
7+
- [#309] Add a browser dashboard to the test application (`spec/dummy`) for exercising the OpenID Connect endpoints by hand — replacing the rails console + curl workflow with forms for Setup, Discovery, Authorization (code / implicit / PKCE / nonce / prompt / `max_age`), token exchange, UserInfo, introspection and revocation
78

89
## v1.10.1 (2026-06-03)
910

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,30 @@
11
# frozen_string_literal: true
22

33
class DummyController < ApplicationController
4+
skip_before_action :verify_authenticity_token, only: :callback
5+
46
def index
5-
redirect_to "/.well-known/openid-configuration", status: :found
7+
@users = User.order(:id)
8+
@applications = Doorkeeper::Application.order(:id)
9+
end
10+
11+
def create_user
12+
User.create!(name: params[:name], password: params[:password])
13+
redirect_to root_path, notice: "User #{params[:name]} created"
14+
end
15+
16+
def create_application
17+
Doorkeeper::Application.create!(
18+
name: params[:name],
19+
redirect_uri: params[:redirect_uri].presence || "http://localhost:3000/callback",
20+
scopes: params[:scopes].presence || "openid",
21+
)
22+
redirect_to root_path, notice: "Application created"
23+
end
24+
25+
def callback
26+
@params = request.query_parameters
27+
.merge(request.request_parameters)
28+
.except("controller", "action")
629
end
730
end
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<h1>Returning to the dashboard…</h1>
2+
<p class="muted">Capturing the authorization response and handing it back to the dashboard.</p>
3+
<noscript><p>JavaScript is required. <a href="/">Back to dashboard</a>.</p></noscript>
4+
5+
<script>
6+
var data = <%= raw json_escape(@params.to_json) %>;
7+
if (location.hash.length > 1) {
8+
new URLSearchParams(location.hash.slice(1)).forEach(function (v, k) { data[k] = v; });
9+
}
10+
sessionStorage.setItem('oidc_cb', JSON.stringify(data));
11+
location.replace('/');
12+
</script>

0 commit comments

Comments
 (0)