Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Watari is a Rust/Axum web GUI that sits in front of [rustypaste](https://github.
- `rustypaste.rs` — the rustypaste HTTP client. Field names/headers here were confirmed against rustypaste's actual source, not guessed — see the "rustypaste's real API" doc comment at the top of the file before changing it.
- `csrf.rs` / `csp.rs` / `ratelimit.rs` — `axum_csrf` verification helper, static CSP header middleware, and `tower_governor` layer factories.
- `templates.rs` — `Tpl<T>`, a tiny `IntoResponse` wrapper around `askama::Template::render()` (replaces the `askama_axum` crate, which no longer exists as of askama ≥0.13), and `Layout`, the struct every page template embeds as a `layout: Layout` field for the data `base.html` needs (csrf token, pbkdf2 iterations, user email, admin flag).
- `routes/` — `pages.rs` (dashboard/upload/paste/shorten form pages), `api.rs` (the mutating `/api/*` proxy endpoints + pagination), `decrypt.rs` (public, SSRF-guarded), `admin.rs` (token bindings viewer).
- `routes/` — `pages.rs` (home overview at `/home`, dashboard, upload/paste/shorten form pages; the Home diagram in `templates/home.html` is hand-aligned box-drawing text, so keep columns intact when editing it), `api.rs` (the mutating `/api/*` proxy endpoints + pagination), `decrypt.rs` (public, SSRF-guarded), `admin.rs` (token bindings viewer).

## Known deviations from `watari.md`

Expand Down
1 change: 1 addition & 0 deletions src/routes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub fn router(max_body_bytes: usize) -> Router<AppState> {

Router::new()
.route("/", get(pages::dashboard))
.route("/home", get(pages::home_page))
.route("/upload", get(pages::upload_page))
.route("/paste", get(pages::paste_page))
.route("/shorten", get(pages::shorten_page))
Expand Down
17 changes: 17 additions & 0 deletions src/routes/pages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,23 @@ pub async fn dashboard(
.into_response()
}

#[derive(Template)]
#[template(path = "home.html")]
struct HomeTemplate {
layout: Layout,
}

pub async fn home_page(
State(state): State<AppState>,
session: UserSession,
csrf_token: CsrfToken,
) -> axum::response::Response {
match layout_for(&state, &csrf_token, &session) {
Ok(layout) => (csrf_token, Tpl(HomeTemplate { layout })).into_response(),
Err(e) => crate::error::AppError::Internal(e).into_response(),
}
}

#[derive(Template)]
#[template(path = "upload.html")]
struct UploadTemplate {
Expand Down
32 changes: 32 additions & 0 deletions static/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,31 @@ main {

h1 { font-size: 1.4rem; }

/* --- Home page --- */
.home p,
.home ul { max-width: 42rem; line-height: 1.55; }
.home .lead { font-size: 1.05rem; opacity: 0.8; margin-top: -0.25rem; }
.home h2 { font-size: 1.1rem; margin: 2rem 0 0.5rem; }
.feature-list { padding-left: 1.25rem; }
.feature-list li { margin-bottom: 0.4rem; }

/* Box-drawing diagram in a terminal-UI style; columns must stay aligned, so
it scrolls horizontally instead of wrapping on narrow screens. */
.tui-diagram {
width: fit-content;
max-width: 100%;
overflow-x: auto;
margin: 0.75rem 0 0;
padding: 1rem 1.25rem;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
font-size: 0.78rem;
line-height: 1.2;
border: 1px solid var(--border);
border-radius: 0.4rem;
background: color-mix(in srgb, currentColor 4%, transparent);
}
.tui-title { color: var(--accent); font-weight: 600; }

table.upload-table {
width: 100%;
border-collapse: collapse;
Expand Down Expand Up @@ -328,6 +353,13 @@ button.copy-btn {
color: inherit;
}

.footer-icon {
width: 1em;
height: 1em;
margin-right: 0.3em;
vertical-align: -0.125em;
}

.error-page {
max-width: 32rem;
margin: 4rem auto;
Expand Down
10 changes: 7 additions & 3 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@
<body hx-headers='{"X-CSRF-Token": "{{ layout.csrf_token }}"}'>
<div class="shell">
<aside class="sidebar">
<a class="brand" href="/">
<a class="brand" href="/home">
<span class="brand-mark">☕</span>
<span class="brand-name">Watari</span>
</a>
<nav class="sidebar-nav">
<a href="/home">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="M3 10.5 12 3l9 7.5"/><path d="M5 9v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V9"/><path d="M10 21v-6h4v6"/></svg>
<span>Home</span>
</a>
<a href="/">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="7" height="9" rx="1.5"/><rect x="14" y="3" width="7" height="5" rx="1.5"/><rect x="14" y="12" width="7" height="9" rx="1.5"/><rect x="3" y="16" width="7" height="5" rx="1.5"/></svg>
<span>Dashboard</span>
Expand Down Expand Up @@ -63,10 +67,10 @@
{% block content %}{% endblock %}
</main>
<footer class="footer">
<svg class="footer-icon" role="img" aria-label="On GitHub:" viewBox="0 0 16 16" fill="currentColor"><path d="M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z"/></svg>
<a href="https://github.com/coko7/watari" target="_blank" rel="noopener">Watari</a>
on GitHub ·
·
<a href="https://github.com/orhun/rustypaste" target="_blank" rel="noopener">rustypaste</a>
on GitHub
</footer>
</div>
</div>
Expand Down
38 changes: 38 additions & 0 deletions templates/home.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{% extends "base.html" %}

{% block title %}Home — Watari{% endblock %}

{% block content %}
<div class="home">
<h1>Watari</h1>
<p class="lead">A web front end for <a href="https://github.com/orhun/rustypaste" target="_blank" rel="noopener">rustypaste</a> that gives every teammate their own login.</p>

<h2>Why Watari?</h2>
<p>rustypaste is a minimal self-hosted pastebin and file-sharing server. It only offers an HTTP API protected by shared tokens and has no notion of users, so everyone who wants to use it ends up holding the same raw token.</p>
<p>Watari sits in front of it. You sign in with your organization's SSO, and Watari calls rustypaste for you with a token picked from your groups. That token never reaches your browser, and rustypaste itself runs unchanged: shared links still point straight at it.</p>

<h2>Features</h2>
<ul class="feature-list">
<li><strong>Upload, paste, shorten:</strong> files, text and URLs, with optional expiry or one-shot links that disappear after the first view.</li>
<li><strong>Password protection:</strong> content is encrypted in your browser (AES-GCM). The password and plaintext never reach the server; recipients unlock it on Watari's decrypt page without an account.</li>
<li><strong>Single sign-on:</strong> OIDC login. Your groups decide which rustypaste token, and therefore which permissions, you get.</li>
<li><strong>Dashboard:</strong> everything you've shared through Watari, with copy and delete.</li>
</ul>

<h2>How it works</h2>
<pre class="tui-diagram" role="img" aria-label="Diagram: your browser talks to Watari. Watari signs you in through your identity provider, maps your groups to a rustypaste token, and calls rustypaste with it. People you share a link with download directly from rustypaste without logging in.">
╭ <span class="tui-title">Identity provider</span> ─────╮
│ Keycloak, Zitadel, … │
╰────────────┬───────────╯
│ SSO login + groups
╭ <span class="tui-title">You (browser)</span> ─────╮ ╭ <span class="tui-title">Watari</span> ────▼───────────╮ ╭ <span class="tui-title">rustypaste</span> ────────────╮
│ upload · paste │ session │ OIDC sessions │ token │ stores files, pastes │
│ shorten · history ├────────►│ groups → token binding ├────────►│ and short URLs │
│ optional AES-GCM │ │ upload history │ │ no user accounts │
╰────────────────────╯ ╰────────────────────────╯ ╰────────────▲───────────╯
direct download, no login │
╭ <span class="tui-title">Recipient</span> ─┴───────────╮
│ opens the shared link │
╰────────────────────────╯</pre>
</div>
{% endblock %}
Loading