Giter Site home page Giter Site logo

Comments (13)

hsluoyz avatar hsluoyz commented on May 27, 2024

@basakest

from php-casbin.

basakest avatar basakest commented on May 27, 2024

Can you provide more detailed information? I tried to implement similar logic in the middleware, but failed to reproduce the problem.
Screen Shot 2021-12-03 at 6 08 54 PM

from php-casbin.

leeqvip avatar leeqvip commented on May 27, 2024

@490626721 Please provide your model file and all policies .

from php-casbin.

490626721 avatar 490626721 commented on May 27, 2024

sql data
1638757113(1)

thinphp6.0 middleware code
1638757196(1)

from php-casbin.

490626721 avatar 490626721 commented on May 27, 2024

@basakest

from php-casbin.

490626721 avatar 490626721 commented on May 27, 2024

api error trace
1638760960(1)

from php-casbin.

leeqvip avatar leeqvip commented on May 27, 2024

@490626721 This does not tell the problem. Have you made any changes to the adapter?
I guess it may be related to model configuration or loading policies, can you provide a tiny sample?

from php-casbin.

490626721 avatar 490626721 commented on May 27, 2024

adapter file

[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 || r.sub == "root"

1638839423(1)

casbinConfig:

public function casbinConfig (): Enforcer
    {
        $config = [
            'type'     => 'mysql', // mysql,pgsql,sqlite,sqlsrv
            'hostname' => Env::get('database.HOSTNAME'),
            'database' => Env::get('database.DATABASE'),
            'username' => Env::get('database.USERNAME'),
            'password' => Env::get('database.PASSWORD'),
            'hostport' => Env::get('database.HOSTPORT'),
        ];
        $adapter = DatabaseAdapter::newAdapter($config);
        $e =  new Enforcer(config_path() . 'casbin.conf', $adapter);
        return $e;
    }

1638839452

from php-casbin.

490626721 avatar 490626721 commented on May 27, 2024

I found the problem:
1638867431(1)
error file path: casbin\src\Persist\AdapterHelper.php 32 line

Using The getcsv () method causes the program to miss some commas

from php-casbin.

490626721 avatar 490626721 commented on May 27, 2024

@techoner

from php-casbin.

leeqvip avatar leeqvip commented on May 27, 2024

For str_getcsv(), please refer to: https://www.php.net/manual/en/function.str-getcsv.php

Note:

The locale settings are taken into account by this function. If LC_CTYPE is e.g. en_US.UTF-8, strings in one-byte encodings may be read wrongly by this function.

In view of this, we need to use loadPolicyArray in the DatabaseAdapter. Migrate to php-casbin/database-adapter#19

@490626721 By the way, I recommend using dbal-adapter instead of database-adapter.

from php-casbin.

490626721 avatar 490626721 commented on May 27, 2024

For str_getcsv(), please refer to: https://www.php.net/manual/en/function.str-getcsv.php

Note:

The locale settings are taken into account by this function. If LC_CTYPE is e.g. en_US.UTF-8, strings in one-byte encodings may be read wrongly by this function.

In view of this, we need to use loadPolicyArray in the DatabaseAdapter. Migrate to php-casbin/database-adapter#19

@490626721 By the way, I recommend using dbal-adapter instead of database-adapter.

OK, I'll change it now 😄

from php-casbin.

leeqvip avatar leeqvip commented on May 27, 2024

Closed as resolved.

from php-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.