<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Rafal Manka</title>
    <description>The latest articles on DEV Community by Rafal Manka (@rafalmanka).</description>
    <link>https://dev.to/rafalmanka</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4051873%2F1b6580b0-5bb2-4b29-8ca1-93b006a79bad.jpg</url>
      <title>DEV Community: Rafal Manka</title>
      <link>https://dev.to/rafalmanka</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rafalmanka"/>
    <language>en</language>
    <item>
      <title>Multi-tenant application: organization-scoped routes in Axum</title>
      <dc:creator>Rafal Manka</dc:creator>
      <pubDate>Wed, 28 Oct 2026 04:02:32 +0000</pubDate>
      <link>https://dev.to/rafalmanka/multi-tenant-application-organization-scoped-routes-in-axum-f9g</link>
      <guid>https://dev.to/rafalmanka/multi-tenant-application-organization-scoped-routes-in-axum-f9g</guid>
      <description>&lt;h2&gt;
  
  
  Multi-tenant application: organization-scoped routes in Axum
&lt;/h2&gt;

&lt;p&gt;Multi-tenancy sounds like a simple idea - reuse the same application across multiple organizations. Usually, you put the organization identifier somewhere in the URL, like a subdomain or a path parameter. You quickly realize that making sure that identifier is carried through and validated with every request is not as easy as it sounds. You have requests, queries, redirects, webhooks, forms, emails, and all kinds of checks that must never cross tenant boundaries.&lt;/p&gt;

&lt;p&gt;Those kinds of problems I have been wrestling with recently through Featherboard, which is a self-hosted customer feedback management board written in Rust with Axum, Askama, HTMX, and SQLite.&lt;/p&gt;

&lt;h2&gt;
  
  
  Organization slug is the first parameter of every route
&lt;/h2&gt;

&lt;p&gt;Featherboard constructs the path in the following way:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/{org-slug}/ideas
/{org-slug}/roadmap
/{org-slug}/settings/site
/{org-slug}/settings/user
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The organization identifier is located in the &lt;code&gt;/{org-slug}&lt;/code&gt; parameter. All routing is therefore evaluated in the context of that parameter.&lt;/p&gt;

&lt;p&gt;This gives the tenant an explicit boundary, and every request is scoped to a specific organization, so instead of asking for &lt;code&gt;/ideas/43&lt;/code&gt;, it is asking for idea 43 inside a particular organization.&lt;/p&gt;

&lt;p&gt;This distinction is useful even if IDs are unique across the entire system, because unique integer IDs do not protect against cross-referencing resources.&lt;/p&gt;

&lt;h2&gt;
  
  
  Central place to extract organization info
&lt;/h2&gt;

&lt;p&gt;Instead of extracting the organization from the slug in every request, Featherboard implemented a &lt;code&gt;CurrentOrg&lt;/code&gt; request extractor. It takes the path, extracts the first parameter, looks up the organization in the database, and provides the organization struct to the request handler.&lt;/p&gt;

&lt;p&gt;This method allows every handler to take &lt;code&gt;CurrentOrg&lt;/code&gt; as a parameter, like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;some_handler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;current_org&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;CurrentOrg&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;Result&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;AppError&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;org_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;current_org&lt;/span&gt;&lt;span class="py"&gt;.id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="c1"&gt;// Rest of the function&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This way, routing logic remains consistent across all endpoints, while invalid organization slugs are rejected with a 404 Not Found response.&lt;/p&gt;

&lt;h2&gt;
  
  
  Enforced organization scope
&lt;/h2&gt;

&lt;p&gt;Organization scope is enforced in the resource query, not just through a route lookup. Let's look at a concrete example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;ideas&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;org_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The same rule applies to write operations:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;UPDATE&lt;/span&gt; &lt;span class="n"&gt;ideas&lt;/span&gt;
&lt;span class="k"&gt;SET&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;org_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It would be more obvious to write the handler with just a simple &lt;code&gt;WHERE id = ?&lt;/code&gt;, especially since the URL slug was validated in the &lt;code&gt;CurrentOrg&lt;/code&gt; extractor, but that kind of validation is not enough. The SQL query must enforce that the record belongs to the same tenant.&lt;/p&gt;

&lt;p&gt;The same thing applies to authorization. The admin check needs to include a SQL query to verify that the &lt;code&gt;user_id&lt;/code&gt; and &lt;code&gt;org_id&lt;/code&gt; match. If a user is an admin within one organization, it should not give them admin rights to all organizations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Organization boundary was the most obvious in settings
&lt;/h2&gt;

&lt;p&gt;We have two separate settings categories in Featherboard:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/{org-slug}/settings/site
/{org-slug}/settings/user
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Site settings are only accessible by admins and contain settings affecting the entire organization, like configuration keys, billing information, branding, and such. User settings, on the other hand, contain information regarding an individual user, such as notification preferences, and should be accessible by regular users as well.&lt;/p&gt;

&lt;p&gt;Both admins and regular users exist within one organization scope, but they have different authorization rules. Because of this routing structure, access to those settings is clearly scoped, and the handlers do not need to accept unrelated requests.&lt;/p&gt;

&lt;p&gt;The same routing is implemented for form actions and redirects. If we blindly accept &lt;code&gt;/settings/user/notification&lt;/code&gt; without the organization prefix, there is a real risk that settings would be saved for a user that belongs to a different organization. The same applies to redirects because navigating to &lt;code&gt;/settings/site&lt;/code&gt; would land you in a different organization entirely.&lt;/p&gt;

&lt;h2&gt;
  
  
  Things that are less obvious
&lt;/h2&gt;

&lt;p&gt;Routing is only one part of the system. To ensure multi-tenant support, the organization prefix had to be implemented in many places across the entire system, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;HTML links&lt;/li&gt;
&lt;li&gt;Form actions&lt;/li&gt;
&lt;li&gt;Redirects&lt;/li&gt;
&lt;li&gt;Email links&lt;/li&gt;
&lt;li&gt;Stripe checkout&lt;/li&gt;
&lt;li&gt;Webhooks&lt;/li&gt;
&lt;li&gt;Tests and assertions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All of the above are quite fragile, because the compiler will not help you validate them. Rendering a website with invalid links still produces valid HTML, so writing proper unit tests and integration tests is absolutely essential.&lt;/p&gt;

&lt;h2&gt;
  
  
  Unit tests and integration tests
&lt;/h2&gt;

&lt;p&gt;In order to ensure the stability of Featherboard, we need to verify that:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;An existing &lt;code&gt;org-slug&lt;/code&gt; reaches the correct handler.&lt;/li&gt;
&lt;li&gt;Users can only access and modify their own settings.&lt;/li&gt;
&lt;li&gt;A malicious request cannot modify settings that belong to another organization.&lt;/li&gt;
&lt;li&gt;Redirects preserve the organization path.&lt;/li&gt;
&lt;li&gt;Links and forms reference URLs that belong to the same organization.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In Featherboard, besides unit tests located in the same module as the code, there are tests that verify the correct behavior of a real Axum router using test dependencies such as a SQLite database and a session store. Those kinds of tests catch different classes of bugs that a typical unit test would not catch, such as route nesting, session cookie handling, extractors, database migrations, writes, and state changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  The tradeoffs
&lt;/h2&gt;

&lt;p&gt;Path-based tenancy routing is not the only design choice. Another valid option is a subdomain model, e.g. &lt;code&gt;acme.example.com&lt;/code&gt;. You could also resolve tenancy through a session token or use some other creative way to differentiate between organizations.&lt;/p&gt;

&lt;p&gt;For Featherboard, I chose the path-based model because it makes hosting very simple and does not require wildcard DNS or complicated reverse proxy configuration. The downside is that every URL has to include the &lt;code&gt;org-slug&lt;/code&gt; prefix.&lt;/p&gt;

&lt;p&gt;The main takeaway from this is that once the organization identifier is in the path, it also needs to be part of the handler context, database design, authorization checks, validations, redirects, HTML templating, and so on.&lt;/p&gt;

</description>
      <category>rust</category>
      <category>axum</category>
      <category>opensource</category>
      <category>selfhosted</category>
    </item>
    <item>
      <title>Setting up billing and subscriptions with Stripe</title>
      <dc:creator>Rafal Manka</dc:creator>
      <pubDate>Tue, 06 Oct 2026 12:34:17 +0000</pubDate>
      <link>https://dev.to/rafalmanka/setting-up-billing-and-subscriptions-with-stripe-541</link>
      <guid>https://dev.to/rafalmanka/setting-up-billing-and-subscriptions-with-stripe-541</guid>
      <description>&lt;p&gt;The core idea behind Featherboard is to keep the core functionality accessible without a paid plan. You can run the app on your own hardware for free, while the hosted version offers the convenience of having it managed for you for a small fee.&lt;/p&gt;

&lt;p&gt;So I've started implementing billing with Stripe. It's still in the early stages of development, but I've already discovered that getting a simple Checkout flow working is easy while making sure the local subscription state stays in sync with Stripe is the part that's actually challenging.&lt;/p&gt;

&lt;h3&gt;
  
  
  Starting a Checkout Session
&lt;/h3&gt;

&lt;p&gt;What's currently built is a simple endpoint that starts a Stripe Checkout Session and is only visible to Admin accounts. It uses a Price ID from an environment variable and authenticates with a secret key from another one. Those values should never be in the source code. Stripe takes care of the rest: collecting and handling the payment details.&lt;/p&gt;

&lt;p&gt;That said, when you're dealing with a multi-tenant application, it's important to handle Stripe callbacks correctly so subscription changes are associated with the right organisations. To achieve that, each Checkout request includes Featherboard's organization ID in the new subscription's metadata, which the webhook reads to associate the subscription with the right organisation.&lt;/p&gt;

&lt;h3&gt;
  
  
  Syncing with Stripe through webhooks
&lt;/h3&gt;

&lt;p&gt;Getting a redirect from Stripe Checkout is not evidence of a successful payment. There are a lot of things that could go wrong, the user could cancel the payment, the card could be rejected, and so on. That's why I'm using a server-to-server webhook to reliably sync subscription changes.&lt;/p&gt;

&lt;p&gt;After receiving a webhook event, the app gets a signature in request header. It uses that signature to check that the raw request body wasn't tampered with. The signature is an HMAC-SHA256 over the timestamp and JSON body. The timestamp is scoped to a five-minute window, so old requests are rejected.&lt;/p&gt;

&lt;p&gt;After this basic verification passes, we process subscription events such as &lt;code&gt;created&lt;/code&gt;, &lt;code&gt;updated&lt;/code&gt; and &lt;code&gt;deleted&lt;/code&gt;. We map the webhook body to a corresponding event structure and save its status in our SQLite database. We're using upsert SQL syntax to elegantly handle new and existing subscription records.&lt;/p&gt;

&lt;p&gt;This is a critical flow, so I added tests for valid and invalid signatures, malformed headers, expired timestamps, and database upserts.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pending work
&lt;/h3&gt;

&lt;p&gt;The current Checkout flow is not ready to be merged yet. The webhook endpoint and subscription handling are in place, but the UI flow is still missing: there is no admin action to start Checkout. It's still possible to create multiple Stripe subscriptions for the same organisation, while our database only tracks one subscription per organisation. Each subscription could lead to charges, so those edge cases need to be handled before going into production.&lt;/p&gt;

&lt;p&gt;The return URL also lands in the same place whether the payment succeeded or failed. On top of that, the app needs a pending state and must not rely on the redirect to tell us what happened.&lt;/p&gt;

&lt;p&gt;There are some other gaps as well: handling paid and failed invoices, duplicate or out-of-order webhook events, and a self-service subscription management flow. Those are all on the list before we can consider billing done.&lt;/p&gt;

&lt;p&gt;I have to admit that I underestimated the effort required to implement payments. It's not just an API call. Actually, it's a full-blown state machine with a lot of edge cases and security checks at every step.&lt;/p&gt;

&lt;p&gt;As always, here's the codebase if you'd like to follow along: &lt;a href="https://github.com/RafalManka/Featherboard" rel="noopener noreferrer"&gt;https://github.com/RafalManka/Featherboard&lt;/a&gt;&lt;/p&gt;

</description>
      <category>rust</category>
      <category>axum</category>
      <category>opensource</category>
      <category>showdev</category>
    </item>
    <item>
      <title>Featherboard's email notifications via SMTP and lettre: a security gap, and a lesson from Rust's borrow checker</title>
      <dc:creator>Rafal Manka</dc:creator>
      <pubDate>Tue, 15 Sep 2026 03:05:53 +0000</pubDate>
      <link>https://dev.to/rafalmanka/featherboards-email-notifications-via-smtp-and-lettre-a-security-gap-and-a-lesson-from-rusts-221p</link>
      <guid>https://dev.to/rafalmanka/featherboards-email-notifications-via-smtp-and-lettre-a-security-gap-and-a-lesson-from-rusts-221p</guid>
      <description>&lt;p&gt;The next phase of development is done and since the last update, admins can now delete ideas as well as merge duplicate ideas into one. The phase I'm currently working on is email notifications. The first part sounds simple: an admin gets an email when someone comments on an idea. Simple enough, but once I actually dove into the implementation, it turned out to be more involved than it sounds.&lt;/p&gt;

&lt;h2&gt;
  
  
  Emails are optional by design
&lt;/h2&gt;

&lt;p&gt;The core design principle of Featherboard is that it should be simple and work out of the box without configuration. So the app needs to run perfectly fine even if no SMTP client has been configured. &lt;code&gt;EmailClient&lt;/code&gt; loads its configuration on startup from environment variables. If those environment variables aren't set, the email client is &lt;code&gt;None&lt;/code&gt;, and no emails are ever sent. The rest of the app just checks whether &lt;code&gt;EmailClient&lt;/code&gt; is &lt;code&gt;None&lt;/code&gt;. That part was quite straightforward.&lt;/p&gt;

&lt;h2&gt;
  
  
  A comment insert that never checked its own org
&lt;/h2&gt;

&lt;p&gt;Featherboard is multi-tenant, so every URL is &lt;code&gt;/{org-slug}/...&lt;/code&gt;, and a &lt;code&gt;CurrentOrg&lt;/code&gt; extractor resolves that slug into an org id on every request. Writing the notification meant fetching the idea's title to put in the email, and doing that fetch is what exposed a bug that had nothing to do with email: &lt;code&gt;create_comment&lt;/code&gt; was inserting a comment for whatever idea id showed up in the URL, without ever checking it belonged to the org in that URL. A crafted request with right org in the path, someone else's idea id in the body would have quietly attached a comment to a different org's idea.&lt;/p&gt;

&lt;p&gt;The fix was simple: check that the idea being commented on actually belongs to the org in the URL via &lt;code&gt;SELECT EXISTS(...)&lt;/code&gt; — and return a 403 if it doesn't, before any write happens.&lt;/p&gt;

&lt;h2&gt;
  
  
  Resolving the commenter's name
&lt;/h2&gt;

&lt;p&gt;Logging in to Featherboard is optional and you can post a comment as a guest or while logged in, and either way you type a name into the comment form. For the notification email specifically, I didn't want it to just repeat whatever was typed into that field: I resolve the commenter's name from the session first, and only fall back to the guest-typed name when nobody's logged in. Right now that's only how the &lt;em&gt;email&lt;/em&gt; picks a name and the comment that actually gets stored and displayed on the page still always uses the typed field, logged in or not. I still need to add that implementation later, so a logged-in user's displayed comment and their notification email can currently show different names for the same comment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Emails use absolute URLs
&lt;/h2&gt;

&lt;p&gt;So far, everything in the app redirected to pages via a relative path, e.g. &lt;code&gt;/acme/ideas/10&lt;/code&gt;. But when sending emails to someone's inbox, a relative path means nothing. There's no page open to resolve it against. I needed to construct a fully qualified URL instead, e.g. &lt;code&gt;https://featherboard.net/acme/ideas/10&lt;/code&gt;. That's why I added another env var, &lt;code&gt;PUBLIC_URL&lt;/code&gt;, and used it to build the final URL that goes in the email.&lt;/p&gt;

&lt;h2&gt;
  
  
  The borrow checker won't let you return something that was just deallocated
&lt;/h2&gt;

&lt;p&gt;This one is a little curious, but it captures perfectly how Rust's ownership model works. Here's my first attempt at writing code to avoid a double slash after the domain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nf"&gt;Some&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;public_url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nn"&gt;env&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"PUBLIC_URL"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="nf"&gt;.ok&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="nf"&gt;.map&lt;/span&gt;&lt;span class="p"&gt;(|&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="nf"&gt;.trim_end_matches&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sc"&gt;'/'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;None&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code doesn't compile, because it returns a &lt;code&gt;&amp;amp;str&lt;/code&gt; pointing into a &lt;code&gt;String&lt;/code&gt; that's about to be deallocated. The &lt;code&gt;String&lt;/code&gt; (&lt;code&gt;e&lt;/code&gt;) only exists for the duration of the closure, once &lt;code&gt;.map()&lt;/code&gt; returns, it's dropped. Returning a &lt;code&gt;&amp;amp;str&lt;/code&gt; into it would be a pointer into freed memory, and Rust's borrow checker refuses to let that happen.&lt;/p&gt;

&lt;p&gt;Coming from a garbage-collected language, this is genuinely surprising the first few times. In Kotlin, for example, a function like that just returns a new string, and the original stays alive for as long as something references it. That's the garbage collector's problem, not the programmer's. Rust has no collector standing behind it, so it enforces the lifetime at compile time instead of leaving it to chance at runtime.&lt;/p&gt;

&lt;h2&gt;
  
  
  Grouping templates by destination
&lt;/h2&gt;

&lt;p&gt;As Featherboard's codebase grows, I added email HTML templates alongside the usual htmx templates, and they all need to live together in one project. Instead of dumping everything into one folder, I split templates into three: &lt;code&gt;pages/&lt;/code&gt; for full pages, &lt;code&gt;htmx/&lt;/code&gt; for partial/swap content, and &lt;code&gt;emails/&lt;/code&gt; for notification emails.&lt;/p&gt;

&lt;p&gt;Thank you for following along and as always, here's the codebase: &lt;a href="https://github.com/RafalManka/Featherboard" rel="noopener noreferrer"&gt;https://github.com/RafalManka/Featherboard&lt;/a&gt;&lt;/p&gt;

</description>
      <category>rust</category>
      <category>axum</category>
      <category>opensource</category>
      <category>showdev</category>
    </item>
    <item>
      <title>Turning Featherboard into a multi-tenant application: GitHub OAuth and path-based routing</title>
      <dc:creator>Rafal Manka</dc:creator>
      <pubDate>Tue, 01 Sep 2026 17:56:14 +0000</pubDate>
      <link>https://dev.to/rafalmanka/turning-featherboard-into-a-multi-tenant-application-github-oauth-and-path-based-routing-48m4</link>
      <guid>https://dev.to/rafalmanka/turning-featherboard-into-a-multi-tenant-application-github-oauth-and-path-based-routing-48m4</guid>
      <description>&lt;p&gt;The next phase of development is done. At this stage, Featherboard starts to become something you can actually go ahead and host on your own server, one that can support multiple teams and multiple products. User authentication so far is implemented via GitHub OAuth login, but in future phases other providers will be added, as well as regular email login. At this point I've removed the temporary hardcoded token authentication. Also, multi-tenant routing is implemented via the &lt;code&gt;app.featherboard.net/{slug}/...&lt;/code&gt; path, where &lt;code&gt;slug&lt;/code&gt; is the name of the organization. This part of the implementation required the most debugging on my side, because all links had to be modified and the slug had to be added dynamically to all paths. Fortunately, Axum provides an extractor that allows intercepting requests and extracting organization data from the path very elegantly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Goodbye to the shared-token hack
&lt;/h2&gt;

&lt;p&gt;So far, as a placeholder, the &lt;code&gt;admin&lt;/code&gt; role was granted when a request contained a header with a token that was hardcoded and stored in an environment variable, &lt;code&gt;FEATHERBOARD_ADMIN_TOKEN&lt;/code&gt;. Naturally, this is not a sustainable solution and had to be replaced by actual authentication logic. This was replaced by a &lt;code&gt;users&lt;/code&gt; table, GitHub OAuth login, and an &lt;code&gt;is_admin&lt;/code&gt; flag on the users table. Even though that implementation sounds simple, getting there wasn't as straightforward as I would have liked.&lt;/p&gt;

&lt;h2&gt;
  
  
  Single binary with embedded static files
&lt;/h2&gt;

&lt;p&gt;In Featherboard I embed all the static files I use throughout the project, so that everything is contained within a single binary file. That includes sqlx migration files as well as HTML templates. The main reason for that decision was that I wanted the hoster not to have to worry about whether they have all the dependencies in the right relative folders. One notable particularity of sqlx migrations is that they are addition-only - if you want to change something in the schema you need to create an additional migration file, because otherwise the migration will be rejected and the app will crash on startup.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting &lt;code&gt;UNIQUE&lt;/code&gt; indexes right
&lt;/h2&gt;

&lt;p&gt;I added a &lt;code&gt;UNIQUE&lt;/code&gt; index on the GitHub account so the user does not register twice. This makes total sense - until you realize that it also prevents a user from creating an account in multiple organizations: if you log in to product A, you won't be able to log in to product B. I realized this during a debugging session, and I was right to try creating an account in another organization - the login failed immediately, as expected. That's not what we wanted, so instead I had to create a compound index on GitHub user id and organization slug.&lt;/p&gt;

&lt;h2&gt;
  
  
  GitHub does not guarantee to give you an email
&lt;/h2&gt;

&lt;p&gt;In order to create an account within Featherboard, you need an email and an OAuth token. But GitHub allows you to make your email address private, so you need to fall back on the &lt;code&gt;/user/emails&lt;/code&gt; endpoint to retrieve the email address if it isn't provided in the original request. The &lt;code&gt;/user/emails&lt;/code&gt; endpoint returns a list of emails, and I had to get the primary one from the list. This wasn't really documented properly in GitHub's documentation, and I had to figure it out during debugging as well.&lt;/p&gt;

&lt;h2&gt;
  
  
  Token upsert as a single operation
&lt;/h2&gt;

&lt;p&gt;GitHub login needs to update the users table, specifically the &lt;code&gt;provider&lt;/code&gt; and &lt;code&gt;provider_user_id&lt;/code&gt; columns; next, it needs to decide whether to create a new entry or update an existing one based on what's already there. Fortunately, SQLite supports exactly the tool I need for this, specifically the syntax: &lt;code&gt;INSERT ... ON CONFLICT (provider, provider_user_id) DO UPDATE ... RETURNING id;&lt;/code&gt; - a single statement that creates or updates a record and returns its id. I could have just used a &lt;code&gt;SELECT&lt;/code&gt; to check if a record already exists, and then &lt;code&gt;INSERT&lt;/code&gt; or &lt;code&gt;UPDATE&lt;/code&gt; respectively, but that wouldn't be as elegant as this single statement.&lt;/p&gt;

&lt;h2&gt;
  
  
  Multi-tenant routing: the &lt;code&gt;{org-slug}&lt;/code&gt; quagmire
&lt;/h2&gt;

&lt;p&gt;Routing was complex and required a lot of changes, because the root of every URL changes in a way that requires me to dynamically inject a path parameter, and also extract that path parameter for every request. Fortunately, Rust's Axum supports extractors, which allowed me to write a simple &lt;code&gt;impl&lt;/code&gt; for an extractor that parses the path and creates a &lt;code&gt;CurrentOrg&lt;/code&gt; struct from it. Then, in each function handler, I just add that parameter to the handler signature for the extractor to work automatically. It was a very clean and pleasant experience.&lt;/p&gt;

&lt;p&gt;None of the bugs I experienced were unusual, and it was quite easy to figure out what I was doing wrong. But even with such a simple-sounding implementation, the amount of work I had to put in was surprisingly large, and at each of those steps I could easily have shot myself in the foot.&lt;/p&gt;

&lt;p&gt;Here's the code if you're interested, ready to grab or follow along: &lt;a href="https://github.com/RafalManka/Featherboard" rel="noopener noreferrer"&gt;https://github.com/RafalManka/Featherboard&lt;/a&gt;&lt;/p&gt;

</description>
      <category>rust</category>
      <category>axum</category>
      <category>opensource</category>
      <category>showdev</category>
    </item>
    <item>
      <title>Why Featherboard is AGPL-3.0, single, self-contained binary</title>
      <dc:creator>Rafal Manka</dc:creator>
      <pubDate>Tue, 28 Jul 2026 18:11:15 +0000</pubDate>
      <link>https://dev.to/rafalmanka/why-featherboard-is-agpl-30-single-self-contained-binary-3cmh</link>
      <guid>https://dev.to/rafalmanka/why-featherboard-is-agpl-30-single-self-contained-binary-3cmh</guid>
      <description>&lt;p&gt;Phase 1 is now complete. The submit -&amp;gt; vote -&amp;gt; comment -&amp;gt; status-tag -&amp;gt; filter path is done. Before moving to Phase 2, I'd like to reflect on a big fundamental decision I've made and the reasoning behind it. I never really contemplated what the real-world consequences of choosing the right license are, but now I get it.&lt;/p&gt;

&lt;p&gt;Why I chose AGPL-3.0 and not MIT or Apache-2.0. The business model is open-core: anyone can host a copy of the app and run it on their own infrastructure. But if you don't want to run it yourself, you can always pay me to do it. Everyone wins.&lt;/p&gt;

&lt;p&gt;If I'd chosen MIT or Apache 2.0, anyone could just fork my repository, run it as a hosted SaaS with their own extensions on top, and never have to share their changes with anyone. Not even plain GPL closes this gap, since its copyleft only kicks in when you &lt;em&gt;distribute&lt;/em&gt; the software, and running a modified version as a web service isn't distribution. That is what they call the "SaaS loophole" and it's the reason why the AGPL license was created.&lt;/p&gt;

&lt;p&gt;Why a single, self-contained binary? Because the target audience is someone who wants this to work fast with minimal setup and little infrastructure - not someone who wants to run their own Postgres database, Docker infrastructure, and expensive AWS hosting solutions, then resolve a whole bunch of dependencies just to load the page after hours of struggling. I chose SQLite and &lt;code&gt;rust-embed&lt;/code&gt; for static assets and Askama baked-in templates. That allowed me to package the entire web server into one 6.8MB executable file.&lt;/p&gt;

&lt;p&gt;Additionally, htmx is bundled with the binary so no CDN dependency is needed - one less thing to worry about, and you don't even need internet access. Self-hosting is supposed to be all about removing external dependencies, so &lt;code&gt;htmx.min.js&lt;/code&gt; is baked into the binary and VENDOR.md is attached to respect licensing requirements.&lt;/p&gt;

&lt;p&gt;The effect? All my decisions point in the same direction - minimize hassle for the hoster and make the install as easy as possible.&lt;/p&gt;

&lt;p&gt;Code's here if you want to follow along or try it yourself ;-)  &lt;a href="https://github.com/RafalManka/Featherboard" rel="noopener noreferrer"&gt;https://github.com/RafalManka/Featherboard&lt;/a&gt;   &lt;/p&gt;

</description>
      <category>opensource</category>
      <category>rust</category>
      <category>showdev</category>
      <category>selfhosted</category>
    </item>
  </channel>
</rss>
