IPlus.Authentication.OpenIdConnect
1.0.0
dotnet add package IPlus.Authentication.OpenIdConnect --version 1.0.0
NuGet\Install-Package IPlus.Authentication.OpenIdConnect -Version 1.0.0
<PackageReference Include="IPlus.Authentication.OpenIdConnect" Version="1.0.0" />
<PackageVersion Include="IPlus.Authentication.OpenIdConnect" Version="1.0.0" />
<PackageReference Include="IPlus.Authentication.OpenIdConnect" />
paket add IPlus.Authentication.OpenIdConnect --version 1.0.0
#r "nuget: IPlus.Authentication.OpenIdConnect, 1.0.0"
#:package IPlus.Authentication.OpenIdConnect@1.0.0
#addin nuget:?package=IPlus.Authentication.OpenIdConnect&version=1.0.0
#tool nuget:?package=IPlus.Authentication.OpenIdConnect&version=1.0.0
iPlusOIDC
This repository contains the code to connect to iPlusOIDC in a very simple way
appsettings.json configuration
The file path and other settings can be read from JSON configuration if desired.
In appsettings.json add a "iPlusOIDCSetting" properties:
{
"iPlusOIDCSetting": {
"Authority": "https://login.iplus.tech",
"ClientId": "aa361a16-a9c0-4aea-971d-753d5135597d",
"ClientSecret": "49C1A7E10C794A89A3D6A37998FB86B0",
"ResponseType": [ "code" ],
"Scope": [ "iplus.write", "iplus.read", "offline_access" ],
"AudienceUrl": "https://api.iplus.tech/"
}
}
And then pass the configuration section to the next methods in 'ConfigureServices':
services.AddIPlusOIDC(Configuration);
Example of a controller using dependency injection userHttpClient or clientHttpClient
[Authorize]
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
private readonly HttpClient _httpClient;
public HomeController(ILogger<HomeController> logger, IHttpClientFactory factory)
{
_logger = logger;
_httpClient = factory.CreateClient("userHttpClient");
}
public async Task<IActionResult> CallApi()
{
var content = await _httpClient.GetStringAsync("identity");
ViewBag.Json = content;
return View("json");
}
public IActionResult Logout()
{
return SignOut("Cookies", "oidc");
}
}
API configuration
In appsettings.json add a "IPlusJwtBearerSetting" properties:
{
"IPlusJwtBearerSetting": {
"Authority": "https://localhost:5001",
"Audience": "iplus"
}
}
And then pass the configuration section to the next methods in 'ConfigureServices':
services.AddJwtBearerAuthentication(Configuration);
Client backchannel configuration to request token with client credentials
Add the following usings
using iPlusOIDC.Extensions; using iPlusOIDC.Settings;
Example using httpClient with client credentials token
var iPlusOIDCSetting = new IPlusOIDCSetting
{
Authority = "https://localhost:5001",
ClientId = "786a5e12-c6f1-41f3-874c-459c012a6e4d",
ClientSecret = "511536EFF270405880CA1C89C192F69A",
Scope = new List<string> { "iplus.write", "iplus.read" },
AudienceUrl = "https://localhost:6001/"
};
var apiClient = await new HttpClient().RequestTokenClientAsync(iPlusOIDCSetting);
var response = await apiClient.GetAsync("endpoint");
if (!response.IsSuccessStatusCode)
{
Console.WriteLine(response.StatusCode);
}
else
{
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 is compatible. 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. 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. |
-
net5.0
- IdentityModel (>= 5.1.0)
- IdentityModel.AspNetCore (>= 3.0.0)
- Microsoft.AspNetCore.Authentication (>= 2.2.0)
- Microsoft.AspNetCore.Authentication.Cookies (>= 2.2.0)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 5.0.10)
- Microsoft.AspNetCore.Authentication.OpenIdConnect (>= 5.0.10)
- Microsoft.Extensions.Configuration.Binder (>= 5.0.0)
- Microsoft.Extensions.DependencyInjection (>= 5.0.2)
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 | 656 | 10/11/2021 |