[#1909] Convert our old dict-based ACLs to list-based ACLs.

This commit includes:

  • addition of ACL and ACE types for model validation
  • replacement of neighborhood ACLs with delegation to the
    --init-- project for that neighborhood
  • unification of security, tool, and delete permission to 'admin'
  • updates to the models
  • updates to permission-checking code
  • rename has__access => has_access(, )
  • removal of some dead code

Signed-off-by: Rick Copeland rcopeland@geek.net

Rick Copeland Rick Copeland 2011-04-13

<< < 1 2 3 (Page 3 of 3)
changed ForgeDiscussion/forgediscussion/templates/discussionforums/thread.html
changed ForgeDiscussion/forgediscussion/tests/test_forum_roles.py
changed ForgeDiscussion/forgediscussion/forum_main.py
changed ForgeDownloads/forgedownloads/dl_main.py
changed ForgeLink/forgelink/link_main.py
changed ForgeTracker/forgetracker/templates/tracker/search.html
changed ForgeTracker/forgetracker/templates/tracker/ticket.html
changed ForgeTracker/forgetracker/tests/test_tracker_roles.py
changed ForgeTracker/forgetracker/tracker_main.py
changed ForgeWiki/forgewiki/templates/wiki/page_edit.html
changed ForgeWiki/forgewiki/templates/wiki/page_history.html
changed ForgeWiki/forgewiki/templates/wiki/page_view.html
changed ForgeWiki/forgewiki/tests/test_wiki_roles.py
changed ForgeWiki/forgewiki/wiki_main.py
copied Allura/allura/templates/neighborhood_admin_permissions.html -> Allura/allura/model/types.py
ForgeDiscussion/forgediscussion/templates/discussionforums/thread.html Diff Switch to side-by-side view
Loading...
ForgeDiscussion/forgediscussion/tests/test_forum_roles.py Diff Switch to side-by-side view
Loading...
ForgeDiscussion/forgediscussion/forum_main.py Diff Switch to side-by-side view
Loading...
ForgeDownloads/forgedownloads/dl_main.py Diff Switch to side-by-side view
Loading...
ForgeLink/forgelink/link_main.py Diff Switch to side-by-side view
Loading...
ForgeTracker/forgetracker/templates/tracker/search.html Diff Switch to side-by-side view
Loading...
ForgeTracker/forgetracker/templates/tracker/ticket.html Diff Switch to side-by-side view
Loading...
ForgeTracker/forgetracker/tests/test_tracker_roles.py Diff Switch to side-by-side view
Loading...
ForgeTracker/forgetracker/tracker_main.py Diff Switch to side-by-side view
Loading...
ForgeWiki/forgewiki/templates/wiki/page_edit.html Diff Switch to side-by-side view
Loading...
ForgeWiki/forgewiki/templates/wiki/page_history.html Diff Switch to side-by-side view
Loading...
ForgeWiki/forgewiki/templates/wiki/page_view.html Diff Switch to side-by-side view
Loading...
ForgeWiki/forgewiki/tests/test_wiki_roles.py Diff Switch to side-by-side view
Loading...
ForgeWiki/forgewiki/wiki_main.py Diff Switch to side-by-side view
Loading...
Allura/allura/templates/neighborhood_admin_permissions.html to Allura/allura/model/types.py
--- a/Allura/allura/templates/neighborhood_admin_permissions.html
+++ b/Allura/allura/model/types.py
@@ -1,81 +1,43 @@
-{% extends g.theme.master %}
+from ming.base import Object
+from ming import schema as S
 
-{% block extra_css %}
-    <link rel="stylesheet" type="text/css" media="screen" href="{{g.forge_static('css/forge/accordion.css')}}" />
-{% endblock %}
+class ACE(S.Object):
+    '''ACE - access control entry'''
+    ALLOW, DENY = 'ALLOW', 'DENY'
+    def __init__(self, permissions, **kwargs):
+        if permissions is None:
+            permission=S.String()
+        else:
+            permission=S.OneOf('*', *permissions)
+        super(ACE, self).__init__(
+            fields=dict(
+                access=S.OneOf(self.ALLOW, self.DENY),
+                role_id=S.ObjectId(),
+                permission=permission),
+            **kwargs)
 
-{% block title %}{{neighborhood.name}} / Permissions{% endblock %}
+    @classmethod
+    def allow(cls, role_id, permission):
+        return Object(
+            access=cls.ALLOW,
+            role_id=role_id,
+            permission=permission)
 
-{% block header %}Permissions for {{neighborhood.name}}{% endblock %}
+    @classmethod
+    def deny(cls, role_id, permission):
+        return Object(
+            access=cls.DENY,
+            role_id=role_id,
+            permission=permission)
 
-{% block nav_menu %}
-{% include 'allura:templates/jinja_master/neigh_nav_menu.html' %}
-{% endblock %}
+    @classmethod
+    def match(cls, ace, role_id, permission):
+        return (
+            ace.role_id == role_id
+            and ace.permission in (permission, '*'))
 
-{% block top_nav %}
-{% include 'allura:templates/jinja_master/neigh_top_nav.html' %}
-{% endblock %}
+class ACL(S.Array):
 
-{% block content %}
-          <p>The ACL determines neighborhood-level permissions.</p>
-          <div id="acl-admin">
-            {% for permission, users in neighborhood.acl.iteritems() %}
-              <h3><a href="#" id="permission_{{permission}}">Permission: {{permission}}</a></h3>
-              <div>
-                <form method="POST" action="update_acl">
-                  <input type="hidden" name="permission" value="{{permission}}"/>
-                  {% for uid in users %}
-                    <input type="hidden" name="user-{{loop.index0}}.id" value="{{uid}}"/>
-                  {% endfor %}
-                  <table>
-                    <thead>
-                      <tr><th>Username</th><th></th></tr>
-                    </thead>
-                    <tbody>
-                      {% for u in h.make_users(users) %}
-                        <tr>
-                          <td>{{u.username}}</td>
-                          <td><input type="submit" value="Remove" name="user-{{loop.index0}}.delete" /></td>
-                        </tr>
-                      {% endfor %}
-                      <tr>
-                        <td>
-                          <input name="new.username" type="text"/>
-                        </td>
-                        <td>
-                          <input type="submit" name="new.add" value="Add Permission"/>
-                        </td>
-                      </tr>
-                    </tbody>
-                  </table>
-                </form>
-              </div>
-            {% endfor %}
-          </div>
-{% endblock %}
-
-{% block extra_js %}
-  <script type="text/javascript">
-    $(function () {
-      $("#acl-admin").accordion({
-        autoHeight: false,
-        navigation: true,
-        change: function(event,ui) {
-          var hid = ui.newHeader.children('a').attr('id');
-          if (hid === undefined) {
-            $.cookie('neighborhood-acl-admin', null);
-          } else {
-            $.cookie('neighborhood-acl-admin', hid, { path: '/', expires: 2 });
-          }
-        }
-      });
-    });
-    $(document).ready(function () {
-      if($.cookie('neighborhood-acl-admin')) {
-        $('#acl-admin').accordion('option', 'animated', false)
-                       .accordion('activate', $('#' + $.cookie('neighborhood-acl-admin')).parent('h3'))
-                       .accordion('option', 'animated', 'slide');
-      }
-    });
-</script>
-{% endblock %}
+    def __init__(self, permissions=None, **kwargs):
+        super(ACL, self).__init__(
+            field_type=ACE(permissions), **kwargs)
<< < 1 2 3 (Page 3 of 3)