diff --git a/coderd/oauth2provider/authorize.go b/coderd/oauth2provider/authorize.go index 15471baf8d..1480259c1f 100644 --- a/coderd/oauth2provider/authorize.go +++ b/coderd/oauth2provider/authorize.go @@ -175,10 +175,10 @@ func ShowAuthorizePage(accessURL *url.URL) http.HandlerFunc { AppName: app.Name, // #nosec G203 -- The scheme is validated by // codersdk.ValidateRedirectURIScheme above. - CancelURI: htmltemplate.URL(cancelURI), - RedirectURI: r.URL.String(), - CSRFToken: nosurf.Token(r), - Username: ua.FriendlyName, + CancelURI: htmltemplate.URL(cancelURI), + DashboardURL: accessURL.String(), + CSRFToken: nosurf.Token(r), + Username: ua.FriendlyName, }) } } diff --git a/coderd/oauth2provider/authorize_test.go b/coderd/oauth2provider/authorize_test.go index 42f5d0258f..61e037a8a4 100644 --- a/coderd/oauth2provider/authorize_test.go +++ b/coderd/oauth2provider/authorize_test.go @@ -20,14 +20,17 @@ func TestOAuthConsentFormIncludesCSRFToken(t *testing.T) { rec := httptest.NewRecorder() site.RenderOAuthAllowPage(rec, req, site.RenderOAuthAllowData{ - AppName: "Test OAuth App", - CancelURI: htmltemplate.URL("https://coder.com/cancel"), - RedirectURI: "https://coder.com/oauth2/authorize?client_id=test", - CSRFToken: csrfFieldValue, - Username: "test-user", + AppName: "Test OAuth App", + CancelURI: htmltemplate.URL("https://coder.com/cancel"), + DashboardURL: "https://coder.com/", + CSRFToken: csrfFieldValue, + Username: "test-user", }) require.Equal(t, http.StatusOK, rec.Result().StatusCode) - assert.Contains(t, rec.Body.String(), `name="csrf_token"`) - assert.Contains(t, rec.Body.String(), `value="`+csrfFieldValue+`"`) + body := rec.Body.String() + assert.Contains(t, body, `name="csrf_token"`) + assert.Contains(t, body, `value="`+csrfFieldValue+`"`) + assert.Contains(t, body, `id="allow-form"`) + assert.Contains(t, body, `id="cancel-link"`) } diff --git a/site/site.go b/site/site.go index 819b51d7ef..a4d123c00f 100644 --- a/site/site.go +++ b/site/site.go @@ -799,12 +799,12 @@ func (jfs justFilesSystem) Open(name string) (fs.File, error) { // RenderOAuthAllowData contains the variables that are found in // site/static/oauth2allow.html. type RenderOAuthAllowData struct { - AppIcon string - AppName string - CancelURI htmltemplate.URL - RedirectURI string - CSRFToken string - Username string + AppIcon string + AppName string + CancelURI htmltemplate.URL + DashboardURL string + CSRFToken string + Username string } // RenderOAuthAllowPage renders the static page for a user to "Allow" an create diff --git a/site/static/oauth2allow.html b/site/static/oauth2allow.html index 76fb4927c1..a9457e80a5 100644 --- a/site/static/oauth2allow.html +++ b/site/static/oauth2allow.html @@ -64,7 +64,7 @@ links */}} line-height: 140%; } - .user-name { + .user-name { font-weight: bold; } @@ -113,17 +113,53 @@ links */}} Coder

Authorize {{ .AppName }}

-

+

Allow {{ .AppName }} to have full access to your {{ .Username }} account?

-
-
+
+ - Cancel + Cancel
+