Comments (4)
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.
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.
HI @rabbal ,
Thanks for closing this issue. You see I fixed it but I forgot to close the issue.
from permissionaccesscontrol.
Hi @rabbal,
Thank you so much for pointing that out - didn't know that. I have a couple of questions:
- Why do you use a
LazyConcurrentDictionary
rather than aConcurrentDictionary
. 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). - 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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from permissionaccesscontrol.