[00:00.000 --> 00:05.420] All right. So with that in mind, welcome to the stage, Ben. [00:06.280 --> 00:14.240] Thank you. Hello, everyone. I'm going to be that annoying guy for the person behind the [00:14.240 --> 00:19.640] camera. I like moving a lot, hence I've got the handheld. I don't like to be stuck behind a [00:19.640 --> 00:25.280] podium. But the main reason I'm here today is because I'd like to talk to you about some [00:25.280 --> 00:29.520] security matters that interest me. Who here is familiar with access control within web [00:29.520 --> 00:33.960] applications in some way or form? About half of you. That's cool. Who knows what RBAC is? [00:34.460 --> 00:40.500] ABAC? Rebac? Cool. Increasingly dropping numbers of hands. That's kind of what I [00:40.500 --> 00:44.520] expected. I think we've got about 10% people here who know Rebac. So we're going to dive in [00:44.520 --> 00:48.680] and we're going to go a little bit deep dive into how Rebac works. Now, normally this is a [00:48.680 --> 00:54.120] 45-minute to one-hour conversation. So excuse me if I skip over some bits, but please come [00:54.120 --> 00:57.140] and ask me questions afterwards. But we're going to go a little bit deep on how the data [00:57.140 --> 01:01.900] actually gets stored so that we as developers understand how Rebac was going to help us and [01:01.900 --> 01:05.980] how the relationship-based access control actually works or may not work for you. It's not [01:05.980 --> 01:10.860] always the right solution. But who am I? I'm a guy who develops slides that have really bad [01:10.860 --> 01:16.660] contrast on LED screens. Also, I've been a software engineer for too many years. I used to [01:16.660 --> 01:20.140] put the number up there. It made me feel old, so now I just do a sentence. You can do the [01:20.140 --> 01:24.280] maths in your head. I love working with developer and open source communities. I've been [01:24.280 --> 01:28.980] doing that for about 20 years. I'm really passionate about security and privacy. If you want [01:28.980 --> 01:33.080] to talk to me about any of those things, those are my jam. Come talk to me afterwards. I'm [01:33.080 --> 01:37.520] currently working as a developer advocate for a company called ArcJet, hence the branding [01:37.520 --> 01:43.260] across my chest here. We're a middleware security solution for your web applications. If you [01:43.260 --> 01:47.220] are writing any kind of web application at all, check out ArcJet.com and just plug it in. It's [01:47.220 --> 01:51.960] free. Give it a try. We'd love to hear what you think about it. If you want to contact me, I've [01:51.960 --> 01:57.260] got the X logo on there, although I still like to call them Twitter. I feel some ways about an [01:57.260 --> 02:03.060] organization whose community does not accept certain people's desire to change their [02:03.060 --> 02:06.880] identity, so I will not allow Twitter to change their identity either. So my Twitter handle [02:06.880 --> 02:14.180] is at BenDekarai. My DMs are open. Contact me. If you like. It's not an instruction. It's an [02:14.180 --> 02:18.940] offer. So let's get into it. Access Control 101. Basics and understandings thereof. First [02:18.940 --> 02:23.520] thing we're going to have a look at is the caricatures we're going to be looking at. So [02:23.520 --> 02:26.780] whenever it comes to access control, the dog wants the bone, right? So we're going to look at [02:26.780 --> 02:30.540] ways that we can stop or allow the dog from accessing the bone. First one is going to be [02:30.540 --> 02:34.320] using RBAC, Role-Based Access Control. It's probably one of the simplest access control [02:34.320 --> 02:38.520] mechanisms, so we'll skip through this very quickly. Basically, we have a number of roles. [02:38.580 --> 02:42.440] You've got an admin, you've got a manager, employee, and a guest. And in our case, our dog, [02:42.440 --> 02:48.080] this is Shadow. Shadow has a blue hat on. Blue hats are employees. And the door is locked to [02:48.080 --> 02:52.640] all but the admins, managers, and employees. We don't want guest dogs getting to the bones. [02:52.640 --> 02:58.620] Only employee, manager, and admin dogs, my analogies fall apart a little bit sometimes, are [02:58.620 --> 03:03.260] going to get access to the bone. So because Shadow has access, the door opens. Role-Based [03:03.260 --> 03:09.060] Access Control. Nice and simple. Next one, Attribute-Based Access Control. This is kind of [03:09.060 --> 03:12.060] like role-based, because you could say, well, a role is an attribute of a person, but [03:12.060 --> 03:16.920] attribute puts so many more layers on top of this. So we've got four attributes here of the [03:16.920 --> 03:22.400] dog. This is Min. This is a white Siberian husky. These are actual real dogs in my life. I [03:22.400 --> 03:26.620] like to relay them into my talks. There are four characteristics. Service dog, good boy, [03:26.620 --> 03:31.840] loyal, and fierce. I can tell you while Shadow is a service dog, Min will never be a service [03:31.840 --> 03:34.680] dog. If you've ever seen one of those dogs that just cannot control itself because it's [03:34.680 --> 03:39.180] always so bloody happy, that's Min. So she will never ever be a service dog. But she is [03:39.180 --> 03:45.220] usually a good boy or a loyal. She is not fierce. We've decided in this case that we're [03:45.220 --> 03:48.640] going to make her a loyal dog, and the door will open if you are a good boy or a loyal [03:48.640 --> 03:54.320] dog. Now, as an aside, I go on tangents occasionally. You might be asking yourself, but [03:54.320 --> 03:58.100] why doesn't a service dog get a bone? Because a service dog is good, right? Service dogs [03:58.100 --> 04:03.080] deserve bones. Anybody agree with that? Nobody agrees with that? You all hate service [04:03.080 --> 04:07.900] dogs. That's what I'm learning about you lot. Jesus. Rough crowd. No, service dogs are [04:07.900 --> 04:12.220] working. They don't get to eat. But we're going to layer an attribute on top of this, because [04:12.220 --> 04:16.160] you could say, well, that's just a role, right? The attribute here we're going to put in is [04:16.160 --> 04:23.300] time. Who does have a dog? Wrong audience. Who has cats? Okay. Let's pretend your cat likes [04:23.300 --> 04:30.440] eating bones. Or for those of you who have dogs. Who lets their dog sleep in their bedroom [04:30.440 --> 04:36.640] with them at night? Who would like the sound of a crunching bone at 3 a.m.? No, I certainly [04:36.640 --> 04:41.240] don't like the sound of a crunching bone at 3 a.m., so if it's outside of 9 p.m. to 9 a.m., [04:41.240 --> 04:47.540] no bone for you. So sadly, men get no bone. But there are plenty of other things we can do [04:47.540 --> 04:52.080] attributes on. We've got actual identity, physical location, network location, the time, the [04:52.080 --> 04:55.340] weather, whether or not you're authenticated to a system. There are lots of things you can [04:55.340 --> 04:59.080] layer on top of this as an attribute of whether or not somebody should get access to a [04:59.080 --> 05:04.100] resource. So a bit more complexity, a bit more flexibility about how we can control our [05:04.100 --> 05:08.060] resources, which brings us on to relationship-based access control. And this changes the [05:08.060 --> 05:15.520] paradigm quite significantly as I lose my balance. So this dog doesn't actually have a name. [05:15.540 --> 05:21.600] Who here had a dog? What was your dog's name? Liam. This is Liam. Thank you. Liam is [05:21.600 --> 05:26.620] actually a dog. Dali designed Liam. I thought it came out a little bit like a cat, but that's [05:26.620 --> 05:32.240] what we're going with. So Liam has an owner. You are the mad scientist. Congratulations. [05:32.720 --> 05:37.100] So Liam's owner is a mad scientist. The mad scientist is friends with a farmer. The [05:37.100 --> 05:40.360] farmer has a whole lot of sheep. And for the vegetarians in the audience, I apologize, but [05:40.360 --> 05:48.380] sheep have bones. Ten minutes? Oh, I need to stay back. This is not good for me because, A, [05:48.380 --> 05:53.320] I'm going to fall off the back of the stage. Not too far. Okay. Just right here. Okay. The [05:53.320 --> 05:59.580] guy who likes to roam may no longer roam. That's okay. So we have this chain of [05:59.580 --> 06:06.460] relationships, as you can see. So we can see here that Liam may or may not have access to the [06:06.460 --> 06:11.040] rules that you can see. Now I'm getting feedback. Based on the rules you can see on the door [06:11.040 --> 06:16.920] there. Oh, sorry. Let's just zoom in a little bit. The rules you can see on the door there. So [06:16.920 --> 06:21.700] with relationship-based access control, we don't actually have a concept of users anymore. We [06:21.700 --> 06:34.270] just have a concept of entities and relationships. Entities and relationships. I'll keep [06:34.270 --> 06:38.990] going unless they actually stop me or unless too many people in the audience cringe. So here [06:38.990 --> 06:43.950] we've got an action. Can the action eat be completed on the bone? So note that we're looking [06:43.950 --> 06:49.370] here at what can be done to the bone. We're not looking at what Shadow or Liam can do. We're [06:49.370 --> 06:52.970] looking at what can be done to the bone, what actions can be taken place. If it's the [06:52.970 --> 06:57.030] animal owner or the friend of the owner of an animal or the pet of a friend of the owner of the [06:57.030 --> 07:02.870] animal, they can eat the bone. Technically I suppose you could argue, no, I probably wouldn't [07:02.870 --> 07:06.690] want the owner of the bone, the sheep, to be eating the bone. That would be a little bit [07:06.690 --> 07:10.890] weird. But you can see we just find here a set of relationships that allow us to decide [07:10.890 --> 07:15.710] whether or not the bone can be accessed by the dog. And because through those green lines [07:15.710 --> 07:19.550] there, which are really terrible on this background, you can see that the flow does actually [07:19.550 --> 07:26.030] go all the way through. Liam gets a bone. Good for Liam. So the door opens. Now, say one [07:26.030 --> 07:31.550] day the farmer and the mad scientist break friends. They're no longer friends with each [07:31.550 --> 07:35.150] other. Suddenly that relationship is broken. Now, nothing has changed about the bone and [07:35.150 --> 07:38.930] nothing has changed about Liam. But the relationship is broken, therefore the friend [07:38.930 --> 07:43.610] component of that rule there breaks. So the only rule that allowed Liam to get access to [07:43.610 --> 07:48.410] that bone is now broken and the door shuts. So that's what a relationship-based access [07:48.410 --> 07:53.670] control is about. It's not so much about defining what somebody or some user can do. It's [07:53.670 --> 07:59.090] about what actions can be performed on a resource based on a set of rules that relates lots [07:59.090 --> 08:05.710] of resources together. Does that make sense? Cool. So under the hood, who here is familiar [08:05.710 --> 08:10.470] with the entity attribute value model of designing? So if you've ever done any kind of [08:10.470 --> 08:14.110] content management systems or anything like that where you've got an undefined at the [08:14.110 --> 08:17.390] beginning of your project, you have an undefined number of entities, you want a way to be [08:17.390 --> 08:21.050] able to create new entities in your system without having to do a database deployment [08:21.050 --> 08:25.310] because they are nasty, especially when you have a lot of data. So the entity attribute [08:25.310 --> 08:30.850] value model of data storage basically says you have a table that defines entities and you [08:30.850 --> 08:34.830] have another table that defines the attributes and values for that entity. So if you want to [08:34.830 --> 08:39.330] add another entity, it's just another row in a table. Nice and simple. Let's have a quick [08:39.330 --> 08:44.190] look at how that works. So we've got a user and an article. So we'll be looking at a blog [08:44.190 --> 08:48.050] post system, for example. So we've got a user and an article and on this right hand side [08:48.050 --> 08:51.570] here we've got a whole jumbled load of mess. You can see we've got the entity ID, the [08:51.570 --> 08:57.250] second column. So the first, second, and the last two rows in the attribute table belong to [08:57.430 --> 09:05.050] a user. And because the second column has number twos in it, the third and fourth rows belong [09:05.050 --> 09:09.370] to an article. So you can see the user's username is Robin and the user's password is [09:09.370 --> 09:14.890] password. Down there we have username Morgan and password, for some reason they like using [09:14.890 --> 09:19.810] JSON Web Tokens for their passwords, but that's their password. And then in the middle [09:19.810 --> 09:23.290] through there you can see that we've got an article, one article, instance ID of the article [09:23.290 --> 09:28.490] is one. We've got a title of Rebec for the win and content is can has FGA, fine grained [09:28.490 --> 09:37.430] access control. So now if we want to pull stuff out we can use a fairly simple-ish join within [09:37.430 --> 09:42.150] an SQL table to say, well, pull all these things out and I can pull out, for example, get me [09:42.150 --> 09:48.150] all of the articles that you have. Give me the title and the content. Or maybe rather than [09:48.150 --> 09:51.870] getting information about one entity you can say give me a list of all the users and just give [09:51.870 --> 09:58.710] me their usernames. So this table set up basically allows you to get really varied views [09:58.710 --> 10:01.830] across the data you have without having to change your database schema, without having to [10:01.830 --> 10:05.950] know what that schema looks like to start with. And you can store arbitrary data in there [10:05.950 --> 10:11.610] and pull it out in whichever way you want. It's complicated and expensive to pull out. And [10:11.610 --> 10:16.850] it's somewhat complicated to set up and use within more so than if you had like an article [10:16.850 --> 10:20.910] table and a user table and a comment table. So if we want to add a comment, for example, we [10:20.910 --> 10:25.750] just add an extra row over there and then we can add some extra columns here saying, okay, so [10:25.750 --> 10:31.750] we've now got this entity ID3, instance ID1, this is comment number one, the article ID is [10:31.750 --> 10:36.630] number one, author is Sam, comment was first and here's the date Sam. So without making any [10:36.630 --> 10:42.430] database schema change, I've added a whole new entity to the system. The only reason I tell [10:42.430 --> 10:47.170] you about EAV is because this is very similar to the way that Reback is managed under the [10:47.170 --> 10:51.950] hood. So let's have a look at how that works. We've got entities on the left-hand side, [10:51.950 --> 10:57.670] Robin is a user, Acme Co is an organization and Reback for the win is an article. And down [10:57.670 --> 11:02.210] here we have some relationships. So we're now looking at just subject ID and I apologize for [11:02.210 --> 11:06.470] the color scheme, we've got a relationship ID which is just arbitrary for this table, we've got [11:06.590 --> 11:11.830] a subject entity ID and an object entity ID. So how does a subject relate to an entity? A [11:11.830 --> 11:16.510] subject is an entity, it's just a primary entity within a relationship. So we're saying subject [11:16.510 --> 11:23.550] one, the user, entity ID three, the article, relationship type is owner. Therefore we know [11:23.550 --> 11:30.330] that Robin is the owner of the Reback for the win article. We can then add in that Robin, user [11:30.330 --> 11:38.050] one, is a member of organization Acme Co. And we can add in that Morgan, user four, is a [11:38.050 --> 11:44.470] member of the organization Acme Co as well. So we now know that both Robin and Morgan are [11:44.470 --> 11:48.910] members of Acme Co. Now we have another one here where we say the organization is a [11:48.910 --> 11:54.770] viewer of the Reback article. But organizations can't view things. So we're able to extend [11:54.770 --> 11:59.170] that slightly and put an extra entity relation on there. How do the entities relate to each [11:59.170 --> 12:04.250] other? Through this member relation. So if we dial that back, if we see here we've got [12:04.250 --> 12:10.750] member in the middle two rows here, we've got a relationship of members. So what we now know [12:10.750 --> 12:20.310] is that members of organization two can view the Reback for the win article. So now if I add [12:20.310 --> 12:24.790] another member into that organization, they automatically inherit that because the [12:24.790 --> 12:30.190] relationship exists already. Does that make sense? This is where it gets a little bit murky. [12:30.470 --> 12:33.750] You don't need to know all of this. I just want you to understand how the data sits in [12:33.750 --> 12:39.110] there so that when we start pulling it out, you can see what's going on. So the other thing [12:39.110 --> 12:43.070] we can do is define permissions on all of these. So we've got the relationships, but what [12:43.070 --> 12:47.190] does that actually mean they can do? So permission ID one, again, arbitrarily for the [12:47.190 --> 12:53.210] permissions table, relates to relationship ID one. So relationship ID one was Robin is the [12:53.210 --> 12:58.310] owner of the Reback article. So we're saying here, well, one of the permissions is read. [12:59.850 --> 13:06.690] Relationship ID one is also that Robin is the owner of the article. Robin also has write [13:06.690 --> 13:13.930] access. And then we have relationship ID four, which is this, this inferred down here, [13:13.930 --> 13:20.610] members of organization two, members of organization two have read permissions. So even [13:20.610 --> 13:24.970] over here we've got relationship types and entities like viewer is just a label. It [13:24.970 --> 13:28.810] doesn't mean anything to the system. But when you look at that, you see what that means is [13:28.810 --> 13:35.930] the permission for viewer for any member of organization two has read access on article [13:35.930 --> 13:43.750] one. So there's one extra table here compared to the AV, but this allows us to define a [13:43.750 --> 13:48.470] multitude of relationships and permissions and how they relate to each other and to other [13:48.470 --> 13:52.290] entities. And more importantly, they allow you to chain those identities. Remember how we [13:52.290 --> 13:57.310] went from Liam to the mad scientist to the farmer to the sheep to the bone? It's not just [13:57.310 --> 14:01.430] one-to-one. You can define these huge big chains and if any part of that chain gets broken, [14:01.430 --> 14:08.030] then the relationship breaks. So querying the Reback model, how does this work? Let's say we [14:08.030 --> 14:14.710] come in here and we want to find out who can read. We can see here that the read, sorry, [14:14.710 --> 14:27.640] who can write, the permission ID there is two. So if we... I think I've got the wrong one [14:27.640 --> 14:33.340] highlighted there. I want to find out who can write to Reback article two. So first thing we [14:33.340 --> 14:37.620] do is we look at the, and the highlighting isn't working so great here, the object entity ID [14:37.620 --> 14:41.740] three there is the Reback article. So we say, okay, within the relationships, let's find out [14:41.740 --> 14:46.300] everything we know about the article. And we can see here that the fourth one there can be [14:46.300 --> 14:51.160] excluded straight away because the relationship ID number four is not in the permissions [14:51.160 --> 14:58.800] table. However, relationship ID one is in that table. That is related to the object identity [14:58.800 --> 15:06.140] two. So we can pull out the user Robin has write access to the article. So you can look at [15:06.140 --> 15:09.940] things in other directions as well. And then further to that, you could even say, okay, well, [15:09.940 --> 15:13.400] tell me everything about the article rather than starting from the permissions. We look at [15:13.400 --> 15:20.480] article number three. We know that Robin is the owner of that article already. And if we [15:20.480 --> 15:24.440] look at the viewer here, we can then, and this is what I was talking about before, how [15:24.440 --> 15:29.880] member gets extrapolated to infer relationship status. So we can see that the member [15:29.880 --> 15:37.460] here of organization two has access to the article. And if we then fold those in, you see [15:37.460 --> 15:41.380] how before this one here was highlighted, what we're now doing is saying the subject is now [15:41.380 --> 15:46.960] the object. So where the object is now entity ID two, where also the relationship type is [15:46.960 --> 15:51.240] member, that's where this one basically gets folded out. So that's probably one of the most [15:51.240 --> 15:58.740] complicated lookups. It's really diving straight into the depths of the Reback schema. But [15:58.740 --> 16:02.480] essentially what we're doing there at that point is we're saying this permission or this [16:02.480 --> 16:05.200] relationship here doesn't make sense from a permission sense because you don't give [16:05.200 --> 16:10.400] permissions to inanimate objects like organizations necessarily. I mean, you do. But [16:10.400 --> 16:15.520] that doesn't really help an end user. How do we then unfold that and then extrapolate that [16:15.520 --> 16:20.880] to refer to the actual user entities? And this is where it gets complicated because Reback, [16:20.880 --> 16:25.840] as I said, doesn't have a concept of a user necessarily. You could actually ask Reback what is [16:25.840 --> 16:30.620] the relationship between this organization and that network. Neither of them really do [16:30.620 --> 16:33.640] anything. They're system entities. They're not user entities. But they still have [16:33.640 --> 16:43.940] relationships. So it's powerful, but also complex. So implementation details. Let's have a [16:43.940 --> 16:47.640] think about how we might do something in code, which is probably the way most of us do [16:47.640 --> 16:53.080] the more complicated business logic like this. So if we want to allow editing an article, if [16:53.080 --> 16:59.120] a user is an admin or an editor, if an editor is allowed to edit this particular article, if [16:59.120 --> 17:03.160] the article is sensitive, then we also want to make sure that the person is on site and we [17:03.160 --> 17:07.620] want to make sure that they're doing it during office hours. Seems like a fairly robust [17:07.620 --> 17:14.260] kind of setup that you might have in a large organization. So if. If the user is admin or [17:14.260 --> 17:21.660] if the user is editor. Cool. So we know what role the user has. Also, if the user is an [17:21.660 --> 17:26.340] editor and the list of document editors contains the current user. So we don't want any [17:26.340 --> 17:30.740] editor to be able to edit this. Only if the list of editors for this particular article [17:30.740 --> 17:35.700] includes the current user. So we can compound those two together. Then also we want to [17:35.700 --> 17:39.760] say, well, if the document isn't sensitive, then we can carry on. Otherwise, we're going to [17:39.760 --> 17:46.540] check to see if the user's location is on premises or if the user's location is currently in [17:46.540 --> 17:51.020] office hours. And I say the user's location because in a world like today, who knows when [17:51.020 --> 17:55.140] it's 9 to 5 for somebody. So as long as it's within the location they're in, it's working [17:55.140 --> 18:00.420] hours and they're on premises or the document is not sensitive and they meet the user [18:00.420 --> 18:04.680] requirements, they're going to get access to this document. Imagine if you had to come [18:04.680 --> 18:10.680] back and change those rules three months later. So instead what we're going to do is we're [18:10.680 --> 18:15.120] going to define entities within our relationship-based access management tool of [18:15.120 --> 18:19.680] choice. We're going to define a document. The document has an owner and an editor. The [18:19.680 --> 18:26.020] owner is a user and the editor is a member of an organization with the member type editor. [18:26.400 --> 18:31.060] So you can have different types of people within groups. And then we're going to have a [18:31.060 --> 18:34.460] sensitive document. So that's the definition of a normal document. A sensitive document is [18:34.460 --> 18:39.820] going to extend document. It's also going to have an edit action on it that says if it's [18:39.820 --> 18:44.860] within working hours and the document ‑‑ it's the document owner who's trying to do this [18:44.860 --> 18:48.000] action. Because remember, we're defining actions on an entity and who's allowed to [18:48.000 --> 18:53.260] perform it. So can edit be done on a sensitive document? Yes, you can if you are the [18:53.260 --> 18:58.820] document owner and you are the document owner and you're on premises. Or if you're an [18:58.820 --> 19:03.460] editor and you're on premises. So this gets tied into your relationship-based access [19:03.460 --> 19:11.600] model schema and permission systems. So now your code can change from this to that. And [19:11.600 --> 19:17.700] now your business logic isn't restricted or it doesn't include the permissions check [19:17.700 --> 19:21.240] because there's no real reason for that to be there. The permission for who should [19:21.240 --> 19:25.660] access an entity within your system should not be dependent on what's in the business [19:25.660 --> 19:31.120] logic. There's a fast and firm rule for that. This gives you two benefits. One from a [19:31.120 --> 19:35.320] clean code, easy to read perspective. That is much easier to read. You know exactly what's [19:35.320 --> 19:39.600] going to happen. You don't have to think about it. Also from a permissions and access [19:39.600 --> 19:43.820] control management perspective, your security team can manage the rules and the [19:43.820 --> 19:48.840] schema separately from your development team and it puts the responsibility in the right [19:48.840 --> 19:57.620] place. So demo time. This is the fun part. So the first part was all about dogs. Then we went [19:57.620 --> 20:02.500] to document access management which is important but boring. So we're going to go back to [20:02.500 --> 20:08.000] dogs. I have tried a number of products. There are all these products up on the screen [20:08.000 --> 20:12.820] here. There are many more. These are relationship-based access management tools. Some [20:12.820 --> 20:15.900] of them are open source and free to use. Some of them are paid for. I'm going to be using [20:15.900 --> 20:22.080] Permify in this demo. And I'm not going to annoy anybody by switching over to this on the [20:22.080 --> 20:25.880] AV team because they didn't mic check me on this one. So I apologize in advance. But I'm [20:25.880 --> 20:33.060] going to need both hands. So I'm just going to stop screen sharing. Let's jump over here [20:33.060 --> 20:40.220] and we're going to have a first look at Postman. So let's make this a bit bigger. Can you [20:40.220 --> 20:46.240] all read that okay? Excellent. So let's have a look from the beginning. We're going to [20:46.240 --> 20:50.380] create a tenant. In fact, the first thing I'm going to do, because like all developers, [20:50.380 --> 20:57.340] I decided to test this before I started the talk. So I'm just going to restart Permify [20:57.340 --> 21:00.880] in the background. So we're starting from a bank slate. So now over here what we're [21:00.880 --> 21:05.100] going to do is we're going to create a new tenant. So Permify allows you to have multiple [21:05.100 --> 21:10.080] tenants in your system. So you can sandbox or isolate certain areas of your organization [21:10.080 --> 21:19.040] or even certain organizations within a larger system. So we're going to create a tenant [21:19.040 --> 21:25.460] over here called Dog and Bone. If I hit send on that, we'll see down here that we get a [21:25.460 --> 21:28.880] positive response back, a 200, and we've got our tenant. So the next thing I'm going to [21:28.880 --> 21:34.440] do is create the schema. Now this schema, for some reason, Permify wants it in a single [21:34.440 --> 21:42.520] string. So to make it easier, I have it over here. And this is very similar to what we [21:42.520 --> 21:47.180] saw in the slides. Basically we've got a definition of a dog. A dog has an owner, which is a person. [21:47.440 --> 21:51.760] We've got a sheep. A sheep has an owner that is also a person. A sheep also has a bone, [21:51.760 --> 21:56.080] which is an entity type bone. We've got a person. A person can have a friend, would [21:56.080 --> 22:00.160] be another person. A person can also have sheep and a person can have dogs. So we've [22:00.160 --> 22:05.640] got bidirectional rules here. And then we've got a relationship between the bone. The [22:05.640 --> 22:08.960] bone has an owner, and that's a sheep. And then we've got a permission. Can the owner's [22:08.960 --> 22:19.260] friend's dog eat? And eat is true if that comes out as a relationship that exists. So let's [22:21.160 --> 22:25.560] submit that through and we should find that that has now worked. If I now create some [22:28.720 --> 22:38.960] relationships... come on, get bigger. Where's the handle? It's always hiding. I'll just [22:38.960 --> 22:43.920] scroll through this a little by little. Actually if I make this slightly smaller, is that still [22:43.920 --> 22:48.240] readable at the back? Yep, okay. So at least we can see a bit more at a time. So we can [22:48.240 --> 22:51.880] see here we've got a relationship between a subject and an entity. Remember I said a [22:51.880 --> 22:55.740] subject is also an entity, but it's just the primary entity in a relationship. Is the microphone [22:55.740 --> 23:01.620] cutting in? A little? I'll go back to this one. Because I don't need to type as much now. So we [23:01.620 --> 23:06.800] can see the subject, mad scientist, is the owner of Shadow the Dog. We can see here that [23:06.800 --> 23:11.620] Shadow the Dog is also a dog belonging to the scientist. And then we've got the farmer has [23:11.620 --> 23:18.760] Dolly the sheep. The sheep belongs to the farmer. And we've got Dolly is a sheep to the [23:18.760 --> 23:24.540] femur. And the femur is a bone to the sheep. So we've got these relationships built up [23:24.540 --> 23:30.820] now. So if I come through and I ask what friends does the scientist have, because we [23:30.820 --> 23:36.700] haven't defined those relationships yet, if I execute that, we'll see down here that the [23:36.700 --> 23:43.280] result is nothing. We have no, he has no friends. He's a sad scientist. As it happens, the [23:43.280 --> 23:47.560] farmer is also a sad farmer. Although the farmer has sheep, so a little bit happier, [23:47.560 --> 23:53.020] probably. I know, sheep are better than dogs. I digress yet again. So can Shadow eat the [23:53.020 --> 24:00.080] bone? What do we reckon? No. So if I hit that, it comes through. Result denied. So [24:01.300 --> 24:09.060] it's a very low energy kind of reaction that I'm getting. But it's also a very low energy [24:09.060 --> 24:13.940] kind of output. So I thought I've got these two requests here that I can make. The first [24:13.940 --> 24:19.940] one calls data right. What I'm going to do is I'm going to say, okay, the mad scientist [24:19.940 --> 24:23.420] is now friends with the farmer. And then I've got another one here, break friends. [24:23.600 --> 24:27.540] It's data delete. And in here I'm defining the mad scientist is no longer a friend with [24:27.540 --> 24:37.460] the farmer. So to make this a little more exciting, I decided to show you all my sister's [24:37.460 --> 24:44.220] Facebook page. And also let's bring this back in over here. I have a dog and a bone. Let's [24:44.220 --> 24:49.440] just refresh this, because it doesn't like having the lid shut on it. And for some reason [24:49.440 --> 24:55.200] I'm getting an image rendering error. There we go. What demos go perfectly. So doors closed. [24:55.200 --> 25:03.760] Dog can't get a bone. So what happens if the farmer makes friends with the scientist? What [25:03.760 --> 25:15.340] do you think? No, it didn't work. Did I call the right one there? Looks like you're offline. [25:15.340 --> 25:25.880] Yeah, but I'm doing everything locally. So did I call the wrong one? Did I call break [25:25.880 --> 25:36.180] friends? Let's double click on that one. Darn it. Well, I will show you that if we come [25:36.180 --> 25:43.940] over here and look at friends of mad scientist, we should now have, there we go, the [25:43.940 --> 25:49.760] friendship is now in here. So now if I call can shadow eat the bone, it comes back as still [25:49.760 --> 25:54.760] denied. So this is where the demo fails. I'm more than happy to work out why the demo [25:54.760 --> 25:59.000] failed. It was probably something to do with keeping my Wi-Fi off at DEF CON and closing my [25:59.000 --> 26:03.640] laptop lid between testing demos. But the theory is there. The results should have come [26:03.640 --> 26:07.520] back immediately. I had a little bit of a cheat in my app. It was basically polling every [26:07.520 --> 26:12.780] second. But there are plenty of ways of connecting to databases and getting a full time [26:12.780 --> 26:17.660] stream of data back. So you can get almost like a push notification or an immediate [26:17.660 --> 26:21.820] notification of permission changes if that's something you need in your environment. Most of [26:21.820 --> 26:24.800] the time it's probably something you only need every time you make a request to make sure [26:24.800 --> 26:31.080] that request should be honored. But one of the things that I want to caution is that while [26:31.080 --> 26:37.760] this is complicated and exciting and perhaps when it comes to permission systems, dare I say [26:37.860 --> 26:43.920] a little bit sexy, I'm not sure, it's not always the right solution. As I said, there's a lot [26:43.920 --> 26:47.180] more computation power required for doing things like checking whether or not a [26:47.180 --> 26:51.320] permission should be granted. Role based access control is always going to be your easiest. [26:51.320 --> 26:55.980] That's always simply like, is this person an admin, yes or no? In fact, in some [26:55.980 --> 26:59.700] situations, if you think of your home internet router, you don't even have permission [26:59.700 --> 27:04.360] systems like are they logged in, yes or no? That's technically the simplest. So work out which [27:04.360 --> 27:11.640] level of permissions complexity or the way that your data is modeled and how you want to [27:11.640 --> 27:16.200] define whether or not access should be allowed. Work out what level of complexity you can [27:16.200 --> 27:19.940] get to at a minimum while still meeting your requirements. Because if you go for the [27:19.940 --> 27:24.980] full thing, straight out, re-back all the way, baby, absolutely it's fun. You will [27:24.980 --> 27:29.340] probably create a situation where your job is now indispensable. You will not be fired [27:29.340 --> 27:33.920] because nobody knows what the hell you did. But it's not always the right solution, okay? [27:33.920 --> 27:37.640] Pick the right one for you. If you are currently going through a situation where you want [27:37.640 --> 27:42.560] to implement some kind of permission control, more than welcome to come up and talk to me [27:42.560 --> 27:46.900] afterwards and tell me a story. I'll let you know if I've got any clue at all as to what you [27:46.900 --> 27:52.400] may or may not consider. I'm certainly not going to tell you I know your system inside [27:52.400 --> 27:55.660] out and can tell you what the answer is, but I'm happy to have a chat and go through that [27:55.660 --> 28:02.960] with you. But I would like to finish by just saying thank you. If I can even find my slides. [28:06.830 --> 28:11.430] Let's just get that back up there. So again, that's my contact details at the top there. [28:11.890 --> 28:16.350] ArcJet are currently running a contest. If you want to try our product out, there's some [28:16.350 --> 28:20.890] prizes we're giving away as well. Challenge.arcjet.com. Give it a try. Let us know. We would really [28:20.890 --> 28:25.770] love to know from you how you find the product, how easy it is to use, and what we can do [28:25.770 --> 28:30.210] to make it easier for you to make your websites better. But this talk was about permission [28:30.210 --> 28:34.810] systems. Come talk to me. Thank you for your time. Have a great rest of your DEF CON. Thanks.