1 00:00:00,000 --> 00:00:01,380 All right. 2 00:00:01,500 --> 00:00:05,420 So with that in mind, welcome to the stage, Ben. 3 00:00:06,280 --> 00:00:07,620 Thank you. 4 00:00:09,240 --> 00:00:10,540 Hello, everyone. 5 00:00:11,180 --> 00:00:14,980 I'm going to be that annoying guy for the person behind the camera. 6 00:00:14,980 --> 00:00:17,700 I like moving a lot, hence I've got the handheld. 7 00:00:17,740 --> 00:00:20,160 I don't like to be stuck behind a podium . 8 00:00:20,400 --> 00:00:26,800 But the main reason I'm here today is because I'd like to talk to you about some security matters that interest me. 9 00:00:26,800 --> 00:00:31,200 Who here is familiar with access control within web applications in some way or form? 10 00:00:31,280 --> 00:00:32,060 About half of you. 11 00:00:32,060 --> 00:00:32,460 That's cool. 12 00:00:32,460 --> 00:00:33,960 Who knows what RBAC is? 13 00:00:34,460 --> 00:00:35,180 ABAC? 14 00:00:35,800 --> 00:00:36,520 Rebac? 15 00:00:37,040 --> 00:00:37,580 Cool. 16 00:00:38,560 --> 00:00:39,920 Increasingly dropping numbers of hands. 17 00:00:39,920 --> 00:00:40,940 That's kind of what I expected. 18 00:00:40,940 --> 00:00:43,480 I think we've got about 10% people here who know Rebac. 19 00:00:43,480 --> 00:00:47,380 So we're going to dive in and we're going to go a little bit deep dive into how Rebac works. 20 00:00:47,380 --> 00:00:50,240 Now, normally this is a 45 -minute to one-hour conversation. 21 00:00:50,560 --> 00:00:55,000 So excuse me if I skip over some bits, but please come and ask me questions afterwards. 22 00:00:55,000 --> 00:01:05,800 But we're going to go a little bit deep on how the data actually gets stored so that we as developers understand how Rebac was going to help us and how the relationship-based access control actually works or may not work for you. 23 00:01:05,800 --> 00:01:07,140 It's not always the right solution. 24 00:01:07,520 --> 00:01:08,420 But who am I? 25 00:01:08,480 --> 00:01:12,700 I'm a guy who develops slides that have really bad contrast on LED screens. 26 00:01:12,840 --> 00:01:16,040 Also, I've been a software engineer for too many years. 27 00:01:16,040 --> 00:01:17,620 I used to put the number up there. 28 00:01:17,620 --> 00:01:19,740 It made me feel old, so now I just do a sentence. 29 00:01:19,740 --> 00:01:21,060 You can do the maths in your head. 30 00:01:21,220 --> 00:01:24,060 I love working with developer and open source communities. 31 00:01:24,060 --> 00:01:25,900 I've been doing that for about 20 years. 32 00:01:26,020 --> 00:01:28,680 I'm really passionate about security and privacy. 33 00:01:28,720 --> 00:01:31,100 If you want to talk to me about any of those things, those are my jam. 34 00:01:31,100 --> 00:01:32,280 Come talk to me afterwards. 35 00:01:32,740 --> 00:01:39,100 I'm currently working as a developer advocate for a company called ArcJet, hence the branding across my chest here. 36 00:01:39,100 --> 00:01:42,740 We're a middleware security solution for your web applications. 37 00:01:42,820 --> 00:01:47,020 If you are writing any kind of web application at all, check out ArcJet.com and just plug it in. 38 00:01:47,020 --> 00:01:47,660 It's free. 39 00:01:47,660 --> 00:01:48,220 Give it a try. 40 00:01:48,220 --> 00:01:49,680 We'd love to hear what you think about it. 41 00:01:50,420 --> 00:01:54,960 If you want to contact me, I've got the X logo on there, although I still like to call them Twitter. 42 00:01:55,000 --> 00:02:06,100 I feel some ways about an organization whose community does not accept certain people's desire to change their identity, so I will not allow Twitter to change their identity either. 43 00:02:06,100 --> 00:02:08,380 So my Twitter handle is at BenDekarai. 44 00:02:08,380 --> 00:02:09,680 My DMs are open. 45 00:02:09,680 --> 00:02:10,800 Contact me. 46 00:02:11,320 --> 00:02:12,060 If you like. 47 00:02:12,060 --> 00:02:13,380 It's not an instruction. 48 00:02:13,380 --> 00:02:14,860 It's an offer. 49 00:02:15,120 --> 00:02:16,060 So let's get into it. 50 00:02:16,060 --> 00:02:17,260 Access Control 101. 51 00:02:17,260 --> 00:02:18,660 Basics and understandings thereof. 52 00:02:18,660 --> 00:02:23,400 First thing we're going to have a look at is the caricatures we're going to be looking at. 53 00:02:23,420 --> 00:02:25,960 So whenever it comes to access control, the dog wants the bone, right? 54 00:02:26,020 --> 00:02:29,800 So we're going to look at ways that we can stop or allow the dog from accessing the bone. 55 00:02:29,820 --> 00:02:32,520 First one is going to be using RBAC, Role-Based Access Control. 56 00:02:32,580 --> 00:02:36,860 It's probably one of the simplest access control mechanisms, so we'll skip through this very quickly. 57 00:02:36,880 --> 00:02:38,520 Basically, we have a number of roles. 58 00:02:38,580 --> 00:02:41,060 You've got an admin, you've got a manager, employee, and a guest. 59 00:02:41,060 --> 00:02:43,260 And in our case, our dog, this is Shadow. 60 00:02:43,680 --> 00:02:45,180 Shadow has a blue hat on. 61 00:02:45,180 --> 00:02:46,620 Blue hats are employees. 62 00:02:46,940 --> 00:02:50,560 And the door is locked to all but the admins, managers, and employees. 63 00:02:50,560 --> 00:02:52,640 We don't want guest dogs getting to the bones. 64 00:02:52,640 --> 00:02:59,800 Only employee, manager, and admin dogs, my analogies fall apart a little bit sometimes, are going to get access to the bone. 65 00:02:59,800 --> 00:03:02,900 So because Shadow has access, the door opens. 66 00:03:03,000 --> 00:03:03,980 Role-Based Access Control. 67 00:03:03,980 --> 00:03:04,900 Nice and simple. 68 00:03:05,720 --> 00:03:08,440 Next one, Attribute-Based Access Control. 69 00:03:08,440 --> 00:03:14,820 This is kind of like role-based, because you could say, well, a role is an attribute of a person, but attribute puts so many more layers on top of this. 70 00:03:14,820 --> 00:03:17,180 So we've got four attributes here of the dog. 71 00:03:17,180 --> 00:03:18,040 This is Min. 72 00:03:18,060 --> 00:03:20,680 This is a white Siberian husky. 73 00:03:20,680 --> 00:03:22,320 These are actual real dogs in my life. 74 00:03:22,320 --> 00:03:24,240 I like to relay them into my talks. 75 00:03:24,440 --> 00:03:25,640 There are four characteristics. 76 00:03:25,640 --> 00:03:27,800 Service dog, good boy, loyal, and fierce. 77 00:03:27,800 --> 00:03:32,200 I can tell you while Shadow is a service dog, Min will never be a service dog. 78 00:03:32,200 --> 00:03:36,660 If you've ever seen one of those dogs that just cannot control itself because it's always so bloody happy, that's Min. 79 00:03:36,660 --> 00:03:38,700 So she will never ever be a service dog. 80 00:03:38,700 --> 00:03:42,000 But she is usually a good boy or a loyal. 81 00:03:42,000 --> 00:03:43,220 She is not fierce. 82 00:03:43,560 --> 00:03:49,240 We've decided in this case that we're going to make her a loyal dog, and the door will open if you are a good boy or a loyal dog. 83 00:03:49,340 --> 00:03:52,440 Now, as an aside, I go on tangents occasionally. 84 00:03:52,580 --> 00:03:56,260 You might be asking yourself, but why doesn't a service dog get a bone? 85 00:03:56,260 --> 00:03:57,560 Because a service dog is good, right? 86 00:03:57,560 --> 00:03:59,700 Service dogs deserve bones. 87 00:03:59,800 --> 00:04:01,080 Anybody agree with that? 88 00:04:01,560 --> 00:04:02,400 Nobody agrees with that? 89 00:04:02,400 --> 00:04:03,440 You all hate service dogs. 90 00:04:03,440 --> 00:04:04,600 That's what I'm learning about you lot. 91 00:04:04,600 --> 00:04:05,220 Jesus. 92 00:04:05,480 --> 00:04:06,500 Rough crowd. 93 00:04:07,060 --> 00:04:08,360 No, service dogs are working. 94 00:04:08,360 --> 00:04:09,320 They don't get to eat. 95 00:04:09,680 --> 00:04:14,200 But we're going to layer an attribute on top of this, because you could say, well, that's just a role, right? 96 00:04:14,220 --> 00:04:16,600 The attribute here we're going to put in is time. 97 00:04:16,600 --> 00:04:17,880 Who does have a dog? 98 00:04:19,200 --> 00:04:19,980 Wrong audience. 99 00:04:19,980 --> 00:04:21,100 Who has cats? 100 00:04:21,740 --> 00:04:22,140 Okay. 101 00:04:22,140 --> 00:04:24,280 Let's pretend your cat likes eating bones. 102 00:04:25,180 --> 00:04:26,900 Or for those of you who have dogs. 103 00:04:27,420 --> 00:04:31,400 Who lets their dog sleep in their bedroom with them at night? 104 00:04:31,400 --> 00:04:35,200 Who would like the sound of a crunching bone at 3 a.m.? 105 00:04:35,200 --> 00:04:40,660 No, I certainly don't like the sound of a crunching bone at 3 a.m., so if it's outside of 9 p.m. 106 00:04:40,660 --> 00:04:42,340 to 9 a.m., no bone for you. 107 00:04:42,500 --> 00:04:44,740 So sadly, men get no bone. 108 00:04:45,960 --> 00:04:48,260 But there are plenty of other things we can do attributes on. 109 00:04:48,260 --> 00:04:54,380 We've got actual identity, physical location, network location, the time, the weather, whether or not you're authenticated to a system. 110 00:04:54,380 --> 00:04:59,440 There are lots of things you can layer on top of this as an attribute of whether or not somebody should get access to a resource . 111 00:05:00,620 --> 00:05:07,220 So a bit more complexity, a bit more flexibility about how we can control our resources , which brings us on to relationship-based access control. 112 00:05:07,220 --> 00:05:11,020 And this changes the paradigm quite significantly as I lose my balance. 113 00:05:11,500 --> 00:05:15,520 So this dog doesn't actually have a name. 114 00:05:15,540 --> 00:05:16,900 Who here had a dog? 115 00:05:17,280 --> 00:05:18,360 What was your dog's name? 116 00:05:18,580 --> 00:05:19,040 Liam. 117 00:05:19,040 --> 00:05:19,900 This is Liam. 118 00:05:19,900 --> 00:05:20,580 Thank you. 119 00:05:20,580 --> 00:05:22,260 Liam is actually a dog. 120 00:05:22,260 --> 00:05:23,880 Dali designed Liam. 121 00:05:24,060 --> 00:05:27,520 I thought it came out a little bit like a cat, but that's what we're going with. 122 00:05:27,580 --> 00:05:30,020 So Liam has an owner. 123 00:05:30,280 --> 00:05:31,520 You are the mad scientist. 124 00:05:31,520 --> 00:05:32,240 Congratulations. 125 00:05:32,720 --> 00:05:34,380 So Liam's owner is a mad scientist. 126 00:05:34,380 --> 00:05:36,880 The mad scientist is friends with a farmer. 127 00:05:36,880 --> 00:05:38,420 The farmer has a whole lot of sheep. 128 00:05:38,420 --> 00:05:41,460 And for the vegetarians in the audience, I apologize, but sheep have bones. 129 00:05:43,920 --> 00:05:44,800 Ten minutes? 130 00:05:45,760 --> 00:05:46,980 Oh, I need to stay back. 131 00:05:46,980 --> 00:05:49,980 This is not good for me because, A, I'm going to fall off the back of the stage. 132 00:05:50,140 --> 00:05:50,940 Not too far. 133 00:05:50,940 --> 00:05:51,320 Okay. 134 00:05:51,320 --> 00:05:52,200 Just right here. 135 00:05:52,200 --> 00:05:52,720 Okay. 136 00:05:53,040 --> 00:05:55,780 The guy who likes to roam may no longer roam. 137 00:05:55,820 --> 00:05:56,600 That's okay. 138 00:05:57,140 --> 00:06:01,080 So we have this chain of relationships, as you can see. 139 00:06:01,100 --> 00:06:08,000 So we can see here that Liam may or may not have access to the rules that you can see. 140 00:06:08,400 --> 00:06:09,520 Now I'm getting feedback. 141 00:06:09,600 --> 00:06:11,560 Based on the rules you can see on the door there. 142 00:06:11,940 --> 00:06:13,320 Oh, sorry. 143 00:06:13,320 --> 00:06:14,520 Let's just zoom in a little bit. 144 00:06:14,520 --> 00:06:16,280 The rules you can see on the door there. 145 00:06:16,740 --> 00:06:21,560 So with relationship-based access control, we don't actually have a concept of users anymore. 146 00:06:21,560 --> 00:06:28,310 We just have a concept of entities and relationships. 147 00:06:33,110 --> 00:06:33,990 Entities and relationships. 148 00:06:33,990 --> 00:06:37,590 I'll keep going unless they actually stop me or unless too many people in the audience cringe. 149 00:06:38,430 --> 00:06:39,850 So here we've got an action. 150 00:06:39,850 --> 00:06:42,210 Can the action eat be completed on the bone? 151 00:06:42,650 --> 00:06:45,550 So note that we're looking here at what can be done to the bone. 152 00:06:45,550 --> 00:06:48,750 We're not looking at what Shadow or Liam can do. 153 00:06:49,110 --> 00:06:52,250 We're looking at what can be done to the bone, what actions can be taken place. 154 00:06:52,470 --> 00:06:59,410 If it's the animal owner or the friend of the owner of an animal or the pet of a friend of the owner of the animal, they can eat the bone. 155 00:07:00,090 --> 00:07:06,030 Technically I suppose you could argue, no, I probably wouldn't want the owner of the bone, the sheep, to be eating the bone. 156 00:07:06,030 --> 00:07:07,290 That would be a little bit weird. 157 00:07:07,590 --> 00:07:13,410 But you can see we just find here a set of relationships that allow us to decide whether or not the bone can be accessed by the dog. 158 00:07:13,710 --> 00:07:20,690 And because through those green lines there, which are really terrible on this background, you can see that the flow does actually go all the way through. 159 00:07:21,010 --> 00:07:22,030 Liam gets a bone. 160 00:07:22,090 --> 00:07:23,210 Good for Liam. 161 00:07:23,230 --> 00:07:24,370 So the door opens. 162 00:07:24,910 --> 00:07:30,590 Now, say one day the farmer and the mad scientist break friends. 163 00:07:30,630 --> 00:07:32,010 They're no longer friends with each other. 164 00:07:32,010 --> 00:07:33,450 Suddenly that relationship is broken. 165 00:07:33,450 --> 00:07:36,630 Now, nothing has changed about the bone and nothing has changed about Liam. 166 00:07:36,630 --> 00:07:41,030 But the relationship is broken, therefore the friend component of that rule there breaks. 167 00:07:41,130 --> 00:07:46,170 So the only rule that allowed Liam to get access to that bone is now broken and the door shuts. 168 00:07:46,730 --> 00:07:49,210 So that's what a relationship-based access control is about. 169 00:07:49,210 --> 00:07:53,430 It's not so much about defining what somebody or some user can do. 170 00:07:53,430 --> 00:08:00,430 It's about what actions can be performed on a resource based on a set of rules that relates lots of resources together. 171 00:08:00,710 --> 00:08:01,630 Does that make sense? 172 00:08:02,130 --> 00:08:02,750 Cool. 173 00:08:03,690 --> 00:08:09,110 So under the hood, who here is familiar with the entity attribute value model of designing? 174 00:08:09,190 --> 00:08:22,490 So if you've ever done any kind of content management systems or anything like that where you've got an undefined at the beginning of your project, you have an undefined number of entities, you want a way to be able to create new entities in your system without having to do a database deployment because they are nasty, 175 00:08:22,490 --> 00:08:23,950 especially when you have a lot of data. 176 00:08:24,190 --> 00:08:34,310 So the entity attribute value model of data storage basically says you have a table that defines entities and you have another table that defines the attributes and values for that entity. 177 00:08:34,350 --> 00:08:37,390 So if you want to add another entity, it's just another row in a table. 178 00:08:37,430 --> 00:08:38,290 Nice and simple. 179 00:08:38,570 --> 00:08:40,590 Let's have a quick look at how that works. 180 00:08:40,590 --> 00:08:42,230 So we've got a user and an article. 181 00:08:42,230 --> 00:08:45,770 So we'll be looking at a blog post system, for example. 182 00:08:45,830 --> 00:08:49,810 So we've got a user and an article and on this right hand side here we've got a whole jumbled load of mess. 183 00:08:49,810 --> 00:08:52,490 You can see we've got the entity ID, the second column. 184 00:08:52,590 --> 00:08:58,170 So the first, second, and the last two rows in the attribute table belong to a user. 185 00:08:58,770 --> 00:09:06,030 And because the second column has number twos in it, the third and fourth rows belong to an article. 186 00:09:06,050 --> 00:09:10,150 So you can see the user's username is Robin and the user's password is password. 187 00:09:10,350 --> 00:09:18,230 Down there we have username Morgan and password, for some reason they like using JSON Web Tokens for their passwords, but that's their password. 188 00:09:18,870 --> 00:09:24,010 And then in the middle through there you can see that we've got an article, one article, instance ID of the article is one. 189 00:09:24,010 --> 00:09:29,550 We've got a title of Rebec for the win and content is can has FGA, fine grained access control. 190 00:09:30,090 --> 00:09:45,150 So now if we want to pull stuff out we can use a fairly simple-ish join within an SQL table to say, well, pull all these things out and I can pull out, for example, get me all of the articles that you have. 191 00:09:45,250 --> 00:09:47,310 Give me the title and the content. 192 00:09:47,310 --> 00:09:53,030 Or maybe rather than getting information about one entity you can say give me a list of all the users and just give me their usernames. 193 00:09:53,150 --> 00:10:03,990 So this table set up basically allows you to get really varied views across the data you have without having to change your database schema, without having to know what that schema looks like to start with. 194 00:10:04,170 --> 00:10:07,990 And you can store arbitrary data in there and pull it out in whichever way you want. 195 00:10:08,270 --> 00:10:11,110 It's complicated and expensive to pull out. 196 00:10:11,410 --> 00:10:19,230 And it's somewhat complicated to set up and use within more so than if you had like an article table and a user table and a comment table. 197 00:10:19,450 --> 00:10:32,930 So if we want to add a comment, for example, we just add an extra row over there and then we can add some extra columns here saying, okay, so we've now got this entity ID3, instance ID1, this is comment number one, the article ID is number one, author is Sam, 198 00:10:32,930 --> 00:10:35,070 comment was first and here's the date Sam. 199 00:10:35,370 --> 00:10:40,430 So without making any database schema change, I've added a whole new entity to the system. 200 00:10:41,250 --> 00:10:47,670 The only reason I tell you about EAV is because this is very similar to the way that Reback is managed under the hood. 201 00:10:47,950 --> 00:10:49,550 So let's have a look at how that works. 202 00:10:49,810 --> 00:10:55,650 We've got entities on the left-hand side, Robin is a user, Acme Co is an organization and Reback for the win is an article. 203 00:10:57,150 --> 00:10:58,930 And down here we have some relationships. 204 00:10:59,230 --> 00:11:08,790 So we're now looking at just subject ID and I apologize for the color scheme, we've got a relationship ID which is just arbitrary for this table, we've got a subject entity ID and an object entity ID. 205 00:11:08,790 --> 00:11:11,130 So how does a subject relate to an entity? 206 00:11:11,630 --> 00:11:15,590 A subject is an entity, it's just a primary entity within a relationship. 207 00:11:15,650 --> 00:11:22,530 So we're saying subject one, the user, entity ID three, the article, relationship type is owner. 208 00:11:22,850 --> 00:11:26,530 Therefore we know that Robin is the owner of the Reback for the win article. 209 00:11:27,930 --> 00:11:33,910 We can then add in that Robin, user one, is a member of organization Acme Co. 210 00:11:34,790 --> 00:11:41,430 And we can add in that Morgan, user four, is a member of the organization Acme Co as well. 211 00:11:41,510 --> 00:11:45,510 So we now know that both Robin and Morgan are members of Acme Co. 212 00:11:45,510 --> 00:11:50,930 Now we have another one here where we say the organization is a viewer of the Reback article. 213 00:11:50,990 --> 00:11:53,230 But organizations can't view things. 214 00:11:53,850 --> 00:11:57,470 So we're able to extend that slightly and put an extra entity relation on there. 215 00:11:57,470 --> 00:11:59,570 How do the entities relate to each other ? 216 00:11:59,590 --> 00:12:01,890 Through this member relation. 217 00:12:02,210 --> 00:12:09,710 So if we dial that back, if we see here we've got member in the middle two rows here, we've got a relationship of members. 218 00:12:09,710 --> 00:12:19,050 So what we now know is that members of organization two can view the Reback for the win article. 219 00:12:19,670 --> 00:12:26,350 So now if I add another member into that organization, they automatically inherit that because the relationship exists already. 220 00:12:26,890 --> 00:12:27,710 Does that make sense? 221 00:12:28,370 --> 00:12:30,190 This is where it gets a little bit murky. 222 00:12:30,470 --> 00:12:31,530 You don't need to know all of this. 223 00:12:31,530 --> 00:12:36,510 I just want you to understand how the data sits in there so that when we start pulling it out, you can see what's going on. 224 00:12:37,330 --> 00:12:41,750 So the other thing we can do is define permissions on all of these. 225 00:12:41,750 --> 00:12:44,570 So we've got the relationships, but what does that actually mean they can do? 226 00:12:44,710 --> 00:12:50,530 So permission ID one, again, arbitrarily for the permissions table, relates to relationship ID one. 227 00:12:50,530 --> 00:12:54,710 So relationship ID one was Robin is the owner of the Reback article. 228 00:12:55,130 --> 00:12:58,310 So we're saying here, well, one of the permissions is read. 229 00:12:59,850 --> 00:13:05,570 Relationship ID one is also that Robin is the owner of the article. 230 00:13:05,830 --> 00:13:07,590 Robin also has write access. 231 00:13:08,230 --> 00:13:19,410 And then we have relationship ID four, which is this, this inferred down here, members of organization two, members of organization two have read permissions. 232 00:13:20,170 --> 00:13:24,790 So even over here we've got relationship types and entities like viewer is just a label. 233 00:13:24,790 --> 00:13:26,710 It doesn't mean anything to the system. 234 00:13:26,710 --> 00:13:36,670 But when you look at that, you see what that means is the permission for viewer for any member of organization two has read access on article one. 235 00:13:37,710 --> 00:13:48,950 So there's one extra table here compared to the AV, but this allows us to define a multitude of relationships and permissions and how they relate to each other and to other entities . 236 00:13:49,170 --> 00:13:51,810 And more importantly, they allow you to chain those identities. 237 00:13:51,810 --> 00:13:56,430 Remember how we went from Liam to the mad scientist to the farmer to the sheep to the bone? 238 00:13:56,770 --> 00:13:58,130 It's not just one-to-one. 239 00:13:58,130 --> 00:14:02,850 You can define these huge big chains and if any part of that chain gets broken, then the relationship breaks. 240 00:14:04,030 --> 00:14:07,270 So querying the Reback model, how does this work? 241 00:14:07,490 --> 00:14:11,150 Let's say we come in here and we want to find out who can read. 242 00:14:11,630 --> 00:14:17,250 We can see here that the read, sorry, who can write, the permission ID there is two. 243 00:14:18,510 --> 00:14:20,990 So if we... 244 00:14:26,100 --> 00:14:28,560 I think I've got the wrong one highlighted there. 245 00:14:28,620 --> 00:14:31,520 I want to find out who can write to Reback article two. 246 00:14:32,000 --> 00:14:39,720 So first thing we do is we look at the, and the highlighting isn't working so great here, the object entity ID three there is the Reback article. 247 00:14:39,720 --> 00:14:43,400 So we say, okay, within the relationships, let's find out everything we know about the article. 248 00:14:43,540 --> 00:14:51,940 And we can see here that the fourth one there can be excluded straight away because the relationship ID number four is not in the permissions table. 249 00:14:53,000 --> 00:14:56,140 However, relationship ID one is in that table. 250 00:14:56,140 --> 00:14:59,300 That is related to the object identity two. 251 00:14:59,300 --> 00:15:04,940 So we can pull out the user Robin has write access to the article. 252 00:15:05,180 --> 00:15:07,700 So you can look at things in other directions as well. 253 00:15:08,200 --> 00:15:13,100 And then further to that, you could even say, okay, well, tell me everything about the article rather than starting from the permissions. 254 00:15:13,100 --> 00:15:14,560 We look at article number three. 255 00:15:14,820 --> 00:15:19,020 We know that Robin is the owner of that article already. 256 00:15:20,120 --> 00:15:28,920 And if we look at the viewer here, we can then, and this is what I was talking about before, how member gets extrapolated to infer relationship status. 257 00:15:28,920 --> 00:15:35,680 So we can see that the member here of organization two has access to the article. 258 00:15:35,860 --> 00:15:42,240 And if we then fold those in, you see how before this one here was highlighted, what we're now doing is saying the subject is now the object. 259 00:15:42,240 --> 00:15:50,240 So where the object is now entity ID two, where also the relationship type is member, that's where this one basically gets folded out. 260 00:15:50,360 --> 00:15:52,940 So that's probably one of the most complicated lookups. 261 00:15:53,020 --> 00:15:58,640 It's really diving straight into the depths of the Reback schema. 262 00:15:58,640 --> 00:16:09,140 But essentially what we're doing there at that point is we're saying this permission or this relationship here doesn't make sense from a permission sense because you don't give permissions to inanimate objects like organizations necessarily. 263 00:16:09,140 --> 00:16:10,200 I mean, you do. 264 00:16:10,200 --> 00:16:12,340 But that doesn't really help an end user. 265 00:16:12,340 --> 00:16:18,660 How do we then unfold that and then extrapolate that to refer to the actual user entities? 266 00:16:19,080 --> 00:16:23,380 And this is where it gets complicated because Reback, as I said, doesn't have a concept of a user necessarily. 267 00:16:23,380 --> 00:16:29,300 You could actually ask Reback what is the relationship between this organization and that network. 268 00:16:29,560 --> 00:16:30,900 Neither of them really do anything. 269 00:16:30,900 --> 00:16:31,840 They're system entities. 270 00:16:31,840 --> 00:16:32,980 They're not user entities. 271 00:16:32,980 --> 00:16:34,480 But they still have relationships. 272 00:16:34,480 --> 00:16:36,800 So it's powerful, but also complex. 273 00:16:37,600 --> 00:16:41,280 So implementation details. 274 00:16:43,220 --> 00:16:49,660 Let's have a think about how we might do something in code, which is probably the way most of us do the more complicated business logic like this. 275 00:16:49,800 --> 00:17:05,400 So if we want to allow editing an article, if a user is an admin or an editor, if an editor is allowed to edit this particular article, if the article is sensitive, then we also want to make sure that the person is on site and we want to make sure that they're doing it during office hours. 276 00:17:06,380 --> 00:17:11,180 Seems like a fairly robust kind of setup that you might have in a large organization. 277 00:17:11,660 --> 00:17:12,560 So if. 278 00:17:13,020 --> 00:17:15,420 If the user is admin or if the user is editor. 279 00:17:15,700 --> 00:17:16,300 Cool. 280 00:17:16,480 --> 00:17:20,060 So we know what role the user has. 281 00:17:20,600 --> 00:17:25,380 Also, if the user is an editor and the list of document editors contains the current user. 282 00:17:25,440 --> 00:17:27,820 So we don't want any editor to be able to edit this. 283 00:17:28,060 --> 00:17:32,240 Only if the list of editors for this particular article includes the current user. 284 00:17:32,680 --> 00:17:34,240 So we can compound those two together. 285 00:17:34,940 --> 00:17:38,660 Then also we want to say, well, if the document isn't sensitive, then we can carry on. 286 00:17:38,700 --> 00:17:47,180 Otherwise, we're going to check to see if the user's location is on premises or if the user's location is currently in office hours. 287 00:17:47,180 --> 00:17:52,320 And I say the user's location because in a world like today, who knows when it's 9 to 5 for somebody. 288 00:17:52,460 --> 00:18:02,700 So as long as it's within the location they're in, it's working hours and they're on premises or the document is not sensitive and they meet the user requirements, they're going to get access to this document. 289 00:18:03,820 --> 00:18:06,640 Imagine if you had to come back and change those rules three months later. 290 00:18:08,780 --> 00:18:15,780 So instead what we're going to do is we're going to define entities within our relationship-based access management tool of choice. 291 00:18:16,080 --> 00:18:17,480 We're going to define a document. 292 00:18:17,700 --> 00:18:19,440 The document has an owner and an editor. 293 00:18:19,440 --> 00:18:26,020 The owner is a user and the editor is a member of an organization with the member type editor. 294 00:18:26,400 --> 00:18:29,140 So you can have different types of people within groups. 295 00:18:29,940 --> 00:18:31,560 And then we're going to have a sensitive document. 296 00:18:31,560 --> 00:18:33,320 So that's the definition of a normal document. 297 00:18:33,380 --> 00:18:36,020 A sensitive document is going to extend document. 298 00:18:36,800 --> 00:18:45,160 It's also going to have an edit action on it that says if it's within working hours and the document ‑‑ it's the document owner who's trying to do this action . 299 00:18:45,160 --> 00:18:49,040 Because remember, we're defining actions on an entity and who's allowed to perform it. 300 00:18:49,200 --> 00:18:52,080 So can edit be done on a sensitive document? 301 00:18:52,080 --> 00:18:57,020 Yes, you can if you are the document owner and you are the document owner and you're on premises. 302 00:18:57,960 --> 00:19:00,240 Or if you're an editor and you're on premises. 303 00:19:00,900 --> 00:19:06,480 So this gets tied into your relationship-based access model schema and permission systems. 304 00:19:06,480 --> 00:19:10,060 So now your code can change from this to that. 305 00:19:11,380 --> 00:19:20,100 And now your business logic isn't restricted or it doesn't include the permissions check because there's no real reason for that to be there. 306 00:19:20,100 --> 00:19:26,040 The permission for who should access an entity within your system should not be dependent on what's in the business logic. 307 00:19:26,040 --> 00:19:28,260 There's a fast and firm rule for that. 308 00:19:28,300 --> 00:19:29,960 This gives you two benefits. 309 00:19:29,960 --> 00:19:32,900 One from a clean code, easy to read perspective. 310 00:19:32,900 --> 00:19:34,420 That is much easier to read. 311 00:19:34,420 --> 00:19:35,760 You know exactly what's going to happen. 312 00:19:35,760 --> 00:19:37,320 You don't have to think about it. 313 00:19:37,620 --> 00:19:49,580 Also from a permissions and access control management perspective, your security team can manage the rules and the schema separately from your development team and it puts the responsibility in the right place. 314 00:19:51,680 --> 00:19:53,360 So demo time. 315 00:19:53,580 --> 00:19:54,480 This is the fun part. 316 00:19:54,480 --> 00:19:57,180 So the first part was all about dogs. 317 00:19:57,180 --> 00:20:01,700 Then we went to document access management which is important but boring. 318 00:20:01,700 --> 00:20:03,140 So we're going to go back to dogs. 319 00:20:03,740 --> 00:20:06,400 I have tried a number of products. 320 00:20:06,400 --> 00:20:08,500 There are all these products up on the screen here. 321 00:20:08,500 --> 00:20:09,360 There are many more. 322 00:20:09,360 --> 00:20:12,540 These are relationship-based access management tools. 323 00:20:12,540 --> 00:20:14,160 Some of them are open source and free to use. 324 00:20:14,160 --> 00:20:15,220 Some of them are paid for. 325 00:20:15,220 --> 00:20:17,600 I'm going to be using Permify in this demo. 326 00:20:18,720 --> 00:20:24,340 And I'm not going to annoy anybody by switching over to this on the AV team because they didn't mic check me on this one. 327 00:20:24,340 --> 00:20:25,620 So I apologize in advance. 328 00:20:25,620 --> 00:20:26,920 But I'm going to need both hands. 329 00:20:27,620 --> 00:20:30,080 So I'm just going to stop screen sharing. 330 00:20:32,060 --> 00:20:36,480 Let's jump over here and we're going to have a first look at Postman. 331 00:20:37,080 --> 00:20:38,980 So let's make this a bit bigger. 332 00:20:39,840 --> 00:20:41,560 Can you all read that okay? 333 00:20:41,740 --> 00:20:42,540 Excellent. 334 00:20:42,900 --> 00:20:45,680 So let's have a look from the beginning. 335 00:20:45,680 --> 00:20:47,420 We're going to create a tenant. 336 00:20:47,420 --> 00:20:56,060 In fact, the first thing I'm going to do, because like all developers, I decided to test this before I started the talk. 337 00:20:56,060 --> 00:20:57,980 So I'm just going to restart Permify in the background. 338 00:20:57,980 --> 00:20:59,500 So we're starting from a bank slate. 339 00:20:59,860 --> 00:21:03,660 So now over here what we're going to do is we're going to create a new tenant. 340 00:21:03,660 --> 00:21:06,000 So Permify allows you to have multiple tenants in your system. 341 00:21:06,000 --> 00:21:14,140 So you can sandbox or isolate certain areas of your organization or even certain organizations within a larger system. 342 00:21:14,840 --> 00:21:20,500 So we're going to create a tenant over here called Dog and Bone. 343 00:21:20,960 --> 00:21:28,040 If I hit send on that, we'll see down here that we get a positive response back, a 200, and we've got our tenant. 344 00:21:28,040 --> 00:21:30,180 So the next thing I'm going to do is create the schema. 345 00:21:30,220 --> 00:21:35,120 Now this schema, for some reason, Permify wants it in a single string. 346 00:21:35,580 --> 00:21:39,100 So to make it easier, I have it over here. 347 00:21:41,240 --> 00:21:43,260 And this is very similar to what we saw in the slides. 348 00:21:43,260 --> 00:21:45,080 Basically we've got a definition of a dog. 349 00:21:45,280 --> 00:21:47,180 A dog has an owner, which is a person. 350 00:21:47,440 --> 00:21:48,280 We've got a sheep. 351 00:21:48,280 --> 00:21:50,340 A sheep has an owner that is also a person. 352 00:21:50,480 --> 00:21:53,200 A sheep also has a bone, which is an entity type bone. 353 00:21:53,580 --> 00:21:54,580 We've got a person. 354 00:21:54,720 --> 00:21:56,980 A person can have a friend, would be another person. 355 00:21:57,300 --> 00:21:59,500 A person can also have sheep and a person can have dogs. 356 00:21:59,680 --> 00:22:02,700 So we've got bidirectional rules here. 357 00:22:02,700 --> 00:22:05,440 And then we've got a relationship between the bone. 358 00:22:05,440 --> 00:22:07,340 The bone has an owner, and that's a sheep. 359 00:22:07,340 --> 00:22:08,300 And then we've got a permission. 360 00:22:08,300 --> 00:22:11,140 Can the owner's friend's dog eat? 361 00:22:11,900 --> 00:22:16,880 And eat is true if that comes out as a relationship that exists. 362 00:22:17,720 --> 00:22:24,220 So let's submit that through and we should find that that has now worked. 363 00:22:24,220 --> 00:22:25,560 If I now create some 364 00:22:28,720 --> 00:22:29,040 relationships... 365 00:22:29,040 --> 00:22:30,280 come on, get bigger. 366 00:22:32,760 --> 00:22:33,680 Where's the handle? 367 00:22:34,260 --> 00:22:35,200 It's always hiding. 368 00:22:38,660 --> 00:22:40,640 I'll just scroll through this a little by little. 369 00:22:41,760 --> 00:22:44,820 Actually if I make this slightly smaller, is that still readable at the back? 370 00:22:45,560 --> 00:22:46,420 Yep, okay. 371 00:22:46,580 --> 00:22:47,940 So at least we can see a bit more at a time. 372 00:22:47,940 --> 00:22:50,840 So we can see here we've got a relationship between a subject and an entity. 373 00:22:51,000 --> 00:22:55,080 Remember I said a subject is also an entity, but it's just the primary entity in a relationship. 374 00:22:55,200 --> 00:22:56,320 Is the microphone cutting in? 375 00:22:56,600 --> 00:22:57,620 A little? 376 00:22:57,800 --> 00:22:59,200 I'll go back to this one. 377 00:22:59,480 --> 00:23:01,240 Because I don't need to type as much now. 378 00:23:01,240 --> 00:23:05,380 So we can see the subject, mad scientist, is the owner of Shadow the Dog. 379 00:23:05,480 --> 00:23:09,680 We can see here that Shadow the Dog is also a dog belonging to the scientist. 380 00:23:10,040 --> 00:23:12,660 And then we've got the farmer has Dolly the sheep. 381 00:23:12,860 --> 00:23:14,700 The sheep belongs to the farmer. 382 00:23:14,860 --> 00:23:19,460 And we've got Dolly is a sheep to the femur. 383 00:23:19,700 --> 00:23:22,680 And the femur is a bone to the sheep. 384 00:23:23,060 --> 00:23:25,200 So we've got these relationships built up now. 385 00:23:25,400 --> 00:23:37,860 So if I come through and I ask what friends does the scientist have, because we haven't defined those relationships yet, if I execute that, we'll see down here that the result is nothing. 386 00:23:37,860 --> 00:23:39,840 We have no, he has no friends. 387 00:23:39,840 --> 00:23:41,340 He's a sad scientist. 388 00:23:41,700 --> 00:23:44,800 As it happens, the farmer is also a sad farmer. 389 00:23:44,900 --> 00:23:48,300 Although the farmer has sheep, so a little bit happier, probably. 390 00:23:48,840 --> 00:23:50,340 I know, sheep are better than dogs. 391 00:23:50,360 --> 00:23:51,820 I digress yet again. 392 00:23:51,820 --> 00:23:53,480 So can Shadow eat the bone? 393 00:23:53,480 --> 00:23:54,440 What do we reckon? 394 00:23:56,100 --> 00:23:56,740 No. 395 00:23:56,740 --> 00:23:58,340 So if I hit that, it comes through. 396 00:23:58,460 --> 00:23:59,460 Result denied. 397 00:23:59,860 --> 00:24:07,880 So it's a very low energy kind of reaction that I'm getting. 398 00:24:07,880 --> 00:24:09,980 But it's also a very low energy kind of output. 399 00:24:10,000 --> 00:24:13,640 So I thought I've got these two requests here that I can make. 400 00:24:13,640 --> 00:24:16,860 The first one calls data right. 401 00:24:17,360 --> 00:24:21,100 What I'm going to do is I'm going to say, okay, the mad scientist is now friends with the farmer. 402 00:24:21,320 --> 00:24:23,420 And then I've got another one here, break friends. 403 00:24:23,600 --> 00:24:24,780 It's data delete. 404 00:24:24,780 --> 00:24:28,240 And in here I'm defining the mad scientist is no longer a friend with the farmer. 405 00:24:28,260 --> 00:24:38,660 So to make this a little more exciting, I decided to show you all my sister's Facebook page. 406 00:24:39,460 --> 00:24:41,820 And also let's bring this back in over here. 407 00:24:42,440 --> 00:24:44,040 I have a dog and a bone. 408 00:24:44,060 --> 00:24:47,760 Let's just refresh this, because it doesn't like having the lid shut on it. 409 00:24:48,480 --> 00:24:51,260 And for some reason I'm getting an image rendering error. 410 00:24:51,260 --> 00:24:52,200 There we go. 411 00:24:52,340 --> 00:24:53,740 What demos go perfectly. 412 00:24:53,740 --> 00:24:55,200 So doors closed. 413 00:24:55,200 --> 00:24:56,440 Dog can't get a bone. 414 00:24:56,440 --> 00:25:03,580 So what happens if the farmer makes friends with the scientist? 415 00:25:03,580 --> 00:25:04,480 What do you think? 416 00:25:09,000 --> 00:25:10,540 No, it didn't work. 417 00:25:11,900 --> 00:25:13,660 Did I call the right one there? 418 00:25:13,800 --> 00:25:15,340 Looks like you're offline. 419 00:25:15,340 --> 00:25:17,160 Yeah, but I'm doing everything locally. 420 00:25:17,640 --> 00:25:19,960 So did 421 00:25:23,920 --> 00:25:25,060 I call the wrong one? 422 00:25:25,180 --> 00:25:26,660 Did I call break friends? 423 00:25:26,680 --> 00:25:28,640 Let's double click on that one. 424 00:25:31,980 --> 00:25:33,020 Darn it. 425 00:25:33,460 --> 00:25:45,100 Well, I will show you that if we come over here and look at friends of mad scientist, we should now have, there we go, the friendship is now in here. 426 00:25:45,100 --> 00:25:50,520 So now if I call can shadow eat the bone, it comes back as still denied. 427 00:25:50,800 --> 00:25:52,720 So this is where the demo fails. 428 00:25:52,720 --> 00:25:55,120 I'm more than happy to work out why the demo failed. 429 00:25:55,120 --> 00:26:00,900 It was probably something to do with keeping my Wi-Fi off at DEF CON and closing my laptop lid between testing demos. 430 00:26:01,200 --> 00:26:02,460 But the theory is there. 431 00:26:02,460 --> 00:26:04,460 The results should have come back immediately. 432 00:26:04,460 --> 00:26:06,600 I had a little bit of a cheat in my app. 433 00:26:06,600 --> 00:26:08,220 It was basically polling every second. 434 00:26:08,640 --> 00:26:13,700 But there are plenty of ways of connecting to databases and getting a full time stream of data back. 435 00:26:13,700 --> 00:26:21,500 So you can get almost like a push notification or an immediate notification of permission changes if that's something you need in your environment. 436 00:26:21,500 --> 00:26:27,100 Most of the time it's probably something you only need every time you make a request to make sure that request should be honored. 437 00:26:28,160 --> 00:26:42,440 But one of the things that I want to caution is that while this is complicated and exciting and perhaps when it comes to permission systems, dare I say a little bit sexy, I'm not sure, it's not always the right solution. 438 00:26:42,440 --> 00:26:48,240 As I said, there's a lot more computation power required for doing things like checking whether or not a permission should be granted. 439 00:26:48,420 --> 00:26:51,320 Role based access control is always going to be your easiest. 440 00:26:51,320 --> 00:26:54,720 That's always simply like, is this person an admin, yes or no? 441 00:26:55,040 --> 00:27:01,360 In fact, in some situations, if you think of your home internet router, you don't even have permission systems like are they logged in, yes or no? 442 00:27:01,460 --> 00:27:03,000 That's technically the simplest. 443 00:27:03,520 --> 00:27:14,200 So work out which level of permissions complexity or the way that your data is modeled and how you want to define whether or not access should be allowed. 444 00:27:14,400 --> 00:27:19,080 Work out what level of complexity you can get to at a minimum while still meeting your requirements. 445 00:27:19,080 --> 00:27:23,940 Because if you go for the full thing, straight out, re-back all the way, baby, absolutely it's fun. 446 00:27:24,340 --> 00:27:28,360 You will probably create a situation where your job is now indispensable. 447 00:27:28,460 --> 00:27:31,540 You will not be fired because nobody knows what the hell you did. 448 00:27:31,880 --> 00:27:33,920 But it's not always the right solution, okay? 449 00:27:33,920 --> 00:27:35,040 Pick the right one for you. 450 00:27:35,040 --> 00:27:44,260 If you are currently going through a situation where you want to implement some kind of permission control, more than welcome to come up and talk to me afterwards and tell me a story. 451 00:27:44,260 --> 00:27:48,560 I'll let you know if I've got any clue at all as to what you may or may not consider. 452 00:27:49,080 --> 00:27:56,380 I'm certainly not going to tell you I know your system inside out and can tell you what the answer is, but I'm happy to have a chat and go through that with you. 453 00:27:56,540 --> 00:28:01,040 But I would like to finish by just saying thank you. 454 00:28:01,180 --> 00:28:02,960 If I can even find my slides. 455 00:28:06,830 --> 00:28:08,450 Let's just get that back up there. 456 00:28:08,510 --> 00:28:11,430 So again, that's my contact details at the top there. 457 00:28:11,890 --> 00:28:13,770 ArcJet are currently running a contest. 458 00:28:13,770 --> 00:28:17,730 If you want to try our product out, there's some prizes we're giving away as well. 459 00:28:17,730 --> 00:28:18,950 Challenge.arcjet.com. 460 00:28:18,950 --> 00:28:19,510 Give it a try. 461 00:28:19,510 --> 00:28:20,150 Let us know. 462 00:28:20,150 --> 00:28:28,590 We would really love to know from you how you find the product, how easy it is to use, and what we can do to make it easier for you to make your websites better. 463 00:28:29,010 --> 00:28:30,810 But this talk was about permission systems. 464 00:28:30,810 --> 00:28:31,730 Come talk to me. 465 00:28:31,750 --> 00:28:32,450 Thank you for your time. 466 00:28:32,450 --> 00:28:34,230 Have a great rest of your DEF CON. 467 00:28:34,230 --> 00:28:34,810 Thanks.