Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
CustomPrivilege.cs
1using System;
2
4{
8 public class CustomPrivilege<T> : IAuthorization<T>
9 {
10 private readonly Func<T, string> calculatePrivilege;
16 public CustomPrivilege(Func<T, string> CalculatePrivilege)
17 {
18 if (CalculatePrivilege is null)
19 throw new ArgumentNullException(nameof(CalculatePrivilege));
20
21 this.calculatePrivilege = CalculatePrivilege;
22 }
23
30 public bool IsAuthorized(T Resource, IHasPrivileges User)
31 {
32 string Privilege = this.calculatePrivilege(Resource);
33 return User.HasPrivilege(Privilege);
34 }
35 }
36}
Authorization based on a custom privilege.
CustomPrivilege(Func< T, string > CalculatePrivilege)
Authorization based on a custom privilege.
bool IsAuthorized(T Resource, IHasPrivileges User)
Checks if an user or object is authorized to perform an action.
Basic authorization interface for objects of type T .
Interface for objects that have privileges.
bool HasPrivilege(string Privilege)
If the object has a given privilege.