ueberauth / guardian

Elixir Authentication
MIT License
3.44k stars 381 forks source link

Guardian.Permissions.Bitwise - "at least" the permission #392

Closed oskar1233 closed 7 years ago

oskar1233 commented 7 years ago

When plugging Guardian.Permissions.Bitwise should ensure and one_of check for permission map to be identical or contain at least specified permissions?

Now it behaves the first way - when I plug Guardian.Permissions.Bitwise, ensure: %{superuser: [:mod]} the permissions can't be higher, e. g. MyApp.Guardian.encode_and_sign(user, %{}, permissions: %{superuser: [:mod, :read]}) will cause {:unauthorized, :unauthorized}.

In my opinion it's unwanted behaviour. I suspect to plug Guardian.Permissions.Bitwise, ensure: %{superuser: [:mod]} and plug Guardian.Permissions.Bitwise, ensure: %{superuser: [:read]} to authorize positively when I specify permissions: %{superuser: [:mod, :read]}.

Thanks for your attention & regards.

doomspork commented 7 years ago

@oskar1233 do you have some example code we could look at?

hassox commented 7 years ago

Agreed this should be at least. @oskar1233 do you have an example setup that shows this behaviour?

hassox commented 7 years ago

I found the issue I believe. @oskar1233 can you confirm that this fixes the issue for you?

https://github.com/ueberauth/guardian/pull/394

oskar1233 commented 7 years ago

@hassox It does - thank you very much.

hassox commented 7 years ago

Great! It's merged. We'll cur a release soon