Giter VIP home page Giter VIP logo

Comments (4)

rabbal avatar rabbal commented on June 16, 2024 3

1- GetOrAdd method of ConcurrentDictionary is not thread-safe
2- You right, also I want to proccess just permission policies. I don't use enum for permission; instead I use const strings with short length.

    public static class PermissionNames
    {
        public const string Blogs_View = "10"; // For minimize token/cookie size
        public const string Blogs_Create = nameof(Blogs_Create);
        public const string Blogs_Edit = nameof(Blogs_Edit);
        public const string Blogs_Delete = nameof(Blogs_Delete);
    }

Thank you @JonPSmith for your idea about minimize cookie size by using series of integers to store as permissions

from permissionaccesscontrol.

JonPSmith avatar JonPSmith commented on June 16, 2024 2

Hi @rabbal,

Wow, its hard to know what is thread safe. Its really not obvious that the GetOrAdd method of ConcurrentDictionary is not thread-safe I have used ConcurrentDictionary thinking that the Concurrent part of the name meant it was thread safe. Thanks for pointing that out and providing a a solution.

I'm busy at the moment so I will leave this open until I fix it.

from permissionaccesscontrol.

JonPSmith avatar JonPSmith commented on June 16, 2024 1

HI @rabbal ,

Thanks for closing this issue. You see I fixed it but I forgot to close the issue.

from permissionaccesscontrol.

JonPSmith avatar JonPSmith commented on June 16, 2024

Hi @rabbal,

Thank you so much for pointing that out - didn't know that. I have a couple of questions:

  1. Why do you use a LazyConcurrentDictionary rather than a ConcurrentDictionary. I would have thought that the dictionary would be used most of the time (unless you have a lot of your own policies registered via DI).
  2. You have added a check for a check on the start of the policy name. I assume you add a prefix to all the Enums, or alter the [HasPermission] attribute. I assume this is just to improve performance - correct?

from permissionaccesscontrol.

Related Issues (2)

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.