Git Product home page Git Product logo

Comments (8)

hsluoyz avatar hsluoyz commented on May 22, 2024

Casbin.NET follows Golang's Casbin's work flow. So please send a GitHub issue to: https://github.com/casbin/casbin/blob/master/internal_api.go#L22 first

from casbin.net.

AaqibAhamed avatar AaqibAhamed commented on May 22, 2024

I have go through GoLang's work flow.I have following doubts.

if !ruleAdded {
		return ruleAdded, nil
	}

it says if not equal to ruleAdded return become true or not ?? What does return ruleAdded mean here?Does it give true or false ?

from casbin.net.

divy9881 avatar divy9881 commented on May 22, 2024

This control structure means, that if ruleAdded is false, it means if the rule is not added to the memory, the function returns false, nil(error).

from casbin.net.

AaqibAhamed avatar AaqibAhamed commented on May 22, 2024

This control structure means, that if ruleAdded is false, it means if the rule is not added to the memory, the function returns false, nil(error).
@divypatel9881
Now clear.Thanks for the response.

from casbin.net.

AaqibAhamed avatar AaqibAhamed commented on May 22, 2024

In InternalEnforcer.cs, there are 3 methods add or remove policy data. All these methods will add or delete data in memory first then call adapter to perform the mutation of data in data store behind the adapter.

It will cause data inconsistency issue if no revert or rollback logic in all those methods. Please refers to the bold area of the partial code below:

bool ruleAdded = model.AddPolicy(sec, ptype, rule);
if (!ruleAdded)
{
    return false;
}

if (adapter != null && autoSave)
{
    try
    {
        await adapter.AddPolicyAsync(sec, ptype, rule);
    }
    catch (NotImplementedException)
    {
    }
    catch (Exception e)
    {
       **// rollback logic to revert the related memory data**
        throw e;
    }

    if (watcher != null)
    {
        // error intentionally ignored
        watcher.Update();
    }
}

Why not catching for NotImplementedException ? Don't we need to show at lease error message ?

from casbin.net.

hsluoyz avatar hsluoyz commented on May 22, 2024

I think we agreed on updating adapter first, then update memory in Golang: casbin/casbin#415 (comment). Let's follow the similar pattern in .NET. Can anyone make a PR for it?

from casbin.net.

hsluoyz avatar hsluoyz commented on May 22, 2024

@huazhikui @xcaptain @sagilio @twchiam can you work on this one?

from casbin.net.

hsluoyz avatar hsluoyz commented on May 22, 2024

@twchiam merged in: #28

from casbin.net.

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.