Skip to content

Commit ac1b74a

Browse files
committed
Improve oauth error webpage
1 parent d1f2dcf commit ac1b74a

3 files changed

Lines changed: 59 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Improve OAuth callback error page to show error code, description, and error URI from the authorization server response.
6+
57
## 0.115.0
68

79
- Improve native image size for smaller eca binaries

resources/webpages/oauth.html

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
background: #fff;
2828
border-radius: 12px;
2929
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
30-
max-width: 400px;
30+
max-width: 480px;
3131
width: 90%;
3232
}
3333

@@ -91,15 +91,49 @@
9191
.error-details {
9292
background: #fef2f2;
9393
border: 1px solid #fecaca;
94-
border-radius: 6px;
95-
padding: 0.75rem 1rem;
94+
border-radius: 8px;
95+
padding: 1rem 1.25rem;
9696
margin-bottom: 1.5rem;
97+
text-align: left;
98+
}
99+
100+
.error-label {
101+
font-size: 0.7rem;
102+
font-weight: 600;
103+
text-transform: uppercase;
104+
letter-spacing: 0.05em;
105+
color: #b91c1c;
106+
margin-bottom: 0.25rem;
107+
}
108+
109+
.error-code {
97110
font-family: monospace;
98-
font-size: 0.85rem;
111+
font-size: 0.9rem;
112+
font-weight: 600;
99113
color: #991b1b;
114+
margin-bottom: 0.75rem;
115+
word-break: break-word;
116+
}
117+
118+
.error-description {
119+
font-size: 0.85rem;
120+
line-height: 1.5;
121+
color: #7f1d1d;
100122
word-break: break-word;
101123
}
102124

125+
.error-link {
126+
display: inline-block;
127+
margin-top: 0.75rem;
128+
font-size: 0.8rem;
129+
color: #b91c1c;
130+
text-decoration: underline;
131+
}
132+
133+
.error-link:hover {
134+
color: #7f1d1d;
135+
}
136+
103137
.hint {
104138
font-size: 0.75rem;
105139
color: #888;
@@ -125,8 +159,17 @@ <h2 class="success">Authentication Successful</h2>
125159
{% if error %}
126160
<div class="status-icon"></div>
127161
<h2 class="error">Authentication Failed</h2>
128-
<p class="message">Something went wrong during authentication.</p>
129-
<div class="error-details">{{error-message}}</div>
162+
<p class="message">The authorization server returned an error.</p>
163+
<div class="error-details">
164+
<div class="error-label">Error</div>
165+
<div class="error-code">{{error-code}}</div>
166+
{% if error-description %}
167+
<div class="error-description">{{error-description}}</div>
168+
{% endif %}
169+
{% if error-uri %}
170+
<a class="error-link" href="{{error-uri}}" target="_blank" rel="noopener noreferrer">More information →</a>
171+
{% endif %}
172+
</div>
130173
{% endif %}
131174

132175
{% if success %}

src/eca/oauth.clj

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,13 @@
3333

3434
(defn ^:private render-oauth-page
3535
"Render the OAuth HTML page with success or error state."
36-
[{:keys [success? error-message]}]
36+
[{:keys [success? error-code error-description error-uri]}]
3737
(selmer/render-file "webpages/oauth.html"
3838
{:success success?
3939
:error (not success?)
40-
:error-message (or error-message "Unknown error")
40+
:error-code (or error-code "unknown_error")
41+
:error-description error-description
42+
:error-uri error-uri
4143
:logo-svg @logo-svg}))
4244

4345
(defn ^:private url->base-url
@@ -97,7 +99,7 @@
9799
:challenge (-> verifier str->sha256 ->base64 ->base64url (string/replace "=" ""))}))
98100

99101
(defn ^:private oauth-handler [request on-success on-error]
100-
(let [{:keys [code error state]} (:params request)]
102+
(let [{:keys [code error error_description error_uri state]} (:params request)]
101103
(if code
102104
(do
103105
(on-success {:code code
@@ -107,7 +109,9 @@
107109
(do
108110
(on-error error)
109111
(-> (response/response (render-oauth-page {:success? false
110-
:error-message error}))
112+
:error-code error
113+
:error-description error_description
114+
:error-uri error_uri}))
111115
(response/content-type "text/html"))))))
112116

113117
(defn ^:private successful-json-body

0 commit comments

Comments
 (0)