Skip to content

Commit c158b2a

Browse files
committed
Head consent "Connect this app to Fizzy?" and name the app in the panel
The heading no longer names a self-registered app by its callback's host with its own name quoted beneath. Every app gets the same heading, and the panel names it, with who set that name in grey beneath, as Connected apps does: the app at the callback's host, an app on your device, the app at its metadata document's host, or 37signals. Self-registered apps keep the caution. Connected apps rows sit in three blocks: the name with its byline tight under it, the access the app holds, and when it connected, with a paragraph's space between them.
1 parent b7cee62 commit c158b2a

10 files changed

Lines changed: 107 additions & 103 deletions

File tree

‎app/assets/stylesheets/oauth.css‎

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@
77
gap: var(--block-space);
88
}
99

10-
/* The heading wraps between words; only a host too long for the line breaks inside it */
11-
.oauth-consent__title {
12-
overflow-wrap: break-word;
13-
}
14-
15-
.oauth-client__self-name {
10+
/* An app's name with its byline tight beneath, on consent and in Connected
11+
apps alike. A long name or host breaks inside itself rather than widening
12+
the panel */
13+
.oauth-client__identity,
14+
.connected-app__identity {
15+
display: flex;
16+
flex-direction: column;
17+
gap: 0.1em;
18+
min-inline-size: 0;
1619
overflow-wrap: anywhere;
1720
}
1821

@@ -158,14 +161,18 @@
158161
flex-shrink: 0;
159162
}
160163

161-
/* Padding, since the bylines' margin-none utility outranks a component's margin */
162-
.connected-app__byline {
163-
padding-block-end: 0.3em;
164-
}
165-
164+
/* Three blocks: the name and its byline, the access the app holds, and when
165+
it connected. The access lines sit together, with a paragraph's space
166+
between them and the grey lines either side */
166167
.connected-app__details {
167-
gap: 0.15em;
168+
gap: var(--block-space-half);
168169
min-inline-size: 0;
169170
overflow-wrap: anywhere;
170171
}
172+
173+
.connected-app__reach {
174+
display: flex;
175+
flex-direction: column;
176+
gap: 0.15em;
177+
}
171178
}

‎app/helpers/oauth_helper.rb‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,6 @@ def oauth_client_self_name(client)
4848
client.name.to_s.gsub(BIDI_CONTROLS, "").presence || "Unnamed app"
4949
end
5050

51-
# Who the person is dealing with, as far as we can vouch for it. A trusted or
52-
# operator-registered app is known by its name. A self-registered app's name
53-
# is only its claim, so it goes by where its access goes: the callback's
54-
# host, port included when it isn't the default, or this device.
55-
def oauth_client_display_identity(client, redirect_uri)
56-
if client.dynamically_registered?
57-
oauth_redirect_host(redirect_uri) || "an app on your device"
58-
else
59-
oauth_client_self_name(client)
60-
end
61-
end
62-
6351
# Lowercase, as a browser reads it. nil for a callback that stays on this
6452
# device: loopback, or an app's own URL scheme.
6553
def oauth_redirect_host(redirect_uri)

‎app/views/my/connected_apps/_connected_app.html.erb‎

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,34 @@
33
<article class="connected-app" id="<%= dom_id(client, :connected_app) %>">
44
<div class="connected-app__details flex flex-column">
55
<%# A self-registered app goes by the name it gave itself, since that's the
6-
name people know it by, but never without where its access goes %>
7-
<h3 class="connected-app__name txt-medium margin-none" id="<%= dom_id(client, :connected_app_name) %>"><bdi><%= oauth_client_self_name(client) %></bdi></h3>
6+
name people know it by, but never without where its access goes. The
7+
byline sits tight under the name, as on consent (oauth/authorizations/client),
8+
and the access it holds reads as a block of its own %>
9+
<div class="connected-app__identity">
10+
<h3 class="connected-app__name txt-medium margin-none" id="<%= dom_id(client, :connected_app_name) %>"><bdi><%= oauth_client_self_name(client) %></bdi></h3>
811

9-
<% if client.dynamically_registered? %>
10-
<p class="connected-app__byline txt-x-small txt-subtle margin-none">
11-
<% if remote_hosts.any? %>
12-
Name set by the app at <%= remote_hosts.to_sentence(two_words_connector: " or ", last_word_connector: " or ") %>
13-
<% else %>
14-
Name set by an app on your device
15-
<% end %>
16-
</p>
17-
<% elsif client.metadata_document? %>
18-
<p class="connected-app__byline txt-x-small txt-subtle margin-none">Name set by the app at <%= URI.parse(client.client_id).host %></p>
19-
<% elsif client.trusted? %>
20-
<p class="connected-app__byline txt-x-small txt-subtle margin-none">Made by 37signals</p>
21-
<% end %>
12+
<% if client.dynamically_registered? %>
13+
<p class="connected-app__byline txt-x-small txt-subtle margin-none">
14+
<% if remote_hosts.any? %>
15+
Name set by the app at <%= remote_hosts.to_sentence(two_words_connector: " or ", last_word_connector: " or ") %>
16+
<% else %>
17+
Name set by an app on your device
18+
<% end %>
19+
</p>
20+
<% elsif client.metadata_document? %>
21+
<p class="connected-app__byline txt-x-small txt-subtle margin-none">Name set by the app at <%= URI.parse(client.client_id).host %></p>
22+
<% elsif client.trusted? %>
23+
<p class="connected-app__byline txt-x-small txt-subtle margin-none">Made by 37signals</p>
24+
<% end %>
25+
</div>
2226

23-
<% oauth_connected_app_reach(tokens).each do |permission, accounts| %>
24-
<p class="connected-app__access txt-small margin-none">
25-
<strong><%= oauth_access_label(permission) %></strong>, <% if accounts %>in <%= to_sentence(accounts.map { |account| tag.bdi(account.name) }) %><% else %>in every account you belong to<% end %>
26-
</p>
27-
<% end %>
27+
<div class="connected-app__reach">
28+
<% oauth_connected_app_reach(tokens).each do |permission, accounts| %>
29+
<p class="connected-app__access txt-small margin-none">
30+
<strong><%= oauth_access_label(permission) %></strong>, <% if accounts %>in <%= to_sentence(accounts.map { |account| tag.bdi(account.name) }) %><% else %>in every account you belong to<% end %>
31+
</p>
32+
<% end %>
33+
</div>
2834

2935
<%# updated_at moves each time the app renews its access %>
3036
<p class="txt-x-small txt-subtle margin-none">
Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,37 @@
1-
<%# Who is asking, as far as Fizzy can vouch for it, under the heading that
2-
names it. A self-registered app's name is only its claim, typed by whoever
3-
registered it, so it's shown as exactly that: quoted and subdued, beside a
4-
caution, with the heading naming where its access goes. bdi keeps any
5-
right-to-left letters in the name from moving the quotes. %>
6-
<% if client.dynamically_registered? %>
7-
<header class="oauth-client flex flex-column gap-half">
8-
<p class="oauth-client__self-name txt-small txt-subtle margin-none">
9-
Says it&rsquo;s &ldquo;<bdi><%= oauth_client_self_name(client) %></bdi>&rdquo;
10-
</p>
1+
<%# The app's name, and under it who set it, as Connected apps shows it
2+
(my/connected_apps/connected_app). A self-registered app's name is only its
3+
claim, typed by whoever registered it, so the line beneath names where this
4+
request's access goes, the one thing about it Fizzy can vouch for, and a
5+
caution follows. bdi keeps any right-to-left letters in the name from
6+
reordering the text around it. %>
7+
<% redirect_host = oauth_redirect_host(redirect_uri) %>
8+
9+
<header class="oauth-client flex flex-column gap">
10+
<div class="oauth-client__identity">
11+
<h2 class="oauth-client__name txt-large margin-none"><bdi><%= oauth_client_self_name(client) %></bdi></h2>
12+
13+
<% if client.dynamically_registered? %>
14+
<p class="oauth-client__byline txt-small txt-subtle margin-none">
15+
<% if redirect_host %>
16+
Name set by the app at <%= redirect_host %>
17+
<% else %>
18+
Name set by an app on your device
19+
<% end %>
20+
</p>
21+
<% elsif client.metadata_document? %>
22+
<p class="oauth-client__byline txt-small txt-subtle margin-none">Name set by the app at <%= URI.parse(client.client_id).host %></p>
23+
<% elsif client.trusted? %>
24+
<p class="oauth-client__byline txt-small txt-subtle margin-none">Made by 37signals</p>
25+
<% end %>
26+
</div>
1127

28+
<% if client.dynamically_registered? %>
1229
<p class="oauth-client__warning txt-small margin-none" role="note">
13-
<% if oauth_redirect_host(redirect_uri) %>
30+
<% if redirect_host %>
1431
<strong>We haven&rsquo;t checked this app.</strong> Only authorize it if you trust that address.
1532
<% else %>
1633
<strong>We haven&rsquo;t checked this app.</strong> Only authorize it if you started it.
1734
<% end %>
1835
</p>
19-
</header>
20-
<% elsif client.metadata_document? %>
21-
<p class="oauth-client__self-name txt-small txt-subtle margin-none">
22-
Name set by the app at <strong><%= URI.parse(client.client_id).host %></strong>.
23-
</p>
24-
<% elsif client.trusted? %>
25-
<p class="oauth-client__made-by txt-small txt-subtle margin-none">Made by 37signals.</p>
26-
<% end %>
36+
<% end %>
37+
</header>

‎app/views/oauth/authorizations/new.html.erb‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
<% identity = oauth_client_display_identity(@client, @redirect_uri) %>
2-
<% redirect_host = oauth_redirect_host(@redirect_uri) %>
3-
<%# A self-registered app is headed by where its access goes, the one thing
4-
about it Fizzy can vouch for: "the app at <host>", or an app on this
5-
device. Any other app is known by its name. %>
6-
<% heading_identity = @client.dynamically_registered? && redirect_host ? "the app at #{redirect_host}" : identity %>
7-
<% @page_title = "Connect #{heading_identity} to Fizzy" %>
1+
<%# One heading for every app. Its name, which a self-registered app typed
2+
itself, goes in the panel beside who set it (oauth/authorizations/client),
3+
so the heading never repeats a claim Fizzy can't vouch for. %>
4+
<% @page_title = "Connect this app to Fizzy" %>
85

96
<% content_for :header do %>
10-
<h1 class="header__title oauth-consent__title">Connect <bdi><%= heading_identity %></bdi> to Fizzy?</h1>
7+
<h1 class="header__title">Connect this app to Fizzy?</h1>
118

129
<%# "Use a different account?" signs out and returns whoever signs in to this same request %>
1310
<div class="oauth-consent__identity flex align-center justify-center gap-half txt-small txt-subtle">

‎test/helpers/oauth_helper_test.rb‎

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,11 @@ class OauthHelperTest < ActionView::TestCase
1818
assert_equal "Unnamed app", oauth_client_self_name(Oauth::Client.new(name: "\u202E\u2066\u2069"))
1919
end
2020

21-
test "a self-registered app is identified by its callback's host, port included when it isn't the default" do
22-
client = Oauth::Client.new name: "Hosted", dynamically_registered: true
23-
24-
assert_equal "connector.example.com", oauth_client_display_identity(client, "https://connector.example.com/callback")
25-
assert_equal "connector.example.com:8443", oauth_client_display_identity(client, "https://connector.example.com:8443/callback")
26-
assert_equal "an app on your device", oauth_client_display_identity(client, "http://127.0.0.1:8888/callback")
27-
assert_equal "an app on your device", oauth_client_display_identity(client, "com.example.app:/callback")
28-
end
29-
30-
test "a registered app is identified by its name" do
31-
assert_equal "Trusted First-Party App", oauth_client_display_identity(oauth_clients(:trusted_client), "https://app.example.com/oauth/callback")
21+
test "a callback's host reads as a browser reads it, port included when it isn't the default, and nil on this device" do
22+
assert_equal "connector.example.com", oauth_redirect_host("https://Connector.Example.com/callback")
23+
assert_equal "connector.example.com:8443", oauth_redirect_host("https://connector.example.com:8443/callback")
24+
assert_nil oauth_redirect_host("http://127.0.0.1:8888/callback")
25+
assert_nil oauth_redirect_host("com.example.app:/callback")
3226
end
3327

3428
test "a read-only client is offered read alone" do
@@ -84,8 +78,4 @@ class OauthHelperTest < ActionView::TestCase
8478
assert_operator level[:description].split.size, :<=, 12
8579
end
8680
end
87-
88-
test "a redirect's host reads in lowercase, as a browser reads it" do
89-
assert_equal "connector.example.com:8443", oauth_redirect_host("https://Connector.EXAMPLE.com:8443/cb")
90-
end
9181
end

‎test/integration/oauth_client_metadata_documents_test.rb‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ class OauthClientMetadataDocumentsTest < ActionDispatch::IntegrationTest
3030
untenanted { get new_oauth_authorization_path, params: authorization }
3131

3232
assert_response :success
33-
assert_match "Claude", response.body
34-
assert_match "Name set by the app at", response.body
33+
assert_select "h1", text: "Connect this app to Fizzy?"
34+
assert_select ".oauth-client__name bdi", text: "Claude"
35+
assert_select ".oauth-client__byline", text: "Name set by the app at claude.ai"
36+
assert_select ".oauth-client__warning", count: 0
3537
assert_nil Oauth::Client.find_presented(URL)
3638
end
3739

‎test/integration/oauth_consent_screen_test.rb‎

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,40 @@ class OauthConsentScreenTest < ActionDispatch::IntegrationTest
55
sign_in_as :david
66
end
77

8-
test "a self-registered web app goes by its callback's host, named once, its own name quoted beneath" do
8+
test "a self-registered web app is named in the panel, by the address that set the name, under a heading for every app" do
99
client = Oauth::Client.create! name: "Totally Fizzy", dynamically_registered: true,
1010
redirect_uris: %w[ https://connector.example.com/callback ]
1111

1212
get_consent_screen client
1313

1414
assert_response :success
15-
assert_select "title", text: /Connect the app at connector\.example\.com to Fizzy/
16-
assert_select "h1", text: "Connect the app at connector.example.com to Fizzy?"
17-
assert_select ".oauth-client__self-name", text: /\ASays it’s “Totally Fizzy”\z/
15+
assert_select "title", text: /Connect this app to Fizzy/
16+
assert_select "h1", text: "Connect this app to Fizzy?"
17+
assert_select ".oauth-client__name bdi", text: "Totally Fizzy"
18+
assert_select ".oauth-client__byline", text: /\AName set by the app at connector\.example\.com\z/
1819
assert_select ".oauth-client__warning", text: /\AWe haven’t checked this app\. Only authorize it if you trust that address\.\z/
1920
assert_equal 1, response.parsed_body.at("body").text.scan("connector.example.com").size
21+
assert_no_match "Says it", response.body
2022
assert_select ".oauth-consent__fine-print", text: /\AIf you change your mind, you can revoke its access at any time in Connected apps\.\z/
2123
end
2224

23-
test "a self-registered app on this device is named as one" do
25+
test "a self-registered app on this device says its name was set on the device" do
2426
get_consent_screen oauth_clients(:mcp_client)
2527

2628
assert_response :success
27-
assert_select "h1", text: "Connect an app on your device to Fizzy?"
28-
assert_select ".oauth-client__self-name", text: /\ASays it’s “Test MCP Client”\z/
29+
assert_select "h1", text: "Connect this app to Fizzy?"
30+
assert_select ".oauth-client__name bdi", text: "Test MCP Client"
31+
assert_select ".oauth-client__byline", text: /\AName set by an app on your device\z/
2932
assert_select ".oauth-client__warning", text: /\AWe haven’t checked this app\. Only authorize it if you started it\.\z/
3033
end
3134

32-
test "a trusted app is known by its name and carries no warning" do
35+
test "a trusted app is made by 37signals and carries no warning" do
3336
get_consent_screen oauth_clients(:trusted_client)
3437

3538
assert_response :success
36-
assert_select "h1", text: "Connect Trusted First-Party App to Fizzy?"
37-
assert_select ".oauth-client__made-by", text: "Made by 37signals."
38-
assert_select ".oauth-client__self-name", count: 0
39+
assert_select "h1", text: "Connect this app to Fizzy?"
40+
assert_select ".oauth-client__name bdi", text: "Trusted First-Party App"
41+
assert_select ".oauth-client__byline", text: "Made by 37signals"
3942
assert_select ".oauth-client__warning", count: 0
4043
end
4144

@@ -47,7 +50,7 @@ class OauthConsentScreenTest < ActionDispatch::IntegrationTest
4750

4851
assert_response :success
4952
assert_no_match "‮", response.body
50-
assert_select ".oauth-client__self-name bdi", text: "Goodppa App"
53+
assert_select ".oauth-client__name bdi", text: "Goodppa App"
5154
end
5255

5356
test "each access level says what it lets the app do" do

‎test/integration/oauth_dcr_redirect_allowlist_test.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class OauthDcrRedirectAllowlistTest < ActionDispatch::IntegrationTest
8989
end
9090
assert_response :success
9191
assert_includes response.headers["Content-Security-Policy"], "cursor:"
92-
assert_select "h1", text: "Connect an app on your device to Fizzy?"
92+
assert_select "h1", text: "Connect this app to Fizzy?"
9393

9494
untenanted do
9595
post oauth_authorization_path, params: {

‎test/integration/oauth_flow_test.rb‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,14 @@ class OauthFlowTest < ActionDispatch::IntegrationTest
166166
assert_equal "invalid_request", Rack::Utils.parse_query(URI.parse(response.location).query)["error"]
167167
end
168168

169-
test "consent names a self-registered redirect's port when it isn't the default" do
169+
test "consent names a self-registered redirect's port, when it isn't the default, as where the name was set" do
170170
sign_in_as :david
171171
client = Oauth::Client.create!(name: "Hosted", redirect_uris: %w[ https://connector.example.com:8443/callback ], dynamically_registered: true)
172172

173173
get_consent_screen client: client
174174

175175
assert_response :success
176-
assert_select "h1", text: "Connect the app at connector.example.com:8443 to Fizzy?"
176+
assert_select ".oauth-client__byline", text: /\AName set by the app at connector\.example\.com:8443\z/
177177
assert_equal 1, response.parsed_body.at("body").text.scan("connector.example.com:8443").size
178178
end
179179

0 commit comments

Comments
 (0)