1. Introduction: When Roles Alone Are Not Enough
At DevRime, authorization starts like this.
@AuthorizedRole(roles = { ScrumRoles.ROLE_PROJECT_MANAGER,
ScrumRoles.ROLE_PROJECT_MEMBER })
public class FindProductProjFetch extends FetchRequest<ProductRdo> {
"Only project managers and project members can call this API." It is clear, easy to read, and sufficient in most cases. We use this approach throughout DevRime.
But at some point, a requirement like this comes in: "Scrum masters should only be able to modify the epics of the products they are responsible for."
This is where the problem begins. ROLE_SCRUM_MASTERallows us to answer the question, "Is this person a scrum master?" But "of which product" they are the scrum master of cannot be captured by a role. A role is a label attached to a person, while what we want to know is the relationship between a person and a specific resource.
Of course, we can force a solution. SCRUM_MASTER_PRODUCT_A, SCRUM_MASTER_PRODUCT_B We could create roles like these for each product, or check this every time in the code.
ScrumTeam team = scrumTeamLogic.findByProductId(productId);
if (!team.getScrumMaster().getCitizenId().equals(currentCitizenId)) {
throw new SecurityException("권한이 없습니다");
}
The former makes management impossible because the number of roles increases with every new product, while the latter scatters authorization logic throughout the service code. Once similar code starts being copied for epics, releases, and backlogs, it becomes impossible to see at a glance who can modify a given resource.
This article introduces ReBAC and SpiceDB, which we adopted to solve this problem, and summarizes how we actually use them in DevRime Scrum.
2. RBAC · ABAC · ReBAC: Three Approaches
Authorization models can be broadly divided into three categories. Their names are similar, but they differ in what they use as the basis for decisions.
RBAC 사람 ──▶ 역할 ──▶ 권한
ABAC (사람 속성 + 자원 속성 + 환경) ──▶ 규칙 평가 ──▶ 허용 / 거부
ReBAC 사람 ──관계──▶ 자원 ──관계──▶ 자원 ──▶ 허용 / 거부
RBAC (Role-Based Access Control) — Decisions Based on Roles
Users are assigned roles, and permissions are grouped into those roles. This is the oldest and most widely used approach. For example, "Hong Gil-dong → project.manager → can change project settings."
The advantage is simplicity. Because the organizational chart directly becomes the permission structure, it is also easy to explain to non-developers. No matter how much the number of users grows, the number of roles stays the same, so management costs remain consistent.
The limitation is distinguishing between resources. It can answer "Is this person an administrator?" but not "Is this person the administrator of this document?" To express this forcibly, the number of roles must increase with the number of resources, which is called role explosion.
ABAC (Attribute-Based Access Control) — Decisions Based on Attributes
Rules are evaluated by combining the attributes of the user, resource, and environment. For example: "User's department == document's department AND current time is within business hours → allow."
The advantage is expressiveness. Fine-grained conditions can be translated directly into rules.
The limitation is predictability. As rules accumulate, it becomes difficult to trace "Why was this person able to access it?" Rules can also conflict with one another, and because the result varies depending on attribute values at the time of evaluation, reproducing the decision can be challenging.
ReBAC (Relationship-Based Access Control) — Decisions Based on Relationships
The relationships between users and resources are stored, and decisions are made by traversing those relationships.
홍길동 ──editor──▶ 프로덕트 A
에픽 #12 ──parent──▶ 프로덕트 A
⇒ 홍길동은 에픽 #12를 수정할 수 있다
The advantages are resource-level permissions and inheritance. Because we directly store "what relationship this person has with this resource," there is no role explosion. If parent-child relationships are established between resources, permissions naturally flow down. It works on the same principle as sharing a folder in Google Drive, which shares all the files inside it as well.
The limitation is the infrastructure burden. A separate store is needed to store relationships and traverse the graph, and the relationship data must be kept consistent with the source domain.
You do not have to choose just one of the three
The three are not mutually exclusive. In practice, using them in combination is natural. That is what we do as well, and we will show that combination later.
|
Category |
Basis for decision |
Best suited for |
Weaknesses |
|---|---|---|---|
|
RBAC |
Role |
Menu- and feature-level access |
Per-resource separation |
|
ABAC |
Attributes |
Policies with complex conditions |
Traceability and reproducibility |
|
ReBAC |
Relationships |
Resource-level permissions and inheritance |
Infrastructure and data consistency |
3. SpiceDB: A database for storing and querying relationships
To implement ReBAC directly, you need to create relationship tables and traverse the graph with recursive queries. Once relationships become just a few levels deep, the queries become unmanageable.
SpiceDBis an open-source authorization database that solves this problem for you. It is a product that implements the paper Zanzibarpublished by Google in 2019. Zanzibaris the system that actually handles permissions for Google Drive, YouTube, and Calendar. Its goal was to respond to millions of permission queries per second within milliseconds, and SpiceDBfollows that design.
Schema and relationships
SpiceDB contains two things. First, the schema— it defines which relationships exist and which permissions are derived from those relationships.
definition resource {
relation editor: actor | group#member
relation viewer: citizen
relation parent: resource
permission edit = editor + parent->edit
permission view = viewer
}
Here is how to read it. The editor relationship can be established with an individual (actor) or a group member. The edit permission is granted when the subject is an editor or has the edit permission on the parent resource (parent->edit), while the view permission is granted when there is a viewer relationship.
The key point here is the line parent->edit. This single line expresses the inheritance rule: "If you can edit the parent resource, you can also edit the child resource."
Then there is relationship data— the actual storage of who has what relationship with which resource. If the three lines below are stored, SpiceDB traverses the graph and answers the question, "Can Hong Gil-dong edit epic E12?"
resource:scrum_product-P1 editor group:scrum_product_sm-P1#member
group:scrum_product_sm-P1 member actor:홍길동
resource:scrum_epic-E12 parent resource:scrum_product-P1
질의: "actor:홍길동이 resource:scrum_epic-E12를 edit할 수 있나?"
epic E12 ──parent──▶ product P1 ──editor──▶ SM 그룹 ──member──▶ 홍길동
⇒ 허용
Where it fits in DevRime
We do not call SpiceDB directly from our services. The platform kernel's Guard service sits in front of SpiceDB, and each service queries Guard through the prologue library's GuardAuthorizer.
스크럼 서비스 ──▶ GuardAuthorizer ──▶ Guard ──gRPC──▶ SpiceDB
(도메인 코드) (prologue) (커널) (권한 저장소)
As a result, the Scrum code has no SpiceDB-related dependencies at all. Schema management and connection information are also centralized in Guard.
4. How do we use it in DevRime?
Scrum Master: Why add one layer of groups
When building a product, we do not attach people directly to the product; instead, we attach a group first.
// Product 생성 시 (최초 1회)
public void linkScrumMasterGroup(String productId) {
guardAuthorizer.add(Relationship.builder()
.resource(ProductRelationType.PRODUCT, productId)
.relation(RelationName.EDITOR)
.subject(SchemaType.GROUP,
ProductGroupType.SCRUM_MASTER.id(productId), "member")
.build());
}
"The editors of product P1 are scrum_product_sm-P1 group members." Then, when a Scrum team is created or the Scrum Master changes, we only add or remove group members.
public void addScrumMaster(String productId, String actorId) {
guardAuthorizer.add(Relationship.builder()
.resource(SchemaType.GROUP,
ProductGroupType.SCRUM_MASTER.id(productId))
.relation(RelationName.MEMBER)
.subject(SchemaType.ACTOR, actorId)
.build());
}
If we attached people directly to the product, we would have to update the relationships for each product, epic, and release every time the Scrum Master was replaced. With a group layer in between, a replacement is completed by changing a single member entry.
[사람을 직접 연결한 경우] 교체 시 관계 3줄을 전부 수정
홍길동 ──editor──▶ 프로덕트 P1
홍길동 ──editor──▶ 에픽 E12
홍길동 ──editor──▶ 릴리스 R3
[그룹을 한 겹 둔 경우] 교체 시 멤버 1줄만 수정
홍길동 ──member──▶ SM 그룹 ──editor──▶ 프로덕트 P1
▲ ▲
parent │ │ parent
에픽 E12 릴리스 R3
Using RBAC and ReBAC together
This is the most common pattern. Let’s look at the epic creation code.
public String registerEpic(EpicCdo epicCdo) {
if (!StageContext.get().getRoles()
.contains(ScrumRoles.ROLE_PROJECT_MANAGER)) {
boolean canEdit = productAuthorizer.canEdit(
ProductRelationType.PRODUCT, epicCdo.getProductId(),
StageContext.get().getActorKey().getId());
if (!canEdit) {
throw new SecurityException(NOT_ALLOWED);
}
}
...
parentAuthorizer.addParent(ProductRelationType.EPIC, epicId,
ProductRelationType.PRODUCT,
epicCdo.getProductId());
return epicId;
}
If the user is a project administrator, access is granted by role; otherwise, the relationship is checked. Project administrators are responsible for the entire project, so there is no need to evaluate access for each resource. For everyone else, we need to ask, "Is this person related to this product?" RBAC serves as a broad, inexpensive first gate, while ReBAC serves as a narrow, precise second gate.
The last line is also worth noting. When creating the epic, we set the product as its parent. Thanks to this one line, when we later check permission to edit an epic, the schema’s parent->editautomatically traverses back up to the product. There is no need to attach a Scrum Master to each epic again.
Conclusion
To summarize ReBAC in one line, it is storing permissions as relationships between people and resources rather than as labels attached to people.
Before adopting it, we wondered, "Do we really need a separate system just to check a single permission?" However, once resources begin to form a hierarchy — epics under products, and releases under epics — roles alone can no longer express everything, and permission checks start to seep into the service code. If we move relationships out at that point, the domain code can focus only on "what to do."
Of course, it is not free. If relationship data falls out of sync with the source data, permissions can quietly become incorrect, and this is harder to notice than a UI bug. If we forget to remove a Scrum Master from the group when replacing them, the previous owner will continue to be able to make edits. That is also why we consolidated Scrum Master registration and removal in a single class, ProductAuthorizer. Code that modifies relationships must not be scattered, so that we can find any places where something was missed.
walrus