Skip to content

Commit

Permalink
Merge pull request #25 from sorah/fancy-oauth-response
Browse files Browse the repository at this point in the history
oauth_code: fancy callback page
  • Loading branch information
sorah authored Feb 5, 2025
2 parents 6b26e99 + 5070c48 commit 96c4f8b
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## 0.7.0

- redirect_uri endpoint returns fancier HTML page during OAuth 2.0 Authorization Code flow.
- New subcomand `mairu list-roles` lists possible `role` parameter for a server. Corresponding HTTP API is added to the spec.
- `mairu` command now suggets user to restart agent when a connected agent reports different version.

Expand Down
4 changes: 3 additions & 1 deletion src/oauth_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ struct CallbackQuery {
/// HTML <head> to supress favicon.ico request
const HTML_PREAMBLE: &str = r#"<!DOCTYPE html><html><head><link rel="icon" href="data:;base64,iVBORw0KGgo="><style>body { font-family: monospace; }</style></head><body>"#;

const HTML_OK: &str = include_str!("oauth_code_ok.html");

#[allow(clippy::type_complexity)]
#[tracing::instrument(skip_all)]
async fn callback(
Expand Down Expand Up @@ -233,6 +235,6 @@ async fn callback(
Ok((
axum::http::StatusCode::OK,
[("content-type", "text/html; charset=utf-8")],
format!("{}ok", HTML_PREAMBLE),
HTML_OK.to_string(),
))
}
44 changes: 44 additions & 0 deletions src/oauth_code_ok.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!DOCTYPE html>
<html lang="en">
<head>
<!-- HTML <head> to supress favicon.ico request -->
<link rel="icon" href="data:;base64,iVBORw0KGgo=">
<style>
body, p {
font-family: sans-serif;
}
body {
text-align: center;
}
main {
width: 450px;
text-align: center;
margin-left: auto;
margin-right: auto;
}
main header {
font-size: 90px;
}
main section p {
font-size: 16px;
}
main footer p {
color: #767676;
font-size: 12px;
}
</style>
</head>
<body>
<main>
<header>
</header>
<section>
<p>Logged in. You can now close this page.</p>
</section>
<footer>
<p>Powered by <a href="https://github.com/sorah/mairu">Mairu</a></p>
</footer>
</main>
</body>
</html>

0 comments on commit 96c4f8b

Please sign in to comment.