Closed giovanni-bertoncelli closed 3 years ago
Angular version: 11.2.4 Typescript version: 4.1.5
@Zxilly @Gabriel-403
ok,i know
@giovanni-bertoncelli Could you please a minimal reproduce example? with JSFiddle or something else
Sadly I can't reproduce the issue online... this is the maximum I can get: https://codesandbox.io/s/casbin-angular-issue-qjosh?file=/src/typings.d.ts
I think I've found where the issue is: The problem occurs when trying to access the "stream" API in csv-parse module. Is there any way to bypass that or avoid to use the csv-parse module?
We have a platform independent version at https://github.com/casbin/casbin.js/tree/v1, but it is still work in progress and not production ready
@giovanni-bertoncelli Do you think this can solve your problem? I an make a patch with this.
I see... Unfortunately casbin.js
does not satisfy my requirements for frontend ACL enforcement since the RBAC model is way more complex than the package can handle. I'm trying to find a way around this in order to use casbin on Angular environment but by enforcing only rules given by the JWT. I let you know if there is some development 👍🏻
@giovanni-bertoncelli Plz view casbin.js at v1
branch. casbin.js is under a totally refactor and will have the exactly funtion like node-casbin
, but platform independent.
@giovanni-bertoncelli We will later release it with something like casbin.js@next
. If you do need it, I think we can move this forward asap.
Sorry I haven't noticed that you where talking about a new version, now I see :)
Well, I'll be glad to try it.
If you can make a @next
tag in a short time that would be amazing!
@Zxilly In the meanwhile is there a way to install the v1 version? I've tried by running npm i casbin/casbin.js#v1
but it does not download correctly since it should build from scratch...
@giovanni-bertoncelli I have been working with another community member and a new version will be released within 24 hours
Ok thanks!
@giovanni-bertoncelli I looked at the online demo, it does work.
@nodece Yes, as I said I can't reproduce the issue online, probably for compilation configuration differences. The workaround is to redirect the "stream" package to the readable-stream one. I can close this issue and wait for the "@next" release of casbin.js...
I don't think using that package is a good idea since the last update is from 7 years ago. As I said, I've solved the issue with the redirect to "readable-stream" package. I'll close this now.
@giovanni-bertoncelli thanks for your suggestion, we will improve this.
Let me know when the new version will be released :)
@giovanni-bertoncelli Once the new version is released, I will ping you.
@nodece @Zxilly any news? :)
@ghaiklor We are removing the dependency on csv-parse
.But we are still discussing on the implementation of some standards
Maybe this can be a valid alternative: https://www.papaparse.com/
Hello @giovanni-bertoncelli, casbin.js@next
has been released on NPM, you can use yarn add casbin.js@next
or npm install casbin.js@next --save
to add this to your project, how to use:
import { newEnforcer, newModel, MemoryAdapter } from 'casbin.js';
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) && r.obj == p.obj && r.act == p.act
`);
const adapter = new MemoryAdapter(`
p, alice, data1, read
p, bob, data2, write
p, data2_admin, data2, read
p, data2_admin, data2, write
g, alice, data2_admin
`);
const enforcer = await newEnforcer(model, adapter);
When importing casbin in a typescript project for Angular I get this error:
For the
Model
class I've solved by importing like this:But for
newEnforcer
there is no way to work around that issue. Am I missing something?