项目作者: jyotman

项目描述 :
Role Based Access Control (RBAC) authorisation library for Scala
高级语言: Scala
项目地址: git://github.com/jyotman/cerberus.git
创建时间: 2017-11-26T18:41:11Z
项目社区:https://github.com/jyotman/cerberus

开源协议:MIT License

下载


Cerberus



Yarn

Build Status

Lightweight Role and Attribute based Access Control for Scala.

Easy to use DSL for assigning permissions to different roles.

Read more about RBAC and ABAC.

Installation

  1. resolvers += Resolver.bintrayRepo("jyotman","maven")
  2. libraryDependencies += "xyz.jyotman" %% "cerberus" % "0.0.5"

Basic Example

  1. import xyz.Types.Data
  2. import xyz.jyotman.Cerberus
  3. import xyz.jyotman.Dsl._
  4. val data: Data =
  5. ("user" can (
  6. ("read" any "project" attributes "title" & "description" & "!createdOn") also
  7. ("read" own "project" attributes "title" & "description") also
  8. ("create" own "project") also
  9. ("update" own "profile")
  10. )) and
  11. ("curator" can (
  12. ("read" any "project") also
  13. ("update" any "project") also
  14. ("delete" any "project")
  15. ))
  16. val cerberus = Cerberus(data)
  17. cerberus.can("user", "create", "project").any // false
  18. cerberus.can("user", "create", "project").own // true
  19. cerberus.can("user", "read", "project").any(List("createdOn")) // false
  20. cerberus.can("user", "read", "project").any(List("title", "description")) // true

Documentation

Work in Progress

Inspired by Access Control.