Re: [Codematch-develop] DataTracker and CodeMatch access control

Lisandro Zambenedetti Granville <granville@inf.ufrgs.br> Wed, 26 August 2015 19:38 UTC

Return-Path: <granville@inf.ufrgs.br>
X-Original-To: codematch-develop@ietfa.amsl.com
Delivered-To: codematch-develop@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 0021F1A92B6 for <codematch-develop@ietfa.amsl.com>; Wed, 26 Aug 2015 12:38:16 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.961
X-Spam-Level:
X-Spam-Status: No, score=-1.961 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, HELO_EQ_BR=0.955, HOST_EQ_BR=1.295, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=ham
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7mQTj7nHdTID for <codematch-develop@ietfa.amsl.com>; Wed, 26 Aug 2015 12:38:13 -0700 (PDT)
Received: from delivery1.ufrgs.br (delivery1.ufrgs.br [143.54.2.211]) by ietfa.amsl.com (Postfix) with ESMTP id 808A21A8A27 for <codematch-develop@ietf.org>; Wed, 26 Aug 2015 12:38:12 -0700 (PDT)
Received: from delivery1.ufrgs.br (localhost [127.0.0.1]) by delivery1.ufrgs.br (Postfix) with ESMTP id 732EF3007A4; Wed, 26 Aug 2015 16:38:09 -0300 (BRT)
Received: from msa1.ufrgs.br (msa1.ufrgs.br [143.54.2.208]) by delivery1.ufrgs.br (Postfix) with ESMTP id 69D553D71C; Wed, 26 Aug 2015 16:38:09 -0300 (BRT)
Content-Type: text/plain; charset=windows-1252
Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\))
From: Lisandro Zambenedetti Granville <granville@inf.ufrgs.br>
In-Reply-To: <55DE0CB3.8020001@nostrum.com>
Date: Wed, 26 Aug 2015 16:38:07 -0300
Content-Transfer-Encoding: quoted-printable
Message-Id: <567B5A53-7A2E-4D1B-A486-37B824D986B0@inf.ufrgs.br>
References: <0EDC30A8-DD35-4153-B8F1-9AE27CB06E09@inf.ufrgs.br> <55DDD328.6020709@nostrum.com> <5A1D82C2-B60B-4A85-A4B2-E8B524C885D6@inf.ufrgs.br> <55DE0CB3.8020001@nostrum.com>
To: Robert Sparks <rjsparks@nostrum.com>
X-Mailer: Apple Mail (2.2104)
X-AV-Checked: ClamAV using ClamSMTP
Archived-At: <http://mailarchive.ietf.org/arch/msg/codematch-develop/NMSJOIv-4qBYICbV4p1AUW8Mk0o>
Cc: codematch-develop <codematch-develop@ietf.org>, Henrik Levkowetz <henrik@levkowetz.com>
Subject: Re: [Codematch-develop] DataTracker and CodeMatch access control
X-BeenThere: codematch-develop@ietf.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: "\"Discussion forum for the planning, coordination, and development of CodeMatch\"" <codematch-develop.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/codematch-develop>, <mailto:codematch-develop-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/codematch-develop/>
List-Post: <mailto:codematch-develop@ietf.org>
List-Help: <mailto:codematch-develop-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/codematch-develop>, <mailto:codematch-develop-request@ietf.org?subject=subscribe>
X-List-Received-Date: Wed, 26 Aug 2015 19:38:16 -0000

Hello Robert

>>> You are not necessarily restricted to the Role names that are defined now (like "chair"). We could add Role names like
>>> "codematcher" or "codematch_approver" or whatever other name matches the semantic for the permission you're wanting to manage.
>> That’s great, so that we can expand the current Roles without changing the data model.
>> 
>>> You could then have things like Lisandro Granville is codematch_approver in nmrg.
>> That is also what we need.
> Just to be sure - you're saying that's sufficient, and while you're explaining the idea further below, you don't need it right now?

Sorry, I was not clear. Creating new Roles and allowing users being assigned to these new Roles are things that we need in CodeMatch too. Further below I mention something that we are proposing (i.e., has_right) in addition to having new roles.

>>> Does that address the need? If not, could you walk me though a scenario where it makes it harder than it should?
>> What you mention above is the link among users, roles, and groups. There is another link between roles and permissions that seems to be hardcoded in datatracker. When we say
>> 
>> if has_role(request.user, ["Area Director", "IAB Chair", "Secretariat”]):
>> 	// do things the user with "permission X" can do
>> 
>> it implies that if we want to grant to, e.g., “codematch_approver” the “permission X” above, we should go back to the code and change it to
>> 
>> if has_role(request.user, ["Area Director", "IAB Chair", “Secretariat”, “codematch_approver"]):...
>> 
>> We were then considering the possibility of moving the link between roles and permission to the data model and implement has_right (or has_permission) like:
>> 
>> if has_right(request.user, “permission X”):
>> 	// do things the user with "permission X" can do
>> 
>> If we want “permission X” to be granted to other roles, that would be a matter of including the proper records in the database, instead of changing the code.
>> 
>> Trying not to go too much into details, the summary is that we want to check if assigning permission to roles is ok to be done in the database, instead of changing the code.
> Well, you still have to type has_right(...) in the code, and specify something concrete in that has_right that would have to change,
> so I don't think we're really talking about avoiding changing code as much as we are about _where_ you model the idea of a permission in the database.

I agree. We are talking about modeling the link between roles and permission in the database.

> I think the real essence of what we're talking about is the difference in how you would implement
> "Give all the WG chairs codematch-approval rights".
> 
> With your proposal, you would make a role to permission match to do that - one database row change - pretty efficient (*)
> With what we have now, you just add a Role of "codematch-approval" to any Person that has a wg chair role.
> So, I think what you're proposing is an optimization, and it comes with some complexity. We can keep talking about it, but I don't
> think we're at the point that we need it.

This complexity involves:

a) Creating a new intermediate table “role_auth_permission" composed of, at least, two columns: role_id and auth_permission_id;

b) Creating the function "has_right (user, permission_label)" which given the user it retrieves the user’s roles, from roles it retrieves permissions and, among permissions, it checks if permission_label is present. 

Of course, the effort of doing a) and b) would be ours. And these implementation would be used in CodeMatch only; it wouldn’t be changing or affecting DataTracker.

> (*) But, it's not really that easy. Right now we have a role of "chair" that is applied to all groups. There's no way to speak differently about WG chairs and RG chairs by simply saying "chair" - it takes more code. We have chairs of Teams, and _could_ have (but don't currently) chairs of other SDOs in the database. So, the apparent simplicity of matching a permission to a role-name isn't as strong as it first appears.

While coding the CodeMatch system, we notice that some portions of the system may be or may be not available to different user roles. Although we define somes roles now, changes on role-permissions will probably happen along the development process. 

The permissions we want the roles to have define, let me say, the policy of CodeMatch. We wanted to decouple that policy from the system implementation itself, thus implementing an RBAC model; if the link between roles and permissions (i.e., the system policy) migrates to the database, we can tag CodeMatch source code (i.e., define permission labels) and redefine which roles are able to access different parts of the system. Notice, this is just for CodeMatch, of course. 

Thanks,

Lisandro

>>  We are of course talking about the CodeMatch code only; we are not talking about the datatracker code at all, although examples were inspired by has_role, which is used in datatracker.
>> 
>> Lisandro
>> 
>>> On 8/25/15 1:52 PM, Lisandro Zambenedetti Granville wrote:
>>>> Dear All
>>>> 
>>>> Last week we had our traditional CodeMatch meeting. One of the questions discussed in the meeting was about role-based access control (RBAC) in CodeMatch. We would like to propose adding an extra table in the current data model to support RBAC. However, because we want to be as aligned with DataTracker style as possible, we are sending this message to start a discussion, specially with Henrik and Robert.
>>>> 
>>>> 1) Style of checking users’ permission
>>>> 
>>>> We observed the DataTracker code and it seems that in general, permission checking is hardcoded, in the following style (using “Area Director”, “IAB Chair”, and “Secretariat" as examples):
>>>> 
>>>> if has_role(request.user, ["Area Director", "IAB Chair", "Secretariat"]):
>>>> 	// do something that only area diretor, IAB chair, and secretariat could do, like “Create CodeRequest"
>>>> 
>>>> 
>>>> In CodeMatch, we would like to check permissions in the following way:
>>>> 
>>>> if has_right(request.user, “Create CodeRequest”):
>>>> 	// do something that only authorized people should be able to do, like “Create CodeRequest”
>>>> 
>>>> The “has_right” function would check the database to retrieve the users’ roles and, for each role, check if it has permission to “Create CodeRequest”. In this way, permissions are associated to roles, and roles associated to users.
>>>> 
>>>> Because permissions and roles in CodeMatch are being defined together with the implementation of the system prototype, the use of “has_right” would allow us to assign permissions to roles just changing the database, instead of changing the CodeMatch code if we use “has_role” instead.
>>>> 
>>>> 2) Database
>>>> 
>>>> Today, permissions are listed in table auth_permission. Roles are listed in table group_role. We would need a intermediate table linking permissions to roles, i.e., a table linking author_permissions and group_role. That would allow us to say, for example, that a mentor (inside group_role) can add documents to a codeRequest (i.e., a permission inside auth_permission). Adding this intermediate table (let’s call it role_permission for the moment) would not affect today’s database, although it would expand today’s data model.
>>>> 
>>>> Do you think doing that is ok?
>>>> 
>>>> Best regards,
>>>> 
>>>> Lisandro, Wanderson, Matheus
>>>> 
>>> _______________________________________________
>>> Codematch-develop mailing list
>>> Codematch-develop@ietf.org
>>> https://www.ietf.org/mailman/listinfo/codematch-develop
>