Skip to content

Commit f71ac37

Browse files
authored
Calm the consent page: name the app once, say each thing once (#3275)
The page is a decision made in a moment. Its heading now asks "Connect <app> to Fizzy?", naming a self-registered app by where its access goes, once: the second heading under it, which broke mid-port on phones, is gone, and the caution and fine print no longer repeat the host. "Act as you" and "It works as you, so it can only reach what you can" are one line under the choices, the choices are a word and a short line, and the how-to lines (connect again to add another account, either way you'll go back to…) leave the decision screen. One fine-print line stays: where to disconnect.
1 parent d5814f5 commit f71ac37

10 files changed

Lines changed: 60 additions & 69 deletions

File tree

‎app/assets/stylesheets/oauth.css‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
gap: var(--block-space);
88
}
99

10-
.oauth-client__name {
11-
overflow-wrap: anywhere;
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;
1213
}
1314

1415
.oauth-client__self-name {

‎app/helpers/oauth_helper.rb‎

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ module OauthHelper
1515
ACCESS_LEVELS = {
1616
"read" => {
1717
label: "Read only",
18-
description: "See your boards, cards, comments and the people in your %{accounts}. It can't change anything."
18+
description: "See boards, cards, comments and people. It can't change anything."
1919
},
2020
"read write" => {
2121
label: "Read and write",
22-
description: "See everything you can, and act as you: create, edit, move, close and delete cards, comments and boards."
22+
description: "Also create, edit, move, close and delete cards, comments and boards."
2323
}
2424
}
2525

@@ -60,15 +60,11 @@ def oauth_client_remote_hosts(client)
6060
end
6161

6262
# The access levels a client may be granted, weakest first, each with what
63-
# it lets the app do in plain words. A grant reaches every account the
64-
# person belongs to, unless it's bound to the one picked at consent.
65-
def oauth_access_levels(client, one_account: false)
63+
# it lets the app do in a few words. Which accounts it reaches is said once,
64+
# under the choices (oauth/authorizations/access).
65+
def oauth_access_levels(client)
6666
levels = client.scopes.include?("write") ? ACCESS_LEVELS.keys : %w[ read ]
67-
68-
levels.map do |scope|
69-
level = ACCESS_LEVELS.fetch(scope)
70-
[ scope, level.merge(description: format(level[:description], accounts: one_account ? "account" : "accounts")) ]
71-
end
67+
ACCESS_LEVELS.slice(*levels).to_a
7268
end
7369

7470
def oauth_strongest_permission(tokens)
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
<%# Fizzy's two access levels, each in plain words. Write includes read, so
1+
<%# Fizzy's two access levels, each in a few words. Write includes read, so
22
the choice is one or the other; a client registered for read alone gets
33
the single option, shown so the person still sees what they're granting. %>
44
<fieldset class="oauth-access flex flex-column gap-half">
55
<legend class="oauth-access__legend"><strong>Access</strong></legend>
66

7-
<% oauth_access_levels(client, one_account: local_assigns[:one_account]).each do |value, level| %>
7+
<% oauth_access_levels(client).each do |value, level| %>
88
<label class="oauth-access__choice">
99
<%= form.radio_button :scope, value, checked: value == scope, class: "oauth-access__radio" %>
1010
<span class="flex flex-column">
@@ -16,9 +16,9 @@
1616

1717
<p class="oauth-access__reach txt-x-small txt-subtle margin-none">
1818
<% if local_assigns[:one_account] %>
19-
It works as you, so it can only reach what you can, in the account above.
19+
It acts as you, so it reaches only what you can, in that account.
2020
<% else %>
21-
It works as you, so it can only reach what you can, in every account you belong to.
21+
It acts as you, so it reaches only what you can, in every account you belong to.
2222
<% end %>
2323
</p>
2424
</fieldset>

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,4 @@
1717
</label>
1818
<% end %>
1919
<% end %>
20-
21-
<p class="txt-x-small txt-subtle margin-none">The app reaches this account only. Connect it again to add another.</p>
2220
</fieldset>
Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
1-
<%# Who is asking, as far as Fizzy can vouch for it. A self-registered app's
2-
name is only its claim, typed by whoever registered it, so it's shown as
3-
exactly that: what the app says it is, quoted and subdued, under a heading
4-
that names where the access goes (bc3 reads the same). bdi keeps any
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
55
right-to-left letters in the name from moving the quotes. %>
6-
<header class="oauth-client flex flex-column gap-half">
7-
<h2 class="oauth-client__name txt-large margin-none"><bdi><%= client.dynamically_registered? && redirect_host.nil? ? identity.upcase_first : identity %></bdi></h2>
8-
9-
<% if client.dynamically_registered? %>
6+
<% if client.dynamically_registered? %>
7+
<header class="oauth-client flex flex-column gap-half">
108
<p class="oauth-client__self-name txt-small txt-subtle margin-none">
119
Says it&rsquo;s &ldquo;<bdi><%= oauth_client_self_name(client) %></bdi>&rdquo;
1210
</p>
1311

1412
<p class="oauth-client__warning txt-small margin-none" role="note">
15-
<% if redirect_host %>
16-
<strong>We haven&rsquo;t checked this app.</strong> Anyone can run an app at any address, so only authorize it if you trust <strong><%= redirect_host %></strong>.
13+
<% if oauth_redirect_host(redirect_uri) %>
14+
<strong>We haven&rsquo;t checked this app.</strong> Only authorize it if you trust that address.
1715
<% else %>
18-
<strong>We haven&rsquo;t checked this app.</strong> It runs on your device and will get this access, so only authorize it if you started it.
16+
<strong>We haven&rsquo;t checked this app.</strong> Only authorize it if you started it.
1917
<% end %>
2018
</p>
21-
<% elsif client.metadata_document? %>
22-
<p class="oauth-client__self-name txt-small txt-subtle margin-none">
23-
Name set by the app at <strong><%= URI.parse(client.client_id).host %></strong>
24-
</p>
25-
<% elsif client.trusted? %>
26-
<p class="oauth-client__made-by txt-small txt-subtle margin-none">Made by 37signals</p>
27-
<% end %>
28-
</header>
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 %>

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

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
<% identity = oauth_client_display_identity(@client, @redirect_uri) %>
22
<% redirect_host = oauth_redirect_host(@redirect_uri) %>
3-
<%# A self-registered web app is headed by where its access goes, as bc3's
4-
consent reads: "Authorize the app at <host>". %>
5-
<% @page_title = "Authorize #{@client.dynamically_registered? && redirect_host ? "the app at #{redirect_host}" : identity}" %>
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" %>
68

79
<% content_for :header do %>
8-
<h1 class="header__title"><%= @page_title %></h1>
10+
<h1 class="header__title oauth-consent__title">Connect <bdi><%= heading_identity %></bdi> to Fizzy?</h1>
911
<% end %>
1012

1113
<article class="oauth-consent panel panel--wide shadow center txt-align-start">
12-
<%= render "oauth/authorizations/client", client: @client, identity: identity, redirect_host: redirect_host %>
14+
<%= render "oauth/authorizations/client", client: @client, redirect_uri: @redirect_uri %>
1315

1416
<%# Not you? signs out and returns whoever signs in to this same request %>
1517
<div class="oauth-consent__identity flex align-center gap-half txt-small txt-subtle">
@@ -36,13 +38,8 @@
3638

3739
<%= render "oauth/authorizations/access", form: f, client: @client, scope: @scope, one_account: @accounts.present? %>
3840

39-
<p class="oauth-consent__destination txt-small txt-subtle margin-none">
40-
<% if redirect_host %>
41-
Either way, you'll go back to <strong><%= redirect_host %></strong>.
42-
<% else %>
43-
Either way, you'll go back to the app on your device.
44-
<% end %>
45-
You can disconnect it at any time in <%= link_to "Connected apps", my_connected_apps_path, class: "txt-link" %>.
41+
<p class="oauth-consent__fine-print txt-x-small txt-subtle margin-none">
42+
You can disconnect it anytime in <%= link_to "Connected apps", my_connected_apps_path, class: "txt-link" %>.
4643
</p>
4744

4845
<div class="oauth-consent__actions flex gap">

‎test/helpers/oauth_helper_test.rb‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,12 @@ class OauthHelperTest < ActionView::TestCase
6464
assert_equal %w[ a.example.com b.example.com:8443 ], oauth_client_remote_hosts(client)
6565
end
6666

67-
test "read's description names the people in every account, or in the one account a bound grant reaches" do
68-
client = oauth_clients(:mcp_client)
69-
70-
assert_match "the people in your accounts.", oauth_access_levels(client).to_h.fetch("read")[:description]
71-
assert_match "the people in your account.", oauth_access_levels(client, one_account: true).to_h.fetch("read")[:description]
67+
test "each access level has a short label and a line saying what it allows" do
68+
oauth_access_levels(oauth_clients(:mcp_client)).each do |_, level|
69+
assert level[:label].present?
70+
assert level[:description].present?
71+
assert_operator level[:description].split.size, :<=, 12
72+
end
7273
end
7374

7475
test "a redirect's host reads in lowercase, as a browser reads it" do

‎test/integration/oauth_consent_screen_test.rb‎

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,35 @@ 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, its own name quoted beside it" do
8+
test "a self-registered web app goes by its callback's host, named once, its own name quoted beneath" 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: /Authorize the app at connector\.example\.com/
16-
assert_select "h1", text: "Authorize the app at connector.example.com"
17-
assert_select ".oauth-client__name", text: "connector.example.com"
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?"
1817
assert_select ".oauth-client__self-name", text: /\ASays it’s “Totally Fizzy”\z/
19-
assert_select ".oauth-client__warning", text: /\AWe haven’t checked this app\. Anyone can run an app at any address, so only authorize it if you trust connector\.example\.com\.\z/
20-
assert_select ".oauth-consent__destination strong", text: "connector.example.com"
18+
assert_select ".oauth-client__warning", text: /\AWe haven’t checked this app\. Only authorize it if you trust that address\.\z/
19+
assert_equal 1, response.parsed_body.at("body").text.scan("connector.example.com").size
2120
end
2221

2322
test "a self-registered app on this device is named as one" do
2423
get_consent_screen oauth_clients(:mcp_client)
2524

2625
assert_response :success
27-
assert_select ".oauth-client__name", text: "An app on your device"
26+
assert_select "h1", text: "Connect an app on your device to Fizzy?"
2827
assert_select ".oauth-client__self-name", text: /\ASays it’s “Test MCP Client”\z/
29-
assert_select ".oauth-client__warning", text: /\AWe haven’t checked this app\. It runs on your device and will get this access, so only authorize it if you started it\.\z/
30-
assert_select ".oauth-consent__destination", text: /the app on your device/
28+
assert_select ".oauth-client__warning", text: /\AWe haven’t checked this app\. Only authorize it if you started it\.\z/
3129
end
3230

3331
test "a trusted app is known by its name and carries no warning" do
3432
get_consent_screen oauth_clients(:trusted_client)
3533

3634
assert_response :success
37-
assert_select ".oauth-client__name", text: "Trusted First-Party App"
38-
assert_select ".oauth-client__made-by", text: "Made by 37signals"
35+
assert_select "h1", text: "Connect Trusted First-Party App to Fizzy?"
36+
assert_select ".oauth-client__made-by", text: "Made by 37signals."
3937
assert_select ".oauth-client__self-name", count: 0
4038
assert_select ".oauth-client__warning", count: 0
4139
end
@@ -56,9 +54,10 @@ class OauthConsentScreenTest < ActionDispatch::IntegrationTest
5654

5755
assert_response :success
5856
assert_select ".oauth-access__choice", count: 2
59-
assert_select ".oauth-access__choice", text: /Read only.*the people in your accounts\. It can't change anything/m
57+
assert_select ".oauth-access__choice", text: /Read only.*It can't change anything/m
6058
assert_select ".oauth-access__choice", text: /Read and write.*delete cards/m
61-
assert_select ".oauth-access__reach", text: /every account you belong to/
59+
assert_select ".oauth-access__reach", text: /\AIt acts as you, so it reaches only what you can, in every account you belong to\.\z/
60+
assert_select ".oauth-consent__fine-print", text: /\AYou can disconnect it anytime in Connected apps\.\z/
6261
end
6362

6463
test "the person sees who they're signed in as" 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 ".oauth-consent__destination", text: /the app on your device/
92+
assert_select "h1", text: "Connect an app on your device to Fizzy?"
9393

9494
untenanted do
9595
post oauth_authorization_path, params: {

‎test/integration/oauth_flow_test.rb‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ class OauthFlowTest < ActionDispatch::IntegrationTest
173173
get_consent_screen client: client
174174

175175
assert_response :success
176-
assert_select "strong", text: "connector.example.com:8443"
176+
assert_select "h1", text: "Connect the app at connector.example.com:8443 to Fizzy?"
177+
assert_equal 1, response.parsed_body.at("body").text.scan("connector.example.com:8443").size
177178
end
178179

179180
test "consent restarts a self-registered client's retention period, so the sweep spares it while the code is live" do

0 commit comments

Comments
 (0)