Precisamento.Permify
1.0.0
dotnet add package Precisamento.Permify --version 1.0.0
NuGet\Install-Package Precisamento.Permify -Version 1.0.0
<PackageReference Include="Precisamento.Permify" Version="1.0.0" />
paket add Precisamento.Permify --version 1.0.0
#r "nuget: Precisamento.Permify, 1.0.0"
// Install Precisamento.Permify as a Cake Addin #addin nuget:?package=Precisamento.Permify&version=1.0.0 // Install Precisamento.Permify as a Cake Tool #tool nuget:?package=Precisamento.Permify&version=1.0.0
Precisamento.Permify
Precisamento.Permify is a C# SDK for the Permify API.
Usage
General
There are few interfaces available that have slightly different uses, but they all share the same default implementation (PermifyClient).
- IPermifyClient
- Best for single tenant applications, or applications that only access a single tenant.
- The methods have descriptive parameters with sane defaults where expected.
- IPermifyClientMultiTenant
- For applications that need to interact with mutliple tenants.
- All methods take a specific tenant as their first argument.
- The methods have descriptive parameters with sane defaults where expected.
- IPermifyClientRaw
- Best for single tenant applications, or applications that only access a single tenant.
- The methods take and return API model objects that directly mirror the JSON requests.
- IPermifyClientRawMultiTenant
- For applications that need to interact with mutliple tenants.
- All methods take a specific tenant as their first argument.
- The methods take and return API model objects that directly mirror the JSON requests.
- IPermifyClientFull
- Useful for hybrid applications with one main tenant, but occasionally needing to interact with others.
- Union of the above interfaces.
Example
var schema = "..."; // Permify schema string
// Typically this would be loaded in from a config file or environment variables.
var options = new PermifyClientOptions()
{
TenantId = "my-tenant", // Defaults to "t1"
Secret = "MY_SECRET_KEY", // One of the keys when using the preshared keys authn config.
Host = "http://localhost:3476" // URL of the Permify server
};
var httpClient = new HttpClient();
httpClient.BaseAddress = new Uri(options.Host);
httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {options.Secret}");
var permifyClient = new PermifyClient(httpClient, options.TenantId);
await permifyClient.CreateTenantAsync(options.TenantId, "My Tenant");
await permifyClient.WriteSchemaAsync(schema);
DependencyInjection
If this library is being used in an application using the C# DependencyInjection functionality (ASP.NET for example), the client can be registered using the AddPermify
extension method. It will add all of the interface types to the IServiceCollection
.
// App startup
// Typically this would be loaded in from a config file or environment variables.
var options = new PermifyClientOptions()
{
TenantId = "my-tenant", // Defaults to "t1"
Secret = "MY_SECRET_KEY", // One of the keys when using the preshared keys authn config.
Host = "http://localhost:3476" // URL of the Permify server
};
var services = new ServiceCollection();
services.AddPermify(options);
// Get IPermifyClient via constructor
class MyController : Controller {
private IPermifyClient _permify;
public MyController(IPermifyClient permify) {
_permify = permify;
}
}
Docs
The docs site is currently under construction. The library is reasonably well-commented with doc blocks, and the methods on IPermifyClient
should be easily identifiable based on the Permify API documentation.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Macross.Json.Extensions (>= 3.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.1)
- Microsoft.Extensions.Http (>= 8.0.0)
- System.Net.Http.Json (>= 8.0.0)
- System.Text.Json (>= 8.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 172 | 6/27/2024 |