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

Dependency issues in Angualr #177

Closed
fahussain opened this issue Aug 26, 2021 · 21 comments
Closed

Dependency issues in Angualr #177

fahussain opened this issue Aug 26, 2021 · 21 comments
Assignees
Labels
bug Something isn't working

Comments

@fahussain
Copy link

fahussain commented Aug 26, 2021

I tried using casbin.js in my Angular project but it seems casbin is dependent on some core node.js modules, path stream and fs to be more specific. Angular 12 uses webpack 5 which does not allow core node.js modules to be included in a web app. I tried some workarounds but finally gave up since I found out that casbin.js does not support RBAC with domains as mentioned here #31.

@casbin-bot
Copy link
Member

@nodece @Zxilly @Gabriel-403

@casbin-bot casbin-bot added the question Further information is requested label Aug 26, 2021
@nodece
Copy link
Member

nodece commented Aug 26, 2021

@fahussain do you use the casbin.js@next? could you provide the model and policy?

@fahussain
Copy link
Author

fahussain commented Aug 26, 2021

For my server side I use NestJS and yes casbin is working there. This is my model:

[request_definition]
r = subject, tenant, object, action

[policy_definition]
p = subject, tenant, object, action

[role_definition]
g = _, _, _
g2 = _, _, _

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

[matchers]
m = g(r.subject, p.subject, r.tenant) && g2(r.object, p.object, r.tenant) && r.tenant == p.tenant && r.action == p.action

I am not sure what you mean by casbin.js@next. I was hoping to use casbin.js on the frontdend in Angular to implement the policies. My policies are going to be dynamic and quite large, generated by an application in which admins can add Tenants, Roles, Users, Objects, Actions, Policies etc... On the server I am using TypeOrm adapter to store policies in MySQL.

@Zxilly
Copy link
Contributor

Zxilly commented Aug 27, 2021

@fahussain plz refer to https://github.com/casbin/casbin.js/tree/v1 to get the infomation about casbin.js@next. It is a totally refactor version and can work cross platform, like Angular.
I suggest designing your own protocol for exchanging permission data between the front and back ends. The communication protocols pre-built in legacy casbin.js are not reliable.

@Zxilly
Copy link
Contributor

Zxilly commented Aug 27, 2021

@fahussain

I tried using casbin.js in my Angular project but it seems casbin is dependent on some core node.js modules

In short, casbin.js@next is cross-platform version of node-casbin.

@hsluoyz hsluoyz added bug Something isn't working and removed question Further information is requested labels Dec 13, 2021
@giovanni-bertoncelli
Copy link

I have the same issue here. The next release is not platform indipendent.

@hsluoyz
Copy link
Member

hsluoyz commented Mar 8, 2022

@nodece

@nodece
Copy link
Member

nodece commented Mar 8, 2022

Can't casbin.js@next solve this?

@giovanni-bertoncelli
Copy link

giovanni-bertoncelli commented Mar 8, 2022

Workaround:

  • Install path
  • Add decs.d.ts file with this line: declare module "path";
  • Link it by adding it to the tsconfig.json file on the include prop

Nope, casbin.js@next version does not resolve this without that workaround.

@nodece
Copy link
Member

nodece commented Mar 8, 2022

@giovanni-bertoncelli Could you provide a repository for reproduce this issue?

@danverde
Copy link

danverde commented Mar 18, 2022

Experiencing the same thing. Here's a repo: https://github.com/danverde/CasbinJS-React/tree/broken
I did make sure to install casbinjs@next. Looks like it ended up installing 1.0.0, rather than 1.0.1 that I got by installing casbin.js

@hsluoyz
Copy link
Member

hsluoyz commented Mar 19, 2022

@nodece

@nodece
Copy link
Member

nodece commented Mar 19, 2022

Thanks @danverde, I know how to resolve it.

@nodece
Copy link
Member

nodece commented Mar 19, 2022

Because we are incorrect design, this version is confusing, we are decided to improve the node-casbin repo, the next version casbin has been released, the casbin@beta can be available on NPM.

but this version number is incorrect, should be 6.0.0-beta.x, not 5.14.0-beta.x. This version is working on React, and Ng.

@danverde
Copy link

danverde commented Mar 21, 2022

@nodece So I need to use version 6.0.0-beta.x of the node-casbin repo rather than the casbin.js repo? or is/will there be a release of casbin.js built off the correct version of node-casbin?

@nodece
Copy link
Member

nodece commented Mar 21, 2022

So I need to use version 6.0.0-beta.x of the node-casbin repo rather than the casbin.js repo?

Yes, you can install this by yarn add casbin@beta, then select the 5.14.0-beta.3.

or is/will there be a release of casbin.js build off the correct version of node-casbin?

We don't continue to release the casbin.js to instead of node-casbin.

@danverde
Copy link

danverde commented Mar 21, 2022

Installing casbin@next doesn't work:
image

And node-casbin 5.14.0-beta.3 doesn't work in the browser either

@danverde
Copy link

I was able to get casbin.js running by ejecting the react project and then updating the webpack config file to disable source maps for node_modules and disabling the polyfill for path.

@hsluoyz
Copy link
Member

hsluoyz commented Mar 22, 2022

@nodece

@nodece
Copy link
Member

nodece commented Mar 22, 2022

Sorry, casbin@beta is correct.

@nodece
Copy link
Member

nodece commented Mar 22, 2022

Installing casbin@next doesn't work: image

And node-casbin 5.14.0-beta.3 doesn't work in the browser either

Could you provide the log that doesn't work in the browser?

@hsluoyz hsluoyz closed this as completed Mar 26, 2022
@hsluoyz hsluoyz removed this from Node-Casbin Easy Tasks in Casbin Easy Tasks for Beginners/Student Applicants Apr 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants