ShiroTrie 1.0.5

Apache Shiro styled permission manager.

Install-Package ShiroTrie -Version 1.0.5
dotnet add package ShiroTrie --version 1.0.5
<PackageReference Include="ShiroTrie" Version="1.0.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ShiroTrie --version 1.0.5
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Introduction

A simple .NET Core library to manage Apache Shiro-styled permissions.

Inspired by the shiro-trie npm package and Apache Shiro styled permissions.

Installation

$ dotnet add package ShiroTrie

Example

var permissions = new[]
{
   "file:read",
   "file:write",
   "directory:delete,create",
   "image:png,jpeg:read,write",
   "audio:mp3,ogg:high,low:sample",
   "user:*",
   "mail",
   "tty"
};

// add permissions to trie
var trie = new PermissionTrie();
trie.Add(scopes);


// test permissions
var checks = new[]
{
   "file:read",
   "file:create",
   "file:update",
   "file:delete",
   "printer",
   "scanner:read",
   "image:png:read",
   "audio:mp3:high:sample",
   "audio:mp3:high:sample:once",
   "user:delete",
   "user:*",
   "user:create",
   "mail",
   "mail:delete",
   "mail:delete:once",
   "bash-tty",
};

foreach (var check in checks)
{
   Console.WriteLine("{0} = {1}", check, trie.Check(check));
}


/*
>  Output:
file:read = True
file:create = False
file:update = False
file:delete = False
printer = False
scanner:read = False
image:png:read = True
audio:mp3:high:sample = True
audio:mp3:high:sample:once = True
user:delete = True
user:* = True
user:create = True
mail = True
mail:delete = True
mail:delete:once = True
bash-tty = False
*/

Introduction

A simple .NET Core library to manage Apache Shiro-styled permissions.

Inspired by the shiro-trie npm package and Apache Shiro styled permissions.

Installation

$ dotnet add package ShiroTrie

Example

var permissions = new[]
{
   "file:read",
   "file:write",
   "directory:delete,create",
   "image:png,jpeg:read,write",
   "audio:mp3,ogg:high,low:sample",
   "user:*",
   "mail",
   "tty"
};

// add permissions to trie
var trie = new PermissionTrie();
trie.Add(scopes);


// test permissions
var checks = new[]
{
   "file:read",
   "file:create",
   "file:update",
   "file:delete",
   "printer",
   "scanner:read",
   "image:png:read",
   "audio:mp3:high:sample",
   "audio:mp3:high:sample:once",
   "user:delete",
   "user:*",
   "user:create",
   "mail",
   "mail:delete",
   "mail:delete:once",
   "bash-tty",
};

foreach (var check in checks)
{
   Console.WriteLine("{0} = {1}", check, trie.Check(check));
}


/*
>  Output:
file:read = True
file:create = False
file:update = False
file:delete = False
printer = False
scanner:read = False
image:png:read = True
audio:mp3:high:sample = True
audio:mp3:high:sample:once = True
user:delete = True
user:* = True
user:create = True
mail = True
mail:delete = True
mail:delete:once = True
bash-tty = False
*/

  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.5 714 3/27/2019
1.0.4 572 10/18/2018
1.0.3 504 7/4/2018
1.0.2 491 5/8/2018
1.0.1 389 5/7/2018
1.0.0 407 5/4/2018