From f82d259e7bda843fb63ac1a0f6ff1d6bfb187099 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Wed, 9 Dec 2015 20:40:42 -0500 Subject: Remove HTML from the project. (We're no longer using Dokku.) --- .html/authnz/_list.html | 88 -------------- .html/authnz/index.html | 88 -------------- .html/authnz/users-rolegraph-privs.html | 197 -------------------------------- 3 files changed, 373 deletions(-) delete mode 100644 .html/authnz/_list.html delete mode 100644 .html/authnz/index.html delete mode 100644 .html/authnz/users-rolegraph-privs.html (limited to '.html/authnz') diff --git a/.html/authnz/_list.html b/.html/authnz/_list.html deleted file mode 100644 index c7948ab..0000000 --- a/.html/authnz/_list.html +++ /dev/null @@ -1,88 +0,0 @@ - - - - - The Codex » - ls /authnz - - - - - - - - -
- - - - - -
-

ls /authnz

- - - - - - - - -
- - - - - - - - -
- - \ No newline at end of file diff --git a/.html/authnz/index.html b/.html/authnz/index.html deleted file mode 100644 index c7948ab..0000000 --- a/.html/authnz/index.html +++ /dev/null @@ -1,88 +0,0 @@ - - - - - The Codex » - ls /authnz - - - - - - - - -
- - - - - -
-

ls /authnz

- - - - - - - - -
- - - - - - - - -
- - \ No newline at end of file diff --git a/.html/authnz/users-rolegraph-privs.html b/.html/authnz/users-rolegraph-privs.html deleted file mode 100644 index 79e1bbe..0000000 --- a/.html/authnz/users-rolegraph-privs.html +++ /dev/null @@ -1,197 +0,0 @@ - - - - - The Codex » - A Users, Roles & Privileges Scheme Using Graphs - - - - - - - - -
- - - - - -
-

A Users, Roles & Privileges Scheme Using Graphs

-

The basic elements:

-
    -
  • Every agent that can interact with a system is represented by a user.
  • -
  • Every capability the system has is authorized by a distinct privilege.
  • -
  • Each user has a list of zero or more roles.
      -
    • Roles can imply further roles. This relationship is transitive: if - role A implies role B, then a member of role A is a member of role B; if - role B also implies role C, then a member of role A is also a member of - role C. It helps if the resulting role graph is acyclic, but it's not - necessary.
    • -
    • Roles can grant privileges.
    • -
    -
  • -
-

A user's privileges are the union of the privileges granted by the transitive -closure of their roles.

-

In SQL

-
create table "user" (
-    username varchar
-        primary key
-    -- credentials &c
-);
-
-create table role (
-    name varchar
-        primary key
-);
-
-create table role_member (
-    role varchar
-        not null
-        references role,
-    member varchar
-        not null
-        references "user",
-    primary key (role, member)
-);
-
-create table role_implies (
-    role varchar
-        not null
-        references role,
-    implied_role varchar
-        not null
-);
-
-create table privilege (
-    privilege varchar
-        primary key
-);
-
-create table role_grants (
-    role varchar
-        not null
-        references role,
-    privilege varchar
-        not null
-        references privilege,
-    primary key (role, privilege)
-);
-
-

If your database supports recursive CTEs, querying this isn't awful, since we -can have the database do all the graph-walking along roles:

-
with recursive user_roles (role) AS (
-    select
-        role
-    from
-        role_member
-    where
-        member = 'SOME USERNAME'
-    union
-    select
-        implied_role as role
-    from
-        user_roles
-        join role_implies on
-            user_roles.role = role_implies.role
-)
-select distinct
-    role_grants.privilege as privilege
-from
-    user_roles
-    join role_grants on
-        user_roles.role = role_grants.role
-order by privilege;
-
-

If not, get a better database. Recursive graph walking with network round -trips at each step is stupid and you shouldn't do it.

-

Realistic uses should have fairly simple graphs: elemental privileges are -grouped into abstract roles, which are in turn grouped into meaningful roles -(by department, for example), which are in turn granted to users. In -PostgreSQL, the above schema handles ~10k privileges and ~10k roles with -randomly-generated graph relationships in around 100ms on my laptop, which is -pretty slow but not intolerable. Perverse cases (interconnected total -subgraphs, deeply-nested linear graphs) can take absurd time but do not -reflect any likely permissions scheme.

-

What Sucks

-
    -
  • Graph theory in my authorization system? It's more likely than you think.
  • -
  • There's no notion of revoking a privilege. If you have a privilege by any - path through your roles, then it cannot be revoked except by removing all of - the paths that lead back to that privilege.
  • -
  • Not every system has an efficient way to compute these graphs.
      -
    • PostgreSQL, as given above, has a hard time with unrealistically-deep - nested roles.
    • -
    -
  • -
-
- - - -
-
- - -comments powered by Disqus -
- - - - - -
- - \ No newline at end of file -- cgit v1.2.3