WEBVTT

00:00.000 --> 00:01.380
All right.

00:01.500 --> 00:05.420
So with that in mind, welcome to the stage, Ben.

00:06.280 --> 00:07.620
Thank you.

00:09.240 --> 00:10.540
Hello, everyone.

00:11.180 --> 00:14.980
I'm going to be that annoying guy for the person behind the camera.

00:14.980 --> 00:17.700
I like moving a lot, hence I've got the handheld.

00:17.740 --> 00:20.160
I don't like to be stuck behind a podium .

00:20.400 --> 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.

00:26.800 --> 00:31.200
Who here is familiar with access control within web applications in some way or form?

00:31.280 --> 00:32.060
About half of you.

00:32.060 --> 00:32.460
That's cool.

00:32.460 --> 00:33.960
Who knows what RBAC is?

00:34.460 --> 00:35.180
ABAC?

00:35.800 --> 00:36.520
Rebac?

00:37.040 --> 00:37.580
Cool.

00:38.560 --> 00:39.920
Increasingly dropping numbers of hands.

00:39.920 --> 00:40.940
That's kind of what I expected.

00:40.940 --> 00:43.480
I think we've got about 10% people here who know Rebac.

00:43.480 --> 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.

00:47.380 --> 00:50.240
Now, normally this is a 45 -minute to one-hour conversation.

00:50.560 --> 00:55.000
So excuse me if I skip over some bits, but please come and ask me questions afterwards.

00:55.000 --> 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.

01:05.800 --> 01:07.140
It's not always the right solution.

01:07.520 --> 01:08.420
But who am I?

01:08.480 --> 01:12.700
I'm a guy who develops slides that have really bad contrast on LED screens.

01:12.840 --> 01:16.040
Also, I've been a software engineer for too many years.

01:16.040 --> 01:17.620
I used to put the number up there.

01:17.620 --> 01:19.740
It made me feel old, so now I just do a sentence.

01:19.740 --> 01:21.060
You can do the maths in your head.

01:21.220 --> 01:24.060
I love working with developer and open source communities.

01:24.060 --> 01:25.900
I've been doing that for about 20 years.

01:26.020 --> 01:28.680
I'm really passionate about security and privacy.

01:28.720 --> 01:31.100
If you want to talk to me about any of those things, those are my jam.

01:31.100 --> 01:32.280
Come talk to me afterwards.

01:32.740 --> 01:39.100
I'm currently working as a developer advocate for a company called ArcJet, hence the branding across my chest here.

01:39.100 --> 01:42.740
We're a middleware security solution for your web applications.

01:42.820 --> 01:47.020
If you are writing any kind of web application at all, check out ArcJet.com and just plug it in.

01:47.020 --> 01:47.660
It's free.

01:47.660 --> 01:48.220
Give it a try.

01:48.220 --> 01:49.680
We'd love to hear what you think about it.

01:50.420 --> 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.

01:55.000 --> 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.

02:06.100 --> 02:08.380
So my Twitter handle is at BenDekarai.

02:08.380 --> 02:09.680
My DMs are open.

02:09.680 --> 02:10.800
Contact me.

02:11.320 --> 02:12.060
If you like.

02:12.060 --> 02:13.380
It's not an instruction.

02:13.380 --> 02:14.860
It's an offer.

02:15.120 --> 02:16.060
So let's get into it.

02:16.060 --> 02:17.260
Access Control 101.

02:17.260 --> 02:18.660
Basics and understandings thereof.

02:18.660 --> 02:23.400
First thing we're going to have a look at is the caricatures we're going to be looking at.

02:23.420 --> 02:25.960
So whenever it comes to access control, the dog wants the bone, right?

02:26.020 --> 02:29.800
So we're going to look at ways that we can stop or allow the dog from accessing the bone.

02:29.820 --> 02:32.520
First one is going to be using RBAC, Role-Based Access Control.

02:32.580 --> 02:36.860
It's probably one of the simplest access control mechanisms, so we'll skip through this very quickly.

02:36.880 --> 02:38.520
Basically, we have a number of roles.

02:38.580 --> 02:41.060
You've got an admin, you've got a manager, employee, and a guest.

02:41.060 --> 02:43.260
And in our case, our dog, this is Shadow.

02:43.680 --> 02:45.180
Shadow has a blue hat on.

02:45.180 --> 02:46.620
Blue hats are employees.

02:46.940 --> 02:50.560
And the door is locked to all but the admins, managers, and employees.

02:50.560 --> 02:52.640
We don't want guest dogs getting to the bones.

02:52.640 --> 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.

02:59.800 --> 03:02.900
So because Shadow has access, the door opens.

03:03.000 --> 03:03.980
Role-Based Access Control.

03:03.980 --> 03:04.900
Nice and simple.

03:05.720 --> 03:08.440
Next one, Attribute-Based Access Control.

03:08.440 --> 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.

03:14.820 --> 03:17.180
So we've got four attributes here of the dog.

03:17.180 --> 03:18.040
This is Min.

03:18.060 --> 03:20.680
This is a white Siberian husky.

03:20.680 --> 03:22.320
These are actual real dogs in my life.

03:22.320 --> 03:24.240
I like to relay them into my talks.

03:24.440 --> 03:25.640
There are four characteristics.

03:25.640 --> 03:27.800
Service dog, good boy, loyal, and fierce.

03:27.800 --> 03:32.200
I can tell you while Shadow is a service dog, Min will never be a service dog.

03:32.200 --> 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.

03:36.660 --> 03:38.700
So she will never ever be a service dog.

03:38.700 --> 03:42.000
But she is usually a good boy or a loyal.

03:42.000 --> 03:43.220
She is not fierce.

03:43.560 --> 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.

03:49.340 --> 03:52.440
Now, as an aside, I go on tangents occasionally.

03:52.580 --> 03:56.260
You might be asking yourself, but why doesn't a service dog get a bone?

03:56.260 --> 03:57.560
Because a service dog is good, right?

03:57.560 --> 03:59.700
Service dogs deserve bones.

03:59.800 --> 04:01.080
Anybody agree with that?

04:01.560 --> 04:02.400
Nobody agrees with that?

04:02.400 --> 04:03.440
You all hate service dogs.

04:03.440 --> 04:04.600
That's what I'm learning about you lot.

04:04.600 --> 04:05.220
Jesus.

04:05.480 --> 04:06.500
Rough crowd.

04:07.060 --> 04:08.360
No, service dogs are working.

04:08.360 --> 04:09.320
They don't get to eat.

04:09.680 --> 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?

04:14.220 --> 04:16.600
The attribute here we're going to put in is time.

04:16.600 --> 04:17.880
Who does have a dog?

04:19.200 --> 04:19.980
Wrong audience.

04:19.980 --> 04:21.100
Who has cats?

04:21.740 --> 04:22.140
Okay.

04:22.140 --> 04:24.280
Let's pretend your cat likes eating bones.

04:25.180 --> 04:26.900
Or for those of you who have dogs.

04:27.420 --> 04:31.400
Who lets their dog sleep in their bedroom with them at night?

04:31.400 --> 04:35.200
Who would like the sound of a crunching bone at 3 a.m.?

04:35.200 --> 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.

04:40.660 --> 04:42.340
to 9 a.m., no bone for you.

04:42.500 --> 04:44.740
So sadly, men get no bone.

04:45.960 --> 04:48.260
But there are plenty of other things we can do attributes on.

04:48.260 --> 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.

04:54.380 --> 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 .

05:00.620 --> 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.

05:07.220 --> 05:11.020
And this changes the paradigm quite significantly as I lose my balance.

05:11.500 --> 05:15.520
So this dog doesn't actually have a name.

05:15.540 --> 05:16.900
Who here had a dog?

05:17.280 --> 05:18.360
What was your dog's name?

05:18.580 --> 05:19.040
Liam.

05:19.040 --> 05:19.900
This is Liam.

05:19.900 --> 05:20.580
Thank you.

05:20.580 --> 05:22.260
Liam is actually a dog.

05:22.260 --> 05:23.880
Dali designed Liam.

05:24.060 --> 05:27.520
I thought it came out a little bit like a cat, but that's what we're going with.

05:27.580 --> 05:30.020
So Liam has an owner.

05:30.280 --> 05:31.520
You are the mad scientist.

05:31.520 --> 05:32.240
Congratulations.

05:32.720 --> 05:34.380
So Liam's owner is a mad scientist.

05:34.380 --> 05:36.880
The mad scientist is friends with a farmer.

05:36.880 --> 05:38.420
The farmer has a whole lot of sheep.

05:38.420 --> 05:41.460
And for the vegetarians in the audience, I apologize, but sheep have bones.

05:43.920 --> 05:44.800
Ten minutes?

05:45.760 --> 05:46.980
Oh, I need to stay back.

05:46.980 --> 05:49.980
This is not good for me because, A, I'm going to fall off the back of the stage.

05:50.140 --> 05:50.940
Not too far.

05:50.940 --> 05:51.320
Okay.

05:51.320 --> 05:52.200
Just right here.

05:52.200 --> 05:52.720
Okay.

05:53.040 --> 05:55.780
The guy who likes to roam may no longer roam.

05:55.820 --> 05:56.600
That's okay.

05:57.140 --> 06:01.080
So we have this chain of relationships, as you can see.

06:01.100 --> 06:08.000
So we can see here that Liam may or may not have access to the rules that you can see.

06:08.400 --> 06:09.520
Now I'm getting feedback.

06:09.600 --> 06:11.560
Based on the rules you can see on the door there.

06:11.940 --> 06:13.320
Oh, sorry.

06:13.320 --> 06:14.520
Let's just zoom in a little bit.

06:14.520 --> 06:16.280
The rules you can see on the door there.

06:16.740 --> 06:21.560
So with relationship-based access control, we don't actually have a concept of users anymore.

06:21.560 --> 06:28.310
We just have a concept of entities and relationships.

06:33.110 --> 06:33.990
Entities and relationships.

06:33.990 --> 06:37.590
I'll keep going unless they actually stop me or unless too many people in the audience cringe.

06:38.430 --> 06:39.850
So here we've got an action.

06:39.850 --> 06:42.210
Can the action eat be completed on the bone?

06:42.650 --> 06:45.550
So note that we're looking here at what can be done to the bone.

06:45.550 --> 06:48.750
We're not looking at what Shadow or Liam can do.

06:49.110 --> 06:52.250
We're looking at what can be done to the bone, what actions can be taken place.

06:52.470 --> 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.

07:00.090 --> 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.

07:06.030 --> 07:07.290
That would be a little bit weird.

07:07.590 --> 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.

07:13.710 --> 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.

07:21.010 --> 07:22.030
Liam gets a bone.

07:22.090 --> 07:23.210
Good for Liam.

07:23.230 --> 07:24.370
So the door opens.

07:24.910 --> 07:30.590
Now, say one day the farmer and the mad scientist break friends.

07:30.630 --> 07:32.010
They're no longer friends with each other.

07:32.010 --> 07:33.450
Suddenly that relationship is broken.

07:33.450 --> 07:36.630
Now, nothing has changed about the bone and nothing has changed about Liam.

07:36.630 --> 07:41.030
But the relationship is broken, therefore the friend component of that rule there breaks.

07:41.130 --> 07:46.170
So the only rule that allowed Liam to get access to that bone is now broken and the door shuts.

07:46.730 --> 07:49.210
So that's what a relationship-based access control is about.

07:49.210 --> 07:53.430
It's not so much about defining what somebody or some user can do.

07:53.430 --> 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.

08:00.710 --> 08:01.630
Does that make sense?

08:02.130 --> 08:02.750
Cool.

08:03.690 --> 08:09.110
So under the hood, who here is familiar with the entity attribute value model of designing?

08:09.190 --> 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,

08:22.490 --> 08:23.950
especially when you have a lot of data.

08:24.190 --> 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.

08:34.350 --> 08:37.390
So if you want to add another entity, it's just another row in a table.

08:37.430 --> 08:38.290
Nice and simple.

08:38.570 --> 08:40.590
Let's have a quick look at how that works.

08:40.590 --> 08:42.230
So we've got a user and an article.

08:42.230 --> 08:45.770
So we'll be looking at a blog post system, for example.

08:45.830 --> 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.

08:49.810 --> 08:52.490
You can see we've got the entity ID, the second column.

08:52.590 --> 08:58.170
So the first, second, and the last two rows in the attribute table belong to a user.

08:58.770 --> 09:06.030
And because the second column has number twos in it, the third and fourth rows belong to an article.

09:06.050 --> 09:10.150
So you can see the user's username is Robin and the user's password is password.

09:10.350 --> 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.

09:18.870 --> 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.

09:24.010 --> 09:29.550
We've got a title of Rebec for the win and content is can has FGA, fine grained access control.

09:30.090 --> 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.

09:45.250 --> 09:47.310
Give me the title and the content.

09:47.310 --> 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.

09:53.150 --> 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.

10:04.170 --> 10:07.990
And you can store arbitrary data in there and pull it out in whichever way you want.

10:08.270 --> 10:11.110
It's complicated and expensive to pull out.

10:11.410 --> 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.

10:19.450 --> 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,

10:32.930 --> 10:35.070
comment was first and here's the date Sam.

10:35.370 --> 10:40.430
So without making any database schema change, I've added a whole new entity to the system.

10:41.250 --> 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.

10:47.950 --> 10:49.550
So let's have a look at how that works.

10:49.810 --> 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.

10:57.150 --> 10:58.930
And down here we have some relationships.

10:59.230 --> 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.

11:08.790 --> 11:11.130
So how does a subject relate to an entity?

11:11.630 --> 11:15.590
A subject is an entity, it's just a primary entity within a relationship.

11:15.650 --> 11:22.530
So we're saying subject one, the user, entity ID three, the article, relationship type is owner.

11:22.850 --> 11:26.530
Therefore we know that Robin is the owner of the Reback for the win article.

11:27.930 --> 11:33.910
We can then add in that Robin, user one, is a member of organization Acme Co.

11:34.790 --> 11:41.430
And we can add in that Morgan, user four, is a member of the organization Acme Co as well.

11:41.510 --> 11:45.510
So we now know that both Robin and Morgan are members of Acme Co.

11:45.510 --> 11:50.930
Now we have another one here where we say the organization is a viewer of the Reback article.

11:50.990 --> 11:53.230
But organizations can't view things.

11:53.850 --> 11:57.470
So we're able to extend that slightly and put an extra entity relation on there.

11:57.470 --> 11:59.570
How do the entities relate to each other ?

11:59.590 --> 12:01.890
Through this member relation.

12:02.210 --> 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.

12:09.710 --> 12:19.050
So what we now know is that members of organization two can view the Reback for the win article.

12:19.670 --> 12:26.350
So now if I add another member into that organization, they automatically inherit that because the relationship exists already.

12:26.890 --> 12:27.710
Does that make sense?

12:28.370 --> 12:30.190
This is where it gets a little bit murky.

12:30.470 --> 12:31.530
You don't need to know all of this.

12:31.530 --> 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.

12:37.330 --> 12:41.750
So the other thing we can do is define permissions on all of these.

12:41.750 --> 12:44.570
So we've got the relationships, but what does that actually mean they can do?

12:44.710 --> 12:50.530
So permission ID one, again, arbitrarily for the permissions table, relates to relationship ID one.

12:50.530 --> 12:54.710
So relationship ID one was Robin is the owner of the Reback article.

12:55.130 --> 12:58.310
So we're saying here, well, one of the permissions is read.

12:59.850 --> 13:05.570
Relationship ID one is also that Robin is the owner of the article.

13:05.830 --> 13:07.590
Robin also has write access.

13:08.230 --> 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.

13:20.170 --> 13:24.790
So even over here we've got relationship types and entities like viewer is just a label.

13:24.790 --> 13:26.710
It doesn't mean anything to the system.

13:26.710 --> 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.

13:37.710 --> 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 .

13:49.170 --> 13:51.810
And more importantly, they allow you to chain those identities.

13:51.810 --> 13:56.430
Remember how we went from Liam to the mad scientist to the farmer to the sheep to the bone?

13:56.770 --> 13:58.130
It's not just one-to-one.

13:58.130 --> 14:02.850
You can define these huge big chains and if any part of that chain gets broken, then the relationship breaks.

14:04.030 --> 14:07.270
So querying the Reback model, how does this work?

14:07.490 --> 14:11.150
Let's say we come in here and we want to find out who can read.

14:11.630 --> 14:17.250
We can see here that the read, sorry, who can write, the permission ID there is two.

14:18.510 --> 14:20.990
So if we...

14:26.100 --> 14:28.560
I think I've got the wrong one highlighted there.

14:28.620 --> 14:31.520
I want to find out who can write to Reback article two.

14:32.000 --> 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.

14:39.720 --> 14:43.400
So we say, okay, within the relationships, let's find out everything we know about the article.

14:43.540 --> 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.

14:53.000 --> 14:56.140
However, relationship ID one is in that table.

14:56.140 --> 14:59.300
That is related to the object identity two.

14:59.300 --> 15:04.940
So we can pull out the user Robin has write access to the article.

15:05.180 --> 15:07.700
So you can look at things in other directions as well.

15:08.200 --> 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.

15:13.100 --> 15:14.560
We look at article number three.

15:14.820 --> 15:19.020
We know that Robin is the owner of that article already.

15:20.120 --> 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.

15:28.920 --> 15:35.680
So we can see that the member here of organization two has access to the article.

15:35.860 --> 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.

15:42.240 --> 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.

15:50.360 --> 15:52.940
So that's probably one of the most complicated lookups.

15:53.020 --> 15:58.640
It's really diving straight into the depths of the Reback schema.

15:58.640 --> 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.

16:09.140 --> 16:10.200
I mean, you do.

16:10.200 --> 16:12.340
But that doesn't really help an end user.

16:12.340 --> 16:18.660
How do we then unfold that and then extrapolate that to refer to the actual user entities?

16:19.080 --> 16:23.380
And this is where it gets complicated because Reback, as I said, doesn't have a concept of a user necessarily.

16:23.380 --> 16:29.300
You could actually ask Reback what is the relationship between this organization and that network.

16:29.560 --> 16:30.900
Neither of them really do anything.

16:30.900 --> 16:31.840
They're system entities.

16:31.840 --> 16:32.980
They're not user entities.

16:32.980 --> 16:34.480
But they still have relationships.

16:34.480 --> 16:36.800
So it's powerful, but also complex.

16:37.600 --> 16:41.280
So implementation details.

16:43.220 --> 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.

16:49.800 --> 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.

17:06.380 --> 17:11.180
Seems like a fairly robust kind of setup that you might have in a large organization.

17:11.660 --> 17:12.560
So if.

17:13.020 --> 17:15.420
If the user is admin or if the user is editor.

17:15.700 --> 17:16.300
Cool.

17:16.480 --> 17:20.060
So we know what role the user has.

17:20.600 --> 17:25.380
Also, if the user is an editor and the list of document editors contains the current user.

17:25.440 --> 17:27.820
So we don't want any editor to be able to edit this.

17:28.060 --> 17:32.240
Only if the list of editors for this particular article includes the current user.

17:32.680 --> 17:34.240
So we can compound those two together.

17:34.940 --> 17:38.660
Then also we want to say, well, if the document isn't sensitive, then we can carry on.

17:38.700 --> 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.

17:47.180 --> 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.

17:52.460 --> 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.

18:03.820 --> 18:06.640
Imagine if you had to come back and change those rules three months later.

18:08.780 --> 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.

18:16.080 --> 18:17.480
We're going to define a document.

18:17.700 --> 18:19.440
The document has an owner and an editor.

18:19.440 --> 18:26.020
The owner is a user and the editor is a member of an organization with the member type editor.

18:26.400 --> 18:29.140
So you can have different types of people within groups.

18:29.940 --> 18:31.560
And then we're going to have a sensitive document.

18:31.560 --> 18:33.320
So that's the definition of a normal document.

18:33.380 --> 18:36.020
A sensitive document is going to extend document.

18:36.800 --> 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 .

18:45.160 --> 18:49.040
Because remember, we're defining actions on an entity and who's allowed to perform it.

18:49.200 --> 18:52.080
So can edit be done on a sensitive document?

18:52.080 --> 18:57.020
Yes, you can if you are the document owner and you are the document owner and you're on premises.

18:57.960 --> 19:00.240
Or if you're an editor and you're on premises.

19:00.900 --> 19:06.480
So this gets tied into your relationship-based access model schema and permission systems.

19:06.480 --> 19:10.060
So now your code can change from this to that.

19:11.380 --> 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.

19:20.100 --> 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.

19:26.040 --> 19:28.260
There's a fast and firm rule for that.

19:28.300 --> 19:29.960
This gives you two benefits.

19:29.960 --> 19:32.900
One from a clean code, easy to read perspective.

19:32.900 --> 19:34.420
That is much easier to read.

19:34.420 --> 19:35.760
You know exactly what's going to happen.

19:35.760 --> 19:37.320
You don't have to think about it.

19:37.620 --> 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.

19:51.680 --> 19:53.360
So demo time.

19:53.580 --> 19:54.480
This is the fun part.

19:54.480 --> 19:57.180
So the first part was all about dogs.

19:57.180 --> 20:01.700
Then we went to document access management which is important but boring.

20:01.700 --> 20:03.140
So we're going to go back to dogs.

20:03.740 --> 20:06.400
I have tried a number of products.

20:06.400 --> 20:08.500
There are all these products up on the screen here.

20:08.500 --> 20:09.360
There are many more.

20:09.360 --> 20:12.540
These are relationship-based access management tools.

20:12.540 --> 20:14.160
Some of them are open source and free to use.

20:14.160 --> 20:15.220
Some of them are paid for.

20:15.220 --> 20:17.600
I'm going to be using Permify in this demo.

20:18.720 --> 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.

20:24.340 --> 20:25.620
So I apologize in advance.

20:25.620 --> 20:26.920
But I'm going to need both hands.

20:27.620 --> 20:30.080
So I'm just going to stop screen sharing.

20:32.060 --> 20:36.480
Let's jump over here and we're going to have a first look at Postman.

20:37.080 --> 20:38.980
So let's make this a bit bigger.

20:39.840 --> 20:41.560
Can you all read that okay?

20:41.740 --> 20:42.540
Excellent.

20:42.900 --> 20:45.680
So let's have a look from the beginning.

20:45.680 --> 20:47.420
We're going to create a tenant.

20:47.420 --> 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.

20:56.060 --> 20:57.980
So I'm just going to restart Permify in the background.

20:57.980 --> 20:59.500
So we're starting from a bank slate.

20:59.860 --> 21:03.660
So now over here what we're going to do is we're going to create a new tenant.

21:03.660 --> 21:06.000
So Permify allows you to have multiple tenants in your system.

21:06.000 --> 21:14.140
So you can sandbox or isolate certain areas of your organization or even certain organizations within a larger system.

21:14.840 --> 21:20.500
So we're going to create a tenant over here called Dog and Bone.

21:20.960 --> 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.

21:28.040 --> 21:30.180
So the next thing I'm going to do is create the schema.

21:30.220 --> 21:35.120
Now this schema, for some reason, Permify wants it in a single string.

21:35.580 --> 21:39.100
So to make it easier, I have it over here.

21:41.240 --> 21:43.260
And this is very similar to what we saw in the slides.

21:43.260 --> 21:45.080
Basically we've got a definition of a dog.

21:45.280 --> 21:47.180
A dog has an owner, which is a person.

21:47.440 --> 21:48.280
We've got a sheep.

21:48.280 --> 21:50.340
A sheep has an owner that is also a person.

21:50.480 --> 21:53.200
A sheep also has a bone, which is an entity type bone.

21:53.580 --> 21:54.580
We've got a person.

21:54.720 --> 21:56.980
A person can have a friend, would be another person.

21:57.300 --> 21:59.500
A person can also have sheep and a person can have dogs.

21:59.680 --> 22:02.700
So we've got bidirectional rules here.

22:02.700 --> 22:05.440
And then we've got a relationship between the bone.

22:05.440 --> 22:07.340
The bone has an owner, and that's a sheep.

22:07.340 --> 22:08.300
And then we've got a permission.

22:08.300 --> 22:11.140
Can the owner's friend's dog eat?

22:11.900 --> 22:16.880
And eat is true if that comes out as a relationship that exists.

22:17.720 --> 22:24.220
So let's submit that through and we should find that that has now worked.

22:24.220 --> 22:25.560
If I now create some

22:28.720 --> 22:29.040
relationships...

22:29.040 --> 22:30.280
come on, get bigger.

22:32.760 --> 22:33.680
Where's the handle?

22:34.260 --> 22:35.200
It's always hiding.

22:38.660 --> 22:40.640
I'll just scroll through this a little by little.

22:41.760 --> 22:44.820
Actually if I make this slightly smaller, is that still readable at the back?

22:45.560 --> 22:46.420
Yep, okay.

22:46.580 --> 22:47.940
So at least we can see a bit more at a time.

22:47.940 --> 22:50.840
So we can see here we've got a relationship between a subject and an entity.

22:51.000 --> 22:55.080
Remember I said a subject is also an entity, but it's just the primary entity in a relationship.

22:55.200 --> 22:56.320
Is the microphone cutting in?

22:56.600 --> 22:57.620
A little?

22:57.800 --> 22:59.200
I'll go back to this one.

22:59.480 --> 23:01.240
Because I don't need to type as much now.

23:01.240 --> 23:05.380
So we can see the subject, mad scientist, is the owner of Shadow the Dog.

23:05.480 --> 23:09.680
We can see here that Shadow the Dog is also a dog belonging to the scientist.

23:10.040 --> 23:12.660
And then we've got the farmer has Dolly the sheep.

23:12.860 --> 23:14.700
The sheep belongs to the farmer.

23:14.860 --> 23:19.460
And we've got Dolly is a sheep to the femur.

23:19.700 --> 23:22.680
And the femur is a bone to the sheep.

23:23.060 --> 23:25.200
So we've got these relationships built up now.

23:25.400 --> 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.

23:37.860 --> 23:39.840
We have no, he has no friends.

23:39.840 --> 23:41.340
He's a sad scientist.

23:41.700 --> 23:44.800
As it happens, the farmer is also a sad farmer.

23:44.900 --> 23:48.300
Although the farmer has sheep, so a little bit happier, probably.

23:48.840 --> 23:50.340
I know, sheep are better than dogs.

23:50.360 --> 23:51.820
I digress yet again.

23:51.820 --> 23:53.480
So can Shadow eat the bone?

23:53.480 --> 23:54.440
What do we reckon?

23:56.100 --> 23:56.740
No.

23:56.740 --> 23:58.340
So if I hit that, it comes through.

23:58.460 --> 23:59.460
Result denied.

23:59.860 --> 24:07.880
So it's a very low energy kind of reaction that I'm getting.

24:07.880 --> 24:09.980
But it's also a very low energy kind of output.

24:10.000 --> 24:13.640
So I thought I've got these two requests here that I can make.

24:13.640 --> 24:16.860
The first one calls data right.

24:17.360 --> 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.

24:21.320 --> 24:23.420
And then I've got another one here, break friends.

24:23.600 --> 24:24.780
It's data delete.

24:24.780 --> 24:28.240
And in here I'm defining the mad scientist is no longer a friend with the farmer.

24:28.260 --> 24:38.660
So to make this a little more exciting, I decided to show you all my sister's Facebook page.

24:39.460 --> 24:41.820
And also let's bring this back in over here.

24:42.440 --> 24:44.040
I have a dog and a bone.

24:44.060 --> 24:47.760
Let's just refresh this, because it doesn't like having the lid shut on it.

24:48.480 --> 24:51.260
And for some reason I'm getting an image rendering error.

24:51.260 --> 24:52.200
There we go.

24:52.340 --> 24:53.740
What demos go perfectly.

24:53.740 --> 24:55.200
So doors closed.

24:55.200 --> 24:56.440
Dog can't get a bone.

24:56.440 --> 25:03.580
So what happens if the farmer makes friends with the scientist?

25:03.580 --> 25:04.480
What do you think?

25:09.000 --> 25:10.540
No, it didn't work.

25:11.900 --> 25:13.660
Did I call the right one there?

25:13.800 --> 25:15.340
Looks like you're offline.

25:15.340 --> 25:17.160
Yeah, but I'm doing everything locally.

25:17.640 --> 25:19.960
So did

25:23.920 --> 25:25.060
I call the wrong one?

25:25.180 --> 25:26.660
Did I call break friends?

25:26.680 --> 25:28.640
Let's double click on that one.

25:31.980 --> 25:33.020
Darn it.

25:33.460 --> 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.

25:45.100 --> 25:50.520
So now if I call can shadow eat the bone, it comes back as still denied.

25:50.800 --> 25:52.720
So this is where the demo fails.

25:52.720 --> 25:55.120
I'm more than happy to work out why the demo failed.

25:55.120 --> 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.

26:01.200 --> 26:02.460
But the theory is there.

26:02.460 --> 26:04.460
The results should have come back immediately.

26:04.460 --> 26:06.600
I had a little bit of a cheat in my app.

26:06.600 --> 26:08.220
It was basically polling every second.

26:08.640 --> 26:13.700
But there are plenty of ways of connecting to databases and getting a full time stream of data back.

26:13.700 --> 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.

26:21.500 --> 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.

26:28.160 --> 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.

26:42.440 --> 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.

26:48.420 --> 26:51.320
Role based access control is always going to be your easiest.

26:51.320 --> 26:54.720
That's always simply like, is this person an admin, yes or no?

26:55.040 --> 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?

27:01.460 --> 27:03.000
That's technically the simplest.

27:03.520 --> 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.

27:14.400 --> 27:19.080
Work out what level of complexity you can get to at a minimum while still meeting your requirements.

27:19.080 --> 27:23.940
Because if you go for the full thing, straight out, re-back all the way, baby, absolutely it's fun.

27:24.340 --> 27:28.360
You will probably create a situation where your job is now indispensable.

27:28.460 --> 27:31.540
You will not be fired because nobody knows what the hell you did.

27:31.880 --> 27:33.920
But it's not always the right solution, okay?

27:33.920 --> 27:35.040
Pick the right one for you.

27:35.040 --> 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.

27:44.260 --> 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.

27:49.080 --> 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.

27:56.540 --> 28:01.040
But I would like to finish by just saying thank you.

28:01.180 --> 28:02.960
If I can even find my slides.

28:06.830 --> 28:08.450
Let's just get that back up there.

28:08.510 --> 28:11.430
So again, that's my contact details at the top there.

28:11.890 --> 28:13.770
ArcJet are currently running a contest.

28:13.770 --> 28:17.730
If you want to try our product out, there's some prizes we're giving away as well.

28:17.730 --> 28:18.950
Challenge.arcjet.com.

28:18.950 --> 28:19.510
Give it a try.

28:19.510 --> 28:20.150
Let us know.

28:20.150 --> 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.

28:29.010 --> 28:30.810
But this talk was about permission systems.

28:30.810 --> 28:31.730
Come talk to me.

28:31.750 --> 28:32.450
Thank you for your time.

28:32.450 --> 28:34.230
Have a great rest of your DEF CON.

28:34.230 --> 28:34.810
Thanks.

