Casdoor.Client 1.16.0

dotnet add package Casdoor.Client --version 1.16.0
                    
NuGet\Install-Package Casdoor.Client -Version 1.16.0
                    
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="Casdoor.Client" Version="1.16.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Casdoor.Client" Version="1.16.0" />
                    
Directory.Packages.props
<PackageReference Include="Casdoor.Client" />
                    
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 Casdoor.Client --version 1.16.0
                    
#r "nuget: Casdoor.Client, 1.16.0"
                    
#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 Casdoor.Client@1.16.0
                    
#: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=Casdoor.Client&version=1.16.0
                    
Install as a Cake Addin
#tool nuget:?package=Casdoor.Client&version=1.16.0
                    
Install as a Cake Tool

Casdoor .NET SDK

Actions Status GitHub

The Casdoor's SDK for .NET/ASP.NET Core, which will allow you to easily connect your application to the Casdoor authentication system without having to implement it from scratch.

Packages

This SDK is built using the following packages for different platforms:

Package Name NuGet Description Supported frameworks
Casdoor.Client NuGet SDK for .NET .NET Standard 2.0/.NET 4.6.1 and newer
Casdoor.AspNetCore NuGet SDK for ASP.NET Core .NET Core 3.1 and newer
Casdoor.Native wait publish SDK for WPF or Maui -

Casdoor Client

Casdoor.Client is a base package for the specific platform SDKs. It contains follow features.

  • CasdoorClient: A API client implementation for the Casdoor. You can use to call the Casdoor APIs.
Usage
var httpClient = new HttpClient();
var client = new CasdoorClient(HttpClient, new CasdoorOptions{
    Endpoint = "https://door.casdoor.com",
    OrganizationName = "casbin", // your Casdoor organization
    ApplicationName = "app-example", // your Casdoor application
    ApplicationType = "native", // webapp, webapi or native
    ClientId = "b800a86702dd4d29ec4d", // your Casdoor application's client ID
    ClientSecret = "1219843a8db4695155699be3a67f10796f2ec1d5", // your Casdoor application's client secret
});

// Request tokens (You should enable credentials flow in your Casdoor application)
var token = await client.RequestClientCredentialsTokenAsync();
client.SetBearerToken(token);

var currentUser = client.ParseJwtToken(token.AccessToken);

// Request user info
var users = await client.GetUsersAsync();
// Request roles
var roles = await client.GetRolesAsync();
// Request Permissions
var persmissions = await client.GetPermissionsAsync();

var policy = new CasdoorPermissionRule()
{
    Id = $"{currentUser.Owner}/{persmissions.First().Name}",
    V0 = $"{currentUser.Owner}/{currentUser.Name}",
    V1 = "example-resource",
    V2 = "example-action"
};

var isPermissionAvaliable = await client.EnforceAsync(policy);

  • CasdoorOptions (Updating)
  • Extensions (Updating)

Casdoor AspNetCore

Getting started

  1. Add the following settings about casdoor in your appsettings.json file:
{
    "Casdoor": {
        "Endpoint": "<your Casdoor endpoint>",
        "OrganizationName": "<your Casdoor organization>",
        "ApplicationName": "<your Casdoor application>",
        "ApplicationType": "webapp", // webapp or webapi (webapi is not yet supported)
        "ClientId": "<your Casdoor application's client ID>",
        "ClientSecret": "<your Casdoor application's client secret>",

        // Optional: The callback path that the client will be redirected to
        // after the user has authenticated. default is "/casdoor/signin-callback"
        "CallbackPath": "/callback",
        // Optional: Whether require https for casdoor endpoint
        "RequireHttpsMetadata": false,
        // Optional: The scopes that the client will request
        "Scopes": [
            "openid",
            "profile",
            "email",
        ]
    }
}
  1. Add the following code to your webapp:
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
    .AddCasdoor(builder.Configuration.GetSection("Casdoor"))
    .AddCookie(CookieAuthenticationDefaults.AuthenticationScheme);
  1. Now you can use the Casdoor authentication scheme in your webapp!

Samples

1. MVC sample

It is a MVC webapp that uses Casdoor authentication. The default settings use the public demo Casdoor and Casnode configuration, you can directly start the webapp by running:

dotnet run

Or change the settings in the appsettings.json according to your deployed casdoor configuration.README.md

License

This project is licensed under the Apache 2.0 license.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  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 is compatible.  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.  net9.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 is compatible. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 is compatible.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Casdoor.Client:

Package Downloads
Casdoor.AspNetCore

The Casdoor's SDK for .NET, which will allow you to easily connect your application to the Casdoor authentication system without having to implement it from scratch.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Casdoor.Client:

Repository Stars
AIDotNet/Thor
Thor is a powerful artificial intelligence model management tool, whose main purpose is to achieve unified management and use of multiple AI models. Through Thor, users can easily manage and utilize numerous AI models
Version Downloads Last Updated
1.16.0 11,703 4/27/2024
1.15.0 2,932 2/17/2024
1.13.0 289 2/3/2024
1.12.0 1,225 11/19/2023
1.11.0 314 11/12/2023
1.10.2 287 11/4/2023
1.10.1 310 10/30/2023
1.10.0 361 10/10/2023
1.9.1 276 10/5/2023
1.9.0 375 9/6/2023
1.8.1 261 9/5/2023
1.8.0 292 8/31/2023
1.7.0 293 8/31/2023
1.6.0 237 8/30/2023
1.5.0 320 8/30/2023
1.4.0 269 8/27/2023
1.3.0 447 8/5/2023
1.2.1 305 8/1/2023
1.2.0 336 7/25/2023
1.1.0 301 7/25/2023
Loading failed