Formula.SimpleResourceServer
1.0.0
See the version list below for details.
dotnet add package Formula.SimpleResourceServer --version 1.0.0
NuGet\Install-Package Formula.SimpleResourceServer -Version 1.0.0
<PackageReference Include="Formula.SimpleResourceServer" Version="1.0.0" />
paket add Formula.SimpleResourceServer --version 1.0.0
#r "nuget: Formula.SimpleResourceServer, 1.0.0"
// Install Formula.SimpleResourceServer as a Cake Addin #addin nuget:?package=Formula.SimpleResourceServer&version=1.0.0 // Install Formula.SimpleResourceServer as a Cake Tool #tool nuget:?package=Formula.SimpleResourceServer&version=1.0.0
Formula.SimpleResourceServer
A simple OAuth2 / OpenID Connect Resource Server wrapper for Identity Server.
By default, Simple Resource Server validates authentication against an authority using JWT ( see here for more on jwt ) passed using using a Bearer token in the Authorization header of the request made from the client.
Adding Resource Server
To enable a project to serve as a resource server against an authority you will need to prepare configuration and inject it correctly in Startup.cs.
Add the following using;
using Formula.SimpleResourceServer;
Startup.cs - ConfigureServices
Some extension methods have been provided for you register your configuration. Within the ConfigureServices function of Startup.cs you can call services.AddSimpleResourceServer providing it with an implementation of ISimpleResourceServerConfig.
This can be done by creating your own class that implements the ISimpleResourceServerConfig contract, manually, however a more common way to provide configuration is via a JSON configuration file within the project using the ResourceServerConfigLoader.
(See ResourceServerConfigDefinition for configuration options)
services.AddSimpleResourceServer(ResourceServerConfigLoader.Get("resourceServerConfig.json"));
You may also provide some defaults using a delegate.
services.AddSimpleResourceServer(ResourceServerConfigLoader.Get("resourceServerConfig.json", () =>
{
var def = new ResourceServerConfigDefinition();
def.Authority = "http://localhost:5000";
def.RequireHttpsMetadata = false;
def.Audience = "my-api";
return def;
}));
(See ConfigLoader in Formula.SimpleCore for details on how this functionality may be leverage for other task)
If you handle other additional authentication mechanisms, you may pass your AuthenticationBuilder as a second parameter to this function, otherwise it is assumed that no other calls to AddAuthentication have been configured.
Startup.cs - Configure
In the configure section of your app, you may call;
app.UseSimpleResourceServer();
This should be done before other calls to UseAuthorization.
Relavant Links
Packages / Projects Used
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.1 is compatible. |
-
.NETCoreApp 3.1
- Formula.SimpleCore (>= 1.0.0)
- IdentityServer4 (>= 3.0.2)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 3.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.