Tolitech.Application.Authorization 1.0.0-preview.4

This is a prerelease version of Tolitech.Application.Authorization.
dotnet add package Tolitech.Application.Authorization --version 1.0.0-preview.4
                    
NuGet\Install-Package Tolitech.Application.Authorization -Version 1.0.0-preview.4
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Tolitech.Application.Authorization" Version="1.0.0-preview.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Tolitech.Application.Authorization" Version="1.0.0-preview.4" />
                    
Directory.Packages.props
<PackageReference Include="Tolitech.Application.Authorization" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Tolitech.Application.Authorization --version 1.0.0-preview.4
                    
#r "nuget: Tolitech.Application.Authorization, 1.0.0-preview.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Tolitech.Application.Authorization@1.0.0-preview.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Tolitech.Application.Authorization&version=1.0.0-preview.4&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Tolitech.Application.Authorization&version=1.0.0-preview.4&prerelease
                    
Install as a Cake Tool

Tolitech.Application.Authorization

Overview

Tolitech.Application.Authorization is a lightweight .NET library for defining and retrieving application permissions using marker interfaces and reflection. It helps you manage permissions in a clean, organized, and scalable way.

Features

  • Marker Interface for Permissions: Use the IPermissionDefinition interface to mark classes that define permissions.
  • Reflection-Based Retrieval: Retrieve all permission definitions from specified assemblies using reflection.
  • Easy Integration: Seamlessly integrate with your .NET applications.
  • Centralized Permission Management: Keep all permission strings in one place, reducing hardcoding and improving maintainability.

Main Interface

IPermissionDefinition

A marker interface to identify classes that contain permission definitions.

Usage

1. Define Permissions

Create classes implementing IPermissionDefinition to define your permissions:

namespace MyApplication.Permissions
{
    public class UserPermissions : IPermissionDefinition
    {
        public const string ViewUsers = "Permissions.Users.View";
        public const string EditUsers = "Permissions.Users.Edit";
    }

    public class AdminPermissions : IPermissionDefinition
    {
        public const string ManageRoles = "Permissions.Admin.ManageRoles";
        public const string ViewLogs = "Permissions.Admin.ViewLogs";
    }
}

2. Retrieve Permissions

Use PermissionUtility.GetAllPermissions to retrieve all permissions from one or more assemblies:

using System.Reflection;
using Tolitech.Application.Authorization;

Assembly assembly = Assembly.GetExecutingAssembly();
var permissions = PermissionUtility.GetAllPermissions(assembly);

foreach (var permission in permissions)
{
    Console.WriteLine(permission);
}

Output:

Permissions.Users.View
Permissions.Users.Edit
Permissions.Admin.ManageRoles
Permissions.Admin.ViewLogs

How to Integrate

  1. Reference Tolitech.Application.Authorization in your project.
  2. Define your permissions in classes implementing IPermissionDefinition.
  3. Use the provided API to retrieve and manage permissions as needed.

Summary

Tolitech.Application.Authorization centralizes and simplifies permission management in .NET applications, making your codebase cleaner, more maintainable, and scalable.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net9.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Tolitech.Application.Authorization:

Package Downloads
Tolitech.Infrastructure.Authorization

The library provides implementations for managing authorization logic. It includes classes and utilities for handling permissions, attribute-based authorization, and configuring authorization policies.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-preview.4 461 7/21/2025
1.0.0-preview.3 123 7/7/2025
1.0.0-preview.2 129 7/3/2025
1.0.0-preview.1 111 12/12/2024