---
title: "Building safe-by-default tools in our Go web application"
description: "incident.io keeps tenant data isolated in a single shared database and application by making its Go code safe by default rather than relying on tests alone."
url: "https://swe.quest/articles/building-safe-by-default-tools-in-our-go-web-application-a15579ba1759fc5c"
canonical: "https://incident.io/blog/safe-by-default"
source: "incident.io"
published: "2021-11-22"
difficulty: "medium"
kind: "Case study"
reading_minutes: 6
tags: ["multi-tenancy","go","appsec","databases","caching"]
---

# Building safe-by-default tools in our Go web application

A post on [incident.io](https://swe.quest/sources/incident-io.md), published 2021-11-22, 6 min read, Case study. Original: [https://incident.io/blog/safe-by-default](https://incident.io/blog/safe-by-default)

## Summary

incident.io keeps tenant data isolated in a single shared database and application by making its Go code safe by default rather than relying on tests alone. An API middleware uses reflection to reject any response whose resources lack an OrganisationID or belong to a different organization. A gorm query hook fails any query or update without an organisation\_id WHERE clause unless explicitly skipped. A cache interface requires an organization argument and confines unscoped access to explicit ...Global methods. The common principle is that dangerous unscoped access must be an explicit opt-in, applied at several layers because Slack traffic bypasses the API check.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Multi-tenancy](https://swe.quest/tags/multi-tenancy.md) (Architecture & design)
- [Go](https://swe.quest/tags/go.md) (Languages)
- [Application security](https://swe.quest/tags/appsec.md) (Security)
- [Databases](https://swe.quest/tags/databases.md) (Data & databases)
- [Caching](https://swe.quest/tags/caching.md) (Backend & APIs)

## Prerequisites

- Go reflection basics ([easy posts on Go](https://swe.quest/tags/go.md?difficulty=easy))
- ORM query hooks
- multi-tenant architecture ([easy posts on System design](https://swe.quest/tags/system-design.md?difficulty=easy))

## Keywords

incident.io, gorm, CheckOrganisationScope, Slack

## Related posts

- [Staying Evergreen: How we automated secure access and repo hygiene in a shared org](https://swe.quest/articles/staying-evergreen-how-we-automated-secure-access-and-repo-hygiene-in-a-shared-b76aa86640c047a2.md): GitHub Engineering · 2026-10-15 · Medium · 8 min read · Identity & auth, Developer tools, Security, System design
  Evergreen is a Go-based GitHub App that automates quarterly outside-collaborator access reviews and stale-repo archival in a shared org of 1,400+ GitHub employees, customers and partners, built entirely from native primitives: scheduled Actions firing repository\_dispatch, webhooks, issue checklists, custom properties, and per-repo JSON state files in git that double as the audit trail.
- [Rolling out Roles](https://swe.quest/articles/rolling-out-roles-feb5c6f49f33b701.md): incident.io · 2022-03-11 · Medium · 6 min read · Identity & auth, Deployment, Product engineering, Go, TypeScript
  incident.io added role-based access control by mapping a fixed set of customer-facing roles (owner, admin, etc.) to granular internal scopes.
- [Better security for your app's secrets](https://swe.quest/articles/better-security-for-your-app-s-secrets-1add70314c176532.md): incident.io · 2023-07-10 · Medium · 9 min read · Security, Cloud platforms, Configuration management, Identity & auth, Go
  incident.io's Go app loads config from per-environment YAML files, overrides values with environment variables, then resolves \`secret-manager:\` references from Google Secret Manager at boot.
- [How we built enterprise search to be secure and private](https://swe.quest/articles/how-we-built-enterprise-search-to-be-secure-and-private-9bbeb6f1e852b588.md): Slack Engineering · 2025-03-07 · Easy · 5 min read · Search, Identity & auth, RAG & retrieval, Privacy, Security
  Slack's enterprise search, which brings Google Drive and GitHub results into Slack search and AI Answers, uses a federated, real-time design instead of an index.
- [A new security baseline for enterprise agentic adoption](https://swe.quest/articles/a-new-security-baseline-for-enterprise-agentic-adoption-e01702f9b0769350.md): Docker · 2026-08-12 · Easy · 5 min read · AI agents, Security, Identity & auth, Sandboxing & isolation
  Agent Baseline, an open v1.0 draft from Docker, Snyk and Keycard, defines 35 controls across six security outcomes for enterprise AI agents: Discover, Constrain, Authorize, Observe, Validate and Respond.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
