README-authorisation
author Simon MacMullen <simon@rabbitmq.com>
Tue Dec 06 11:32:29 2011 +0000 (5 months ago)
changeset 79 767428564f73
parent 77 2accb1d0f5e3
permissions -rw-r--r--
Docs update.
     1 Overview
     2 ========
     3 
     4 Authorisation is effected by three configuration options:
     5 
     6 * vhost_access_query
     7 * resource_access_query
     8 * tag_queries
     9 
    10 Each defines a query that will determine whether a user has access to
    11 a vhost, a resource (e.g. exchange, queue, binding) or is considered
    12 an administrator.
    13 
    14 The default values are {constant, true}, {constant, true} and
    15 [{administrator, {constant, false}}] respectively, granting all users
    16 access to all objects in all vhosts, but not making them
    17 administrators.
    18 
    19 A query can be of one of several types:
    20 
    21 Constant Query
    22 --------------
    23 
    24 {constant, Bool}
    25 
    26 This will always return either true or false, unconditionally granting
    27 or denying access.
    28 
    29 Exists Query
    30 ------------
    31 
    32 {exists, Pattern}
    33 
    34 This will substitute variables into the pattern, and return true if
    35 there exists an object with the resulting DN. Substitution occurs with
    36 ${} syntax. The vhost_access_query in the example configuration below
    37 therefore allows you to control access to vhosts by controlling the
    38 existence of OUs in a vhosts OU.
    39 
    40 Each of the three queries allow different substitutions:
    41 
    42 vhost_access_query:
    43   ${username}
    44   ${user_dn}
    45   ${vhost}
    46 
    47 resource_access_query:
    48   ${username}
    49   ${user_dn}
    50   ${vhost}
    51   ${resource} (one of exchange or queue)
    52   ${name}
    53   ${permission} (one of configure, write or read)
    54 
    55 The terms configure, write and read for resource access have the same
    56 meanings that they do for the built-in RabbitMQ permissions system,
    57 see http://www.rabbitmq.com/access-control.html
    58 
    59 tag_queries:
    60   ${username}
    61   ${user_dn}
    62 
    63 Note that tag_queries consists of a proplist, mapping the name of a
    64 tag to a query to perform to determine whether or not the user has
    65 that tag. You must list queries for all tags that you want your users
    66 to have.
    67 
    68 In Group Query
    69 --------------
    70 
    71 {in_group, Pattern}
    72 
    73 Like the Exists Query, substitutes arguments into a pattern to look
    74 for an object. However, this query returns true if the logged in user
    75 is a member.
    76 
    77 Match Query
    78 -----------
    79 
    80 {match, StringSubQuery, RESubQuery}
    81 
    82 Takes a string and a regular expression, and checks that the one
    83 matches the other. Note that the string and the regular expression are
    84 both queries in turn.
    85 
    86 String Query
    87 ------------
    88 
    89 {string, Pattern}
    90 
    91 Just substitutes arguments into a string. As this returns a string
    92 rather than a boolean it should be used within a match query.
    93 
    94 Attribute Query
    95 ---------------
    96 
    97 {attribute, DNPattern, AttributeName}
    98 
    99 Returns the value of an attribute of an object retrieved from LDAP. As
   100 this returns a string rather than a boolean it should be used within a
   101 match query.
   102 
   103 For Query
   104 ---------
   105 
   106 {for, [{Name, Value, SubQuery}, ...]}
   107 
   108 This allows you to split up a query and handle different cases with
   109 different subqueries.
   110 
   111 Options should be a list of three-tuples, with each tuple containing a
   112 name, value and subquery. The name is the name of a variable
   113 (i.e. something that would go into a ${} substitution). The value is a
   114 possible value for that variable.
   115 
   116 So the example:
   117 
   118      {resource_access_query,
   119       {for, [{resource, exchange,
   120               {for, [{permission, configure,
   121                       { in_group, "cn=wheel,ou=groups,dc=example,dc=com" }
   122                      },
   123                      {permission, write, {constant, true}},
   124                      {permission, read,  {constant, true}}
   125                     ]}},
   126              {resource, queue, {constant, true}} ]}}
   127 
   128 would allow members of the "wheel" group to declare and delete
   129 exchanges, and allow all users to do everything else.
   130 
   131 Example Configuration
   132 =====================
   133 
   134 TODO improve and explain this
   135 
   136 [
   137   {rabbit, [{auth_backends, [rabbit_auth_backend_ldap]}]},
   138   {rabbitmq_auth_backend_ldap,
   139    [ {servers,               ["my-ldap-server"]},
   140      {user_dn_pattern,       "cn=${username},ou=People,dc=example,dc=com"},
   141      {vhost_access_query,    {exists,
   142                               "ou=${vhost},ou=vhosts,dc=example,dc=com"}},
   143      {resource_access_query,
   144       {for, [{resource, exchange,
   145               {for, [{permission, configure,
   146                       { in_group, "cn=wheel,ou=groups,dc=example,dc=com" }
   147                      },
   148                      {permission, write, {constant, true}},
   149                      {permission, read,  {constant, true}}
   150                     ]}},
   151              {resource, queue, {constant, true}} ]}},
   152      {tag_queries,           [{administrator, {constant, false}}]},
   153      {use_ssl,               false},
   154      {port,                  389},
   155      {log,                   false} ] }
   156 ].