Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposition: introduce scala dsl #17

Open
ottovw opened this issue Nov 30, 2015 · 1 comment
Open

proposition: introduce scala dsl #17

ottovw opened this issue Nov 30, 2015 · 1 comment

Comments

@ottovw
Copy link

ottovw commented Nov 30, 2015

The current deadbolt scala api feels very java-like. however it should be trivially easy to add a lightweight scala dsl for permission building to create a better api.

Instead of:

// subject must have the "foo" AND "bar" roles 
def restrictedFunctionB = actionBuilder.RestrictAction("foo", "bar").defaultHandler() { Ok(accessOk()) }

// subject must have the "foo" OR "bar" roles 
def restrictedFunctionC = actionBuilder.RestrictAction(List(Array("foo"), Array("bar"))).defaultHandler() { Ok(accessOk()) }

The API could look like this (even without changing the current api, by adding some dsl builders:

// Foo and Bar are types / enums / case classes ... or just stay string, both would work
// subject must have the "foo" AND "bar" roles 
def restrictedFunctionB = RestrictAction(Foo and Bar) { Ok(accessOk()) }

// subject must have the "foo" OR "bar" roles 
def restrictedFunctionC = RestrictAction(Foo or Bar) { Ok(accessOk()) }
@schaloner
Copy link
Collaborator

A very valid criticism, and a very interesting idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants