Authress.SDK 1.5.72

dotnet add package Authress.SDK --version 1.5.72
NuGet\Install-Package Authress.SDK -Version 1.5.72
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="Authress.SDK" Version="1.5.72" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Authress.SDK --version 1.5.72
#r "nuget: Authress.SDK, 1.5.72"
#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.
// Install Authress.SDK as a Cake Addin
#addin nuget:?package=Authress.SDK&version=1.5.72

// Install Authress.SDK as a Cake Tool
#tool nuget:?package=Authress.SDK&version=1.5.72

<p align="center"> <img src="https://github.com/Authress/authress-sdk.cs/assets/5056218/924fb776-9588-4d4a-adf7-33682fa29356" height="300px" alt="Authress Media Banner"> </p>

Authress SDK for C#

This is the Authress SDK for C#. Authress provides an authorization API for user identity, access control, and api key management as a drop in SaaS.

The Nuget package connects to the Authress API. You can use Authress to build authentication and authorization directly into your applications and services. Additionally, Authress can be used locally to develop faster without needing an Authress Account

<p align="center"> <a href="https://www.nuget.org/packages/Authress.SDK" alt="Authress Nuget C#"><img src="https://badge.fury.io/nu/Authress.Sdk.svg"></a> <a href="./LICENSE" alt="Apache-2.0"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"></a> <a href="https://authress.io/community" alt="authress community"><img src="https://img.shields.io/badge/Community-Authress-fbaf0b.svg"></a> </p>

<hr>

Usage

You can either directly install the Authress SDK directly into your current application or checkout the Authress C# Starter Kit.

Installation:

  • run: dotnet add Authress.SDK (or install via visual tools)
Verify Authress JWT

The recommended solution is to use the C# built in OpenID provider by Microsoft. An example implementation is available in the Authress C# Starter Kit. However, in some cases you might need to parse the JWT directly and verify it for use in serverless functions.

using Authress.SDK;

// Get an authress custom domain: https://authress.io/app/#/settings?focus=domain
var authressSettings = new AuthressSettings { ApiBasePath = "https://authress.company.com", };
var authressClient = new AuthressClient(tokenProvider, authressSettings)

var verifiedUserIdentity = await authressClient.VerifyToken(jwtToken);
Console.WriteLine($"User ID: {verifiedUserIdentity.UserId}");
Authorize users using user identity token
using Authress.SDK;

namespace Microservice
{
    public class Controller
    {
        public static async void Route()
        {
            // automatically populate forward the users token
            // 1. instantiate all the necessary classes (example using ASP.NET or MVC, but any function works)
            //   If using the HttpContextAccessor, register it first inside the application root
            //   services.TryAddSingleton<IHttpContextAccessor, HttpContextAccessor>();
            var tokenProvider = new DynamicTokenProvider(() =>
            {
                // Then get the access token from the incoming API request and return it
                var httpContextAccessor = ServiceProvider.GetRequiredService<IHttpContextAccessor>();
                var accessToken = await httpContextAccessor.HttpContext.GetTokenAsync("Bearer", "access_token");
                return accessToken;
            });
            // Get an authress custom domain: https://authress.io/app/#/settings?focus=domain
            var authressSettings = new AuthressSettings { ApiBasePath = "https://authress.company.com", };
            var authressClient = new AuthressClient(tokenProvider, authressSettings);

            // 2. At runtime attempt to Authorize the user for the resource
            await authressClient.AuthorizeUser("USERID", "RESOURCE_URI", "PERMISSION");

            // API Route code
            // ...
        }
    }
}
Authorize using an explicitly set token each time
using Authress.SDK;

namespace Microservice
{
    public class Controller
    {
        public static async void Route()
        {
            // automatically populate forward the users token
            // 1. instantiate all the necessary classes
            var tokenProvider = new ManualTokenProvider();
            var authressSettings = new AuthressSettings { ApiBasePath = "https://DOMAIN.api.authress.io", };
            var authressClient = new AuthressClient(tokenProvider, authressSettings);

            // 2. At runtime attempt to Authorize the user for the resource
            tokenProvider.setToken(userJwt);
            await authressClient.AuthorizeUser("USERID", "RESOURCE_URI", "PERMISSION");

            // API Route code
            // ...
        }
    }
}
Authorize users using client secret
using Authress.SDK;

namespace Microservice
{
    public class Controller
    {
        public static async void Route()
        {
            // accessKey is returned from service client creation in Authress UI
            // 1. instantiate all the necessary classes
            var accessKey = 'ACCESS_KEY';
            // Assuming it was encrypted in storage, decrypt it
            var decodedAccessKey = decrypt(accessKey);
            var tokenProvider = new AuthressClientTokenProvider(decodedAccessKey);
            // Get an authress custom domain: https://authress.io/app/#/settings?focus=domain
            var authressSettings = new AuthressSettings { ApiBasePath = "https://authress.company.com", };
            var authressClient = new AuthressClient(tokenProvider, authressSettings);

            // Attempt to Authorize the user for the resource
            // 2. At runtime the token provider will automatically pull the token forward
            await authressClient.AuthorizeUser("USERID", "RESOURCE_URI", "PERMISSION");

            // API Route code
            // ...
        }
    }
}

Contribution guidelines for the Authress SDK

Contribution guidelines

Product Compatible and additional computed target framework versions.
.NET 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.5.72 104 3/5/2024
1.5.71 89 2/25/2024
1.5.69 88 2/14/2024
1.5.65 169 1/23/2024
1.5.63 74 1/22/2024
1.5.60 74 1/22/2024
1.5.59 78 1/22/2024
1.5.57 189 1/10/2024
1.5.55 79 1/9/2024
1.4.53 80 1/9/2024
1.4.52 77 1/9/2024
1.4.50 83 1/9/2024
1.4.48 86 1/9/2024
1.4.45 135 8/24/2023
1.4.44 118 8/19/2023
1.4.41 154 8/9/2023
1.4.40 142 8/6/2023
1.4.39 128 8/6/2023
1.4.37 148 8/5/2023
1.4.35 154 8/5/2023
1.4.33 137 8/5/2023
1.4.31 138 8/4/2023
1.4.30 134 8/4/2023
1.3.29 162 5/17/2023
1.3.26 128 5/15/2023
1.2.25 127 5/14/2023
1.2.22 816 11/4/2022
1.2.20 390 6/23/2022
1.2.18 440 2/10/2022
1.2.15 419 2/10/2022
1.2.13 419 2/9/2022
1.2.11 417 2/9/2022
1.2.8 419 2/9/2022
1.1.53 1,338 4/12/2021
1.1.50 338 2/19/2021
1.1.46 1,884 12/5/2020
1.0.43 2,681 6/27/2020