---
title: "How Render Enforces Access Controls with Go Generics"
description: "Render enforces role-based access control at compile time by wrapping domain objects like Project in opaque types (AuthorizedProject) that can only be constructed through a permission-checking function."
url: "https://swe.quest/articles/how-render-enforces-access-controls-with-go-generics-6a60bf3827f53ed7"
canonical: "https://render.com/blog/how-render-enforces-access-controls-with-go-generics"
source: "Render"
published: "2024-04-16"
difficulty: "medium"
kind: "Case study"
reading_minutes: 6
tags: ["go","identity-auth","type-systems","appsec"]
---

# How Render Enforces Access Controls with Go Generics

A post on [Render](https://swe.quest/sources/render.md), published 2024-04-16, 6 min read, Case study. Original: [https://render.com/blog/how-render-enforces-access-controls-with-go-generics](https://render.com/blog/how-render-enforces-access-controls-with-go-generics)

## Summary

Render enforces role-based access control at compile time by wrapping domain objects like Project in opaque types (AuthorizedProject) that can only be constructed through a permission-checking function. This guarantees model-layer code never runs without an authorization check. Go generics go further: each permission is a distinct type parameter, so passing an object authorized for "update" into a "delete" method is a type error, though tooling gaps around generics have kept that final step from being merged. Rare bootstrapping cases use an explicitly named UnsafeAuthorize() that gets extra review. The tradeoff is more code per new permission, but the compiler yields a complete list of codepaths to update, which caught real security holes before launch.

Written by swe.quest, not by the author.

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

## Topics

- [Go](https://swe.quest/tags/go.md) (Languages)
- [Identity & auth](https://swe.quest/tags/identity-auth.md) (Security)
- [Type systems](https://swe.quest/tags/type-systems.md) (Compilers & runtimes)
- [Application security](https://swe.quest/tags/appsec.md) (Security)

## Prerequisites

- Go generics ([easy posts on Go](https://swe.quest/tags/go.md?difficulty=easy))
- Go package visibility rules ([easy posts on Go](https://swe.quest/tags/go.md?difficulty=easy))
- RBAC basics

## Keywords

Go generics, RBAC, opaque type pattern, Render

## Related posts

- [Making code-generation in Go more powerful with generics](https://swe.quest/articles/making-code-generation-in-go-more-powerful-with-generics-5b72d91ebe8db40c.md): incident.io · 2022-10-20 · Medium · 10 min read · Go, Type systems, Testing, Developer productivity
  Combining Go generics with code generation gives type-safe partial structs: a generic Partial\[T\] tracks which fields are set alongside a subject value, enabling safe partial updates through a Gorm wrapper that avoids zero-value overwrites and race conditions.
- [Modelling Authorization for a Social Network with Postgres RLS and Drizzle ORM](https://swe.quest/articles/modelling-authorization-for-a-social-network-with-postgres-rls-and-drizzle-orm-6267eb437b8171e7.md): Neon · 2024-11-11 · Medium · 8 min read · PostgreSQL, Identity & auth, TypeScript, System design
  Postgres Row-Level Security can express the full authorization model for a Twitter-like social network, defined with Drizzle ORM's crudPolicy and pgPolicy helpers and the pg\_session\_jwt extension's auth.user\_id().
- [How we built a custom permissions DSL at Figma](https://swe.quest/articles/how-we-built-a-custom-permissions-dsl-at-figma-b86982742becc83a.md): Figma · 2024-03-13 · Medium · 24 min read · Identity & auth, Language design, System design, Ruby, TypeScript
  Figma replaced a sprawling Ruby \`has\_access?\` permissions function with a custom, JSON-serializable permissions DSL and a cross-platform policy engine, inspired by AWS IAM policies.
- [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.
- [Higher-level CRUD Abstraction for Postgres RLS](https://swe.quest/articles/higher-level-crud-abstraction-for-postgres-rls-90207e4bb081ead2.md): Neon · 2024-11-13 · Medium · 3 min read · PostgreSQL, Identity & auth, TypeScript
  Postgres Row-Level Security requires separate USING and WITH CHECK policies per operation, which gets repetitive for CRUD apps.

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)
