duanbipu1720 2012-09-26 17:26
浏览 18

是否有支持细粒度访问控制方法的PHP太阳能风格的uri-router? [关闭]

There are at least a dozen well written, permissibly-licensed router packages out there (alloy, aura, solar, symphony, etc), but I have yet to come across one that includes some form of fine-grained (ie, resource or finer) access control.

Important features:

  • Solar style routes
  • Loose couplining to authentication mechanisms (this should only handle authorization)
  • Groups as well as users
  • Scoping capability (ie, you can access resources you have some kind of relationship with, but not ones of the same type that you don't)

I would be more than willing to contribute to a project that wanted to do this, but would rather not reinvent the wheel if someone is already working on this.

Specifically, given a route and some form of authentication, I want have the access controller decide to:

  1. Give the user that resource
  2. Give that user a redacted version of that resource
  3. Suggest authenticating/re-authenticating with different credentials
  4. In the absence of authentication, not confirm or deny the existence of the resource

As a bonus, having a way to request the full resource from the redacted one would be great; eg, you pull up a person resource, and their SSN/DOB are redacted. When you hit a "show" button, it logs it and then gives you the resource with those in it.

Edit: This does not actually have to be the router itself, but it seems like it would make sense to use the same kind of addressing to control access. It's possible that this could be implemented as a standalone tool that is executed post-routing, pre-dispatch.

  • 写回答

1条回答 默认 最新

  • dongyao1915 2012-09-27 12:34
    关注

    Routing, authentication and authorization are three separate parts of application. Each of those steps would be part of the bootstrap state for application.

    1. try to acquire user's identity from authentication token in session or cookies
    2. route the incoming request
    3. check if user is authorized to execute command, that was provided by router

    I usually do the authorization checks by wrapping the target's instance in decorator, which provides me with access control over any structure, that require it. The implementation is usually similar to one described in this example.

    When access is denied or if method is not found, you just throw the appropriate exception.

    This also provides the added benefit of working well with dependency injection. When you inject such decorated object, any method, that gets performed on it, will go through access control.

    评论

报告相同问题?

悬赏问题

  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制