-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from biscuit-auth/namespace-and-interop
Talk a bit about interop and namespacing
- Loading branch information
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
+++ | ||
title = "Interoperability & Reusability" | ||
description = "Designing rules for reusability; keping things interoperable" | ||
date = 2021-05-01T08:00:00+00:00 | ||
updated = 2021-05-01T08:00:00+00:00 | ||
draft = false | ||
weight = 10 | ||
sort_by = "weight" | ||
template = "docs/page.html" | ||
|
||
[extra] | ||
lead = "Designing rules for reusability; keeping thing interoperable" | ||
toc = true | ||
top = false | ||
+++ | ||
|
||
In small biscuit deployments (a couple services, in a single | ||
organization), you have full control on which rules and facts are | ||
defined and have meaning. On bigger deployments (across multiple | ||
organizations, or if you want to design a reusable library that can | ||
be used by multiple services), you will need to be more careful | ||
about avoiding name collisions. | ||
|
||
While there are no well-defined patterns that have emerged yet, | ||
a good practice is to prefix fact names with the organization name, | ||
separated by a colon (`:`). So for instance: | ||
|
||
``` | ||
// can collide with other facts | ||
user("1234"); | ||
// makes it clear that the user is tied to a specific organization | ||
wayne_industries:user("1234"); | ||
``` | ||
|
||
## A few notes | ||
|
||
Using namespaced fact names will make tokens a bit bigger for two reasons: | ||
|
||
- well, they're longer; | ||
- names like `user` that are part of the default symbol table are only | ||
represented by an index in the wire format. | ||
|
||
The size increase will be mitigated by string interning (you only pay the extra | ||
cost once). | ||
|
||
Another thing to note is that _namespacing is not a security feature_: it prevents | ||
accidental name collisions, but is not a proper way to separate facts based on | ||
their origin. Third party blocks provide such a mechanism. Namespacing can be | ||
used _in conjuction_, to make things easier to read and understand. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters