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

Get List of Roles for App #110

Closed
5 tasks done
nelsonic opened this issue Aug 7, 2020 · 4 comments
Closed
5 tasks done

Get List of Roles for App #110

nelsonic opened this issue Aug 7, 2020 · 4 comments
Assignees

Comments

@nelsonic
Copy link
Member

nelsonic commented Aug 7, 2020

In order to allow custom roles for any App that uses Auth, we need a way of getting the list of roles that are relevant to that App once during application startup. The list should be cached in memory to speed up in-app role checking. Such that a call to RBAC.has_role(person, "hotel_guest") dwyl/rbac#2 should take less than a microsecond (zero network latency).

Todo

@nelsonic nelsonic self-assigned this Aug 20, 2020
@nelsonic nelsonic transferred this issue from dwyl/rbac Sep 11, 2020
@nelsonic
Copy link
Member Author

Dummy request already working: http://localhost:4000/approles/:client_id
image

Now I just need to work on restricting to the roles of the app via :client_id

@nelsonic
Copy link
Member Author

I've naively tried doing the caching of the approles list in the auth_plug and was immediately reminded (obvs in retrospect) that any function put in a plug runs on each/every request. again, obvs. So instead, we need to run our GET /approles/:client_id in a config.exs or "startup" script.

Reading: https://moosecode.nl/blog/where-do-i-put-startup-code-in-elixir

@nelsonic
Copy link
Member Author

OK. We have a get_approles/2 function working in:
https://github.com/dwyl/rbac/blob/e05a58a7c70dcad9bd0350d516d1e01ea7c2d452/lib/rbac.ex#L41-L49

Next we need to cache the list of roles in ETS, going to borrow some code from:
https://github.com/club-soda/club-soda-guide/search?q=ets&unscoped_q=ets

Tomorrow. 😴

nelsonic added a commit to dwyl/rbac that referenced this issue Sep 14, 2020
nelsonic added a commit that referenced this issue Sep 14, 2020
@nelsonic
Copy link
Member Author

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

No branches or pull requests

1 participant