Client Libraries
Applyze Tenant has following client libraries:
C# Libraries
Name | Description | Version | Target | Platform |
---|---|---|---|---|
Applyze.Identity.Client | It provides all endpoints processes over abstractions. | Portable |
||
Applyze.Shared.Authentication | It provides only authentication of tenant (Api-Key ), user (User-Api-Key ) and app (app-key ). |
Portable |
||
Applyze.Shared.Authentication.AspNetCore | It provides only same processes with Applyze.Shared.Authentication, but it has AspNetCore special Middleware and Attributes. | AspNetCore |
||
Applyze.Identity.Client.TypeScript | Provides access to all endpoints. | v2.1 |
TypeScript |
Usage Client Libraries
Applyze.Identity.Client
Will be added...
Applyze.Shared.Authentication
Installation
NuGet Package
You can find NuGet Package and instructions from here
- Open Package Manager Console and run following command:
Install-Package Applyze.Shared.Authentication
- Or just add following package reference to .csproj file:
<PackageReference Include="Applyze.Shared.Authentication" Version="1.0.3" />
- Finally you should set the base url of tenant once in your application start:
Applyze.Shared.Authentication.Constants.TenantBaseUrl = "https://mycustomdomain.api.applyze.com/tenant/v1/";
Set-Up
- Go to Dependency Injection builder
- Add following implementation into IServiceCollection:
services.AddScoped<ITenantService,TenantService>();
Usage
Sample:
- Add
ITenantService
type parameter to your class constructor, keep it and use it:
//...
using Applyze.Shared.Authentication.Services;
//...
public class YourClass()
{
private readonly ITenantService _service;
public YourClass(ITenantService service) //<-- Constructor
{
_service = service;
}
public async Task<IActionResult> YourAction(string apiKey)
{
//...
var result = await service.AuthenticateApiKeyAsync(apiKey); // < --- Just use like here.
//...
}
}
Applyze.Shared.Authentication.AspNetCore
Installation
NuGet Package
You can find NuGet Package and instructions from here
- Open Package Manager Console and run following command:
Install-Package Applyze.Shared.Authentication.AspNetCore
- Or just add following package reference to .csproj file:
<PackageReference Include="Applyze.Shared.Authentication" Version="1.0.4" />
<PackageReference Include="Applyze.Shared.Authentication.AspNetCore" Version="1.0.4" />
Set-Up
- Go to Startup.cs
- Add following code into ConfigureServices() method:
services.AddApplyzeAuthentication(builder => builder.SetTenantBaseUrl("test.com/v1"));
// or you can set it from your configuretion
services.AddApplyzeAuthentication(builder => builder.SetTenantBaseUrl(Configuration.GetSection("Applyze:TenantUrl").Value));
Usage
Authenticate with Attribute
There is an ApplyzeAuthenticateAttribute which is located at Applyze.Shared.Authentication.Filters namespace nad ready to use authenticate your Controllers or Actions.
Sample:
- Just use ApplyzeAuthenticate attribute:
//...
using Applyze.Shared.Authentication.Filters;
//...
[ApplyzeAuthenticate] // <-- Authenticates ApiKey from Tenant
public class YourController()
{
[AllowAnonymous] // <-- Authentication disabled for this action
public IActionResult YourAction()
{
//...
}
[ApplyzeAuthenticate(AuthenticationType.ApplicationLevel)] // <-- Authenticates ApiKey, AppKey
public IActionResult YourOtherAction()
{
//...
}
[ApplyzeAuthenticate(AuthenticationType.ApplicationOwnerLevel)] // <-- Authenticates ApiKey, UserApiKey and AppKey from Tenant
public IActionResult YourAnotherAction()
{
//...
}
}
Or you can combine your own requirements with bitwise OR like following sample:
[ApplyzeAuthenticate(AuthenticationType.ApiKey | AuthenticationType.UserApiKey | AuthenticationType.AppKey)]
Getting Authenticated App
//...
using Applyze.Shared.Authentication.Helpers;
//...
[ApplyzeAuthenticate(AuthenticationType.ApplicationLevel)]
public class YourController()
{
public IActionResult YourAction()
{
var app = HttpContext.GetCachedApp();
Console.WriteLine(app.Name);
//...
}
}