correct-apricot
correct-apricot11mo ago

could not find the login username and password of the examples/pixels-admin, any clues?

I am trying to find a complete example about casbin for RBAC, there are only two in the official examples, one of these are pixels-admin, but I did not find the login info, could not try it out. any hint?
5 Replies
kapa.ai
kapa.ai11mo ago
Hi @crosssz. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Sure, I can guide you through the process of setting up Role Based Access Control (RBAC) with Casbin in refine. Firstly, you need to install Casbin in your project. You can do this by running the following command in your terminal:
npm install casbin
npm install casbin
Source (https://refine.dev/docs/advanced-tutorials/access-control/) Then, you can use the accessControlProvider from refine to implement RBAC. Here is an example of how you can define your Casbin model and policies:
import { newModel, StringAdapter } from "casbin";

export const model = newModel(`
[request_definition]
r = sub, obj, act

[policy_definition]
p = sub, obj, act

[role_definition]
g = _, _

[policy_effect]
e = some(where (p.eft == allow))

[matchers]
m = g(r.sub, p.sub) && keyMatch(r.obj, p.obj) && regexMatch(r.act, p.act)
`);

export const adapter = new StringAdapter(`
p, admin, users, list
p, admin, canvases, (list)|(edit)|(delete)

p, editor, users, list
p, editor, canvases, (list)|(edit)
`);
import { newModel, StringAdapter } from "casbin";

export const model = newModel(`
[request_definition]
r = sub, obj, act

[policy_definition]
p = sub, obj, act

[role_definition]
g = _, _

[policy_effect]
e = some(where (p.eft == allow))

[matchers]
m = g(r.sub, p.sub) && keyMatch(r.obj, p.obj) && regexMatch(r.act, p.act)
`);

export const adapter = new StringAdapter(`
p, admin, users, list
p, admin, canvases, (list)|(edit)|(delete)

p, editor, users, list
p, editor, canvases, (list)|(edit)
`);
Source (https://refine.dev/blog/refine-pixels-6/) In this example, the admin role can list, edit, and delete canvases, and both admin and editor roles can list users. You can find a complete example of how to use refine and Casbin to simplify access control management throughout your application in the refine Access Control Provider documentation (https://refine.dev/docs/api-reference/core/providers/accessControl-provider/). As for the login information for the Pixels Admin app, it seems like the provided extracts do not contain this information. However, you can check out the source code of the Pixels Admin app here (https://github.com/refinedev/refine/tree/master/examples/pixels-admin) to find more details. If you want to run the example on your local machine, you can use the following command:
npm create refine-app@latest -- --example access-control-casbin
npm create refine-app@latest -- --example access-control-casbin
Source (https://refine.dev/docs/examples/access-control/casbin/) I hope this helps! Let me know if you have any other questions. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai11mo ago
<@850615794185666562> kapa.ai is still learning and improving, please let us know how it did by reacting below
metropolitan-bronze
metropolitan-bronze11mo ago
Hello @crosssz you can login with this credentials email: demo@refine.dev password: demodemo
correct-apricot
correct-apricot11mo ago
@alicanerdurmaz thanks for prompt reply, it works! I also want to check admin user, where can I find it in this public example project?
metropolitan-bronze
metropolitan-bronze11mo ago
GitHub
refine/examples/pixels-admin at next · refinedev/refine
Build your React-based CRUD applications, without constraints. 🌟 Star to support our work! - refinedev/refine