Giter Site home page Giter Site logo

Comments (10)

hsluoyz avatar hsluoyz commented on June 5, 2024 2

@johnsonjo4531 I think we need your PR:) Thanks for doing this

from node-casbin.

casbin-bot avatar casbin-bot commented on June 5, 2024

@nodece @Zxilly @Shivansh-yadav13

from node-casbin.

nodece avatar nodece commented on June 5, 2024

Could you provide your case?

from node-casbin.

hsluoyz avatar hsluoyz commented on June 5, 2024

@IonVillarreal plz provide the full code, Casbin model, policy, request and response (expected and got)

from node-casbin.

IonVillarreal avatar IonVillarreal commented on June 5, 2024

Hi, sorry for the delay, I attached the snippet of the code where the error happened

import Head from "next/head";
import Image from "next/image";
import { Inter } from "next/font/google";
import styles from "@/styles/Home.module.css";
import { useEffect } from "react";
import {
  Enforcer,
  newEnforcer,
  newModelFromString,
  StringAdapter,
} from "casbin";


export const basicModel = `
[request_definition]
r = sub, obj, act

[policy_definition]
p = sub, obj, act

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

[matchers]
m = (r.sub == p.sub || p.sub == "*") && keyMatch2(r.obj, p.obj) && regexMatch(r.act, p.act)
`;
export const basicPolicy = `g, admin, ADMINISTRADOR`;

export default function Home() {
  const iniciar = async () => {
    const politicas: string[][] = []; // TODO: add
    const model = newModelFromString(basicModel);
    const policy = new StringAdapter(basicPolicy);
    const enforcerTemp: Enforcer = await newEnforcer(model, policy);
    for await (const p of politicas) {
      await enforcerTemp.addPolicy(p[0], p[1], p[2], p[3], p[4], p[5]);
    }
    return enforcerTemp;
  };

  useEffect(() => {
    iniciar();
  }, []);

  return (
    <>
      <Head>
        <title>Create Next App</title>
      </Head>
      <main className={styles.main}>
        <div className={styles.description}>
          <div>
            <a
              href="https://vercel.com?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
              target="_blank"
              rel="noopener noreferrer"
            >
              By{" "}
              <Image
                src="/vercel.svg"
                alt="Vercel Logo"
                className={styles.vercelLogo}
                width={100}
                height={24}
                priority
              />
            </a>
          </div>
        </div>
      </main>
    </>
  );
}

image

The error happens in Safari v16.3, but not happen in Safari v16.4 that released today

from node-casbin.

IonVillarreal avatar IonVillarreal commented on June 5, 2024

It still happens in v5.26.0 in Safari v16.3 but it doesn't happen in Safari v16.4

from node-casbin.

hsluoyz avatar hsluoyz commented on June 5, 2024

@johnsonjo4531 please take a look as it is caused by: #439

from node-casbin.

johnsonjo4531 avatar johnsonjo4531 commented on June 5, 2024

Yes, this is definitely my fault πŸ˜…. I used an ES2018 feature RegExp Negative LookBehind to implement the two lines of RegExp I used in my PR. I should have let you all know that it wouldn't work on older browsers. It should work on all modern (non End Of Life) Node.js versions though as far as I'm aware. I don't have much time to assist with the fix. But these two lines in ./src/util/util.ts are what need to be changed to not use back references. If they are changed back to what they used to be they will fail the tests I added to fix the bug in #438. See this series of answers on stack overflow for possible answers to not use the negative lookbehind.

from node-casbin.

johnsonjo4531 avatar johnsonjo4531 commented on June 5, 2024

@hsluoyz hopefully the above is enough info to get you guys going. I'll try to help you tomorrow if you can't get this by then just ping me, thanks.

from node-casbin.

github-actions avatar github-actions commented on June 5, 2024

πŸŽ‰ This issue has been resolved in version 5.26.1 πŸŽ‰

The release is available on:

Your semantic-release bot πŸ“¦πŸš€

from node-casbin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.