ets-berkeley-edu/calcentral — pull request #2155 by ctweney (2014-02-19 22:40:00+00:00)
Title: CLC-3194 Introducing an abstraction for user roles 

CLC-3194 Introducing an abstraction for user roles (superuser, author, viewer) and their granular permissions based on the pundit gem.

Conceptual model: UserAuth represents the role of a user (superusers, authors, viewers). A UserAuth has a UserAuthPolicy instance that encapsulates the granular permissions (acting as, authoring, clearing cache, etc etc). This gives us future flexibility for more roles or more permission types without investing too much right now.

pundit is so simple as to be irresistible in our main block of code. Unfortunately, rails_admin makes it hard to use anything but CanCan for authorization (you have to write a complete AuthorizationAdapter, and it was complicated). As a compromise I just wrote the Ability class into the rails_admin init helper as a lightweight adapter from our system to CanCan's. If there's a better way to do that, I'm open to suggestions!

Squashed commit of the following:

commit 993ac5d467b39378598037e09ebca34d36da8217
Author: Chris Tweney
Date: Wed Feb 19 14:34:53 2014 -0800

CLC-3194 Rename methods for clarity

commit 276ed8779c4f164d0eea356320436b33f51e4588
Author: Chris Tweney
Date: Wed Feb 19 14:19:59 2014 -0800

CLC-3194 Enforce UserAuthPolicy in rails_admin

commit 137ecd06c8756198e6d591e2577abc045089c7a3
Author: Chris Tweney
Date: Wed Feb 19 11:47:40 2014 -0800

CLC-3194 Give authors and viewers their correct policy attributes, and test these

commit 088b62c703bc9213da8884b4fe9ef00cc482176b
Author: Chris Tweney
Date: Tue Feb 18 16:28:08 2014 -0800

CLC-3194 Add new UserAuth cols to developer seed data file

commit 9834c5a24d182b3c53499b1c08ebc20e4178a5f4
Author: Chris Tweney
Date: Tue Feb 18 15:15:41 2014 -0800

CLC-3194 Seed new UserAuths columns to make bamboo tests runs pass

commit abac371cd02bf233df3d1f7e2e199180ba202f40
Author: Chris Tweney
Date: Tue Feb 18 14:17:51 2014 -0800

CLC-3194 UserAuth table now has is_author, is_viewer columns

commit 950a1dbdd1b3e092e37144b6d5b6525bd66cc3b3
Author: Chris Tweney
Date: Tue Feb 18 13:59:53 2014 -0800

CLC-3194 Add record as passable param for policy getter

commit fe6ed540aeaad2b4499965e77993dd248717815a
Author: Chris Tweney
Date: Thu Feb 13 10:26:59 2014 -0800

CLC-3194 Fix failing RegBlocks tests

commit 9f9eea72ce7084d52bc8a2671eb4eb1d029af79e
Author: Chris Tweney
Date: Thu Feb 13 10:04:21 2014 -0800

CLC-3194 Get rid of some obsolete methods from UserAuth

commit 76e8dcb5d5d461ea5b1c0fd7c4a5123b4ea497a9
Author: Chris Tweney
Date: Thu Feb 13 09:46:10 2014 -0800

CLC-3194 Improve design: UserAuth has-a policy, instead of the reverse

commit 56435ee545a9565cd2211f60c161c8f8e4c854f2
Author: Chris Tweney
Date: Wed Feb 12 14:08:31 2014 -0800

CLC-3194 Clarify future functionality

commit 05b934d68fbad477d0141ea597c7f67162bf7a42
Author: Chris Tweney
Date: Wed Feb 12 14:01:31 2014 -0800

CLC-3194 pundit auth for rails_admin

commit 2f9995871723432ed7eca5f35c1940915dda1ff0
Author: Chris Tweney
Date: Wed Feb 12 13:49:12 2014 -0800

CLC-3194 Spreading pundit auth into the model layer

commit 83d61a89269537d60c78d6736e0f87ae23d00e04
Author: Chris Tweney
Date: Wed Feb 12 12:59:41 2014 -0800

CLC-3194 Simplify UserAuthPolicy constructor

commit a521aff3233809e93ee950263348abaccafee88f
Author: Chris Tweney
Date: Wed Feb 12 10:49:36 2014 -0800

CLC-3194 pundit auth framework for act-as system

commit 7844c0b28bb40dd757ef7e7c8911fe56448d5543
Author: Chris Tweney
Date: Tue Feb 11 15:46:48 2014 -0800

CLC-3194 pundit auth for RoutesListController

commit 1381c3537bb1da29b8a2d1bfb8b3ffd1a5c27013
Author: Chris Tweney
Date: Tue Feb 11 15:37:03 2014 -0800

CLC-3194 pundit auth for RefreshLoggingController

commit 947f1af42405d6ef429c9cb238594a9a9c2652f1
Author: Chris Tweney
Date: Tue Feb 11 15:32:37 2014 -0800

CLC-3194 pundit auth for MyEventsController

commit b14633c999e4228c2dbe38116d91a6eaa3b84448
Author: Chris Tweney
Date: Tue Feb 11 15:22:33 2014 -0800

CLC-3194 pundit auth for MyCampusLinksController

commit f3514205c0ca4e91a6e425a2672c6789fc916edd
Author: Chris Tweney
Date: Tue Feb 11 15:14:51 2014 -0800

CLC-3194 pundit authorization for CanvasUserProvisionController

commit 211be1e08999e88058c45470096fdf74939e6875
Author: Chris Tweney
Date: Tue Feb 11 14:41:21 2014 -0800

CLC-3194 Use pundit to authorize cache clearing