diff --git a/Package.Build.props b/Package.Build.props
index 5801518..2de6222 100644
--- a/Package.Build.props
+++ b/Package.Build.props
@@ -1,6 +1,6 @@
- 0.5.0-alpha
+ 0.6.0-alpha
Hawxy
true
Apache-2.0
@@ -20,4 +20,4 @@
<_Parameter1>Fga.Net.Tests
-
\ No newline at end of file
+
diff --git a/README.md b/README.md
index fb3a8f1..6b21854 100644
--- a/README.md
+++ b/README.md
@@ -1,38 +1,65 @@
-# Auth0 FGA for Worker Services & ASP.NET Core
+## OpenFGA & Auth0 FGA for ASP.NET Core + Worker Services
[![Nuget (with prereleases)](https://img.shields.io/nuget/vpre/Fga.Net.DependencyInjection?label=Fga.Net.DependencyInjection&style=flat-square)](https://www.nuget.org/packages/Fga.Net.DependencyInjection)
[![Nuget (with prereleases)](https://img.shields.io/nuget/vpre/Fga.Net.AspNetCore?label=Fga.Net.AspNetCore&style=flat-square)](https://www.nuget.org/packages/Fga.Net.AspNetCore)
+#### Note: This project is in its early stages and will have breaking changes as FGA matures.
+
### Packages
-- **Fga.Net.DependencyInjection**: Provides dependency injection extensions for Auth0.Fga
+**`Fga.Net.DependencyInjection`**: Provides dependency injection/configuration extensions for [OpenFga.Sdk](https://github.com/openfga/dotnet-sdk)
-- **Fga.Net.AspNetCore**: Additionally includes Authorization middleware to support FGA checks as part of a request's lifecycle.
+**`Fga.Net.AspNetCore`**: Additionally includes Authorization middleware to support FGA checks as part of a request's lifecycle.
## Getting Started
-#### Note: This project is in its early stages and will have breaking changes as FGA matures.
+This package is compatible with the OSS OpenFGA as well as the managed Auth0 FGA service.
-Please ensure you have a basic understanding of how FGA works before continuing: https://docs.fga.dev/
+Please ensure you have a basic understanding of how FGA works before continuing: [OpenFGA Docs](https://openfga.dev/) or [Auth0 FGA Docs](https://docs.fga.dev/)
## ASP.NET Core Setup
-Before getting started, ensure you have a Store ID, Client ID, and Client Secret ready from [How to get your API keys](https://docs.fga.dev/integration/getting-your-api-keys).
+This tutorial assumes you have authentication setup within your project, such as [JWT bearer authentication via Auth0](https://auth0.com/docs/quickstart/backend/aspnet-core-webapi/01-authorization).
+
+Install `Fga.Net.AspNetCore` from Nuget before continuing.
+
+### Auth0 FGA
-I'm also assuming you have authentication setup within your project, such as [JWT bearer authentication via Auth0](https://auth0.com/docs/quickstart/backend/aspnet-core-webapi/01-authorization).
+Ensure you have a Store ID, Client ID, and Client Secret ready from [How to get your API keys](https://docs.fga.dev/integration/getting-your-api-keys).
-1. Install `Fga.Net.AspNetCore` from Nuget.
-2. Add your `StoreId`, `ClientId` and `ClientSecret` to your application configuration, ideally via the [dotnet secrets manager](https://docs.microsoft.com/en-us/aspnet/core/security/app-secrets?view=aspnetcore-6.0&tabs=windows#enable-secret-storage).
-3. Add the following code to your ASP.NET Core configuration:
+1. Add your `StoreId`, `ClientId` and `ClientSecret` to your application configuration, ideally via the [dotnet secrets manager](https://docs.microsoft.com/en-us/aspnet/core/security/app-secrets?view=aspnetcore-6.0&tabs=windows#enable-secret-storage).
+2. Add the following code to your ASP.NET Core services configuration:
```cs
-// Registers the Auth0FgaApi client
-builder.Services.AddAuth0Fga(x =>
+builder.Services.AddOpenFga(x =>
{
- x.ClientId = builder.Configuration["Auth0Fga:ClientId"];
- x.ClientSecret = builder.Configuration["Auth0Fga:ClientSecret"];
+ x.WithAuth0FgaDefaults(builder.Configuration["Auth0Fga:ClientId"], builder.Configuration["Auth0Fga:ClientSecret"]);
+
x.StoreId = builder.Configuration["Auth0Fga:StoreId"];
});
+```
+
+The `WithAuth0FgaDefaults` extension will configure the relevant OpenFGA client settings to work with Auth0 FGA's US environment.
+
+### OpenFGA
+
+OpenFGA configuration is very similar to the [SDK Setup Guide](https://openfga.dev/docs/getting-started/setup-sdk-client)
+1. Add the FGA `ApiScheme`, `ApiHost` & `StoreId` to your application configuration.
+2. Add the following code to your ASP.NET Core configuration:
+```cs
+builder.Services.AddOpenFga(x =>
+{
+ x.ApiScheme = builder.Configuration["Fga:ApiScheme"];
+ x.ApiHost = builder.Configuration["Fga:ApiHost"];
+ x.StoreId = builder.Configuration["Fga:StoreId"];
+});
+```
+
+### Authorization Policy Setup
+
+Now we'll need to setup our authorization middleware like so:
+
+```cs
// Register the authorization policy
builder.Services.AddAuthorization(options =>
{
@@ -43,7 +70,7 @@ builder.Services.AddAuthorization(options =>
});
```
-4. Create an attribute that inherits from `TupleCheckAttribute`. From here, you can pull the metadata you require to perform your tuple checks out of the HTTP request.
+Next, create an attribute that inherits from `TupleCheckAttribute`. From here, you can pull the metadata you require to perform your tuple checks out of the HTTP request.
For example, an equivalent to the [How To Integrate Within A Framework](https://docs.fga.dev/integration/framework) example would be:
```cs
public class EntityAuthorizationAttribute : TupleCheckAttribute
@@ -72,7 +99,7 @@ public class EntityAuthorizationAttribute : TupleCheckAttribute
}
```
-5. Apply the `Authorize` and `EntityAuthorization` attributes to your controller(s):
+Now apply the `Authorize` and `EntityAuthorization` attributes to your controller(s):
```cs
// Traditional Controllers
[ApiController]
@@ -89,10 +116,9 @@ public class EntityAuthorizationAttribute : TupleCheckAttribute
}
// Minimal APIs
- app.MapGet("/viewminimal/{documentId}",
- [Authorize(FgaAuthorizationDefaults.PolicyKey)]
- [EntityAuthorization("doc", "documentId")]
- (documentId) => Task.FromResult(documentId));
+ app.MapGet("/viewminimal/{documentId}", (string documentId) => Task.FromResult(documentId))
+ .RequireAuthorization(FgaAuthorizationDefaults.PolicyKey)
+ .WithMetadata(new EntityAuthorizationAttribute("doc", "documentId"));
```
If you need to manually perform checks, inject the `Auth0FgaApi` as required.
@@ -101,23 +127,28 @@ An additional pre-made attribute that allows all tuple values to be hardcoded st
## Worker Service / Generic Host Setup
-`Fga.Net.DependencyInjection` ships with the `AddAuth0FgaClient` service collection extension that handles all required wire-up.
+`Fga.Net.DependencyInjection` ships with the `AddOpenFgaClient` service collection extension that handles all required wire-up.
To get started:
1. Install `Fga.Net.DependencyInjection`
-2. Add your `StoreId`, `ClientId` and `ClientSecret` to your application configuration, ideally via the [dotnet secrets manager](https://docs.microsoft.com/en-us/aspnet/core/security/app-secrets?view=aspnetcore-6.0&tabs=windows#enable-secret-storage).
+2. Add your `StoreId`, `ClientId` and `ClientSecret` Auth0 FGA configuration **OR** `ApiScheme`, `ApiHost` & `StoreId` OpenFGA configuration to your application configuration, ideally via the [dotnet secrets manager](https://docs.microsoft.com/en-us/aspnet/core/security/app-secrets?view=aspnetcore-6.0&tabs=windows#enable-secret-storage).
3. Register the authorization client:
```cs
var host = Host.CreateDefaultBuilder(args)
.ConfigureServices((context, services) =>
{
- services.AddAuth0FgaClient(config =>
+ services.AddOpenFgaClient(config =>
{
- config.ClientId = context.Configuration["Auth0Fga:ClientId"];
- config.ClientSecret = context.Configuration["Auth0Fga:ClientSecret"];
+ // Auth0 FGA
+ config.WithAuth0FgaDefaults(context.Configuration["Auth0Fga:ClientId"], context.Configuration["Auth0Fga:ClientSecret"]);
config.StoreId = context.Configuration["Auth0Fga:StoreId"];
+
+ // OpenFGA
+ config.ApiScheme = context.Configuration["Fga:ApiScheme"];
+ config.ApiHost = context.Configuration["Fga:ApiHost"];
+ config.StoreId = context.Configuration["Fga:StoreId"];
});
services.AddHostedService();
@@ -148,8 +179,8 @@ public class MyBackgroundWorker : BackgroundService
## Standalone client setup
-See the [Auth0.Fga docs](https://github.com/auth0-lab/fga-dotnet-sdk)
+See the [OpenFGA.Sdk docs](https://openfga.dev/docs/getting-started/setup-sdk-client)
## Disclaimer
-I am not affiliated with nor represent Auth0. All support queries regarding the underlying service should go to the [Auth0 Labs Discord](https://discord.gg/8naAwJfWN6).
+I am not affiliated with nor represent Auth0 or OpenFGA. All support queries regarding the underlying service should go to the [Auth0 Labs Discord](https://discord.gg/8naAwJfWN6).
diff --git a/build/Build.cs b/build/Build.cs
index d9df69e..0515dcf 100644
--- a/build/Build.cs
+++ b/build/Build.cs
@@ -1,17 +1,9 @@
-using System;
-using System.Linq;
using Nuke.Common;
using Nuke.Common.CI;
-using Nuke.Common.Execution;
-using Nuke.Common.Git;
using Nuke.Common.IO;
using Nuke.Common.ProjectModel;
-using Nuke.Common.Tooling;
using Nuke.Common.Tools.DotNet;
-using Nuke.Common.Utilities.Collections;
-using static Nuke.Common.EnvironmentInfo;
using static Nuke.Common.IO.FileSystemTasks;
-using static Nuke.Common.IO.PathConstruction;
using static Nuke.Common.Tools.DotNet.DotNetTasks;
[ShutdownDotNetAfterServerBuild]
diff --git a/build/_build.csproj b/build/_build.csproj
index be8500f..6184984 100644
--- a/build/_build.csproj
+++ b/build/_build.csproj
@@ -11,7 +11,7 @@
-
+
diff --git a/samples/Fga.Example.AspNetCore/Fga.Example.AspNetCore.csproj b/samples/Fga.Example.AspNetCore/Fga.Example.AspNetCore.csproj
index fa4d9e1..62611ad 100644
--- a/samples/Fga.Example.AspNetCore/Fga.Example.AspNetCore.csproj
+++ b/samples/Fga.Example.AspNetCore/Fga.Example.AspNetCore.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/samples/Fga.Example.AspNetCore/Program.cs b/samples/Fga.Example.AspNetCore/Program.cs
index d5e32c8..439e833 100644
--- a/samples/Fga.Example.AspNetCore/Program.cs
+++ b/samples/Fga.Example.AspNetCore/Program.cs
@@ -2,8 +2,8 @@
using Fga.Example.AspNetCore;
using Fga.Net.AspNetCore;
using Fga.Net.AspNetCore.Authorization;
+using Fga.Net.DependencyInjection;
using Microsoft.AspNetCore.Authentication.JwtBearer;
-using Microsoft.AspNetCore.Authorization;
using Microsoft.IdentityModel.Tokens;
var builder = WebApplication.CreateBuilder(args);
@@ -27,13 +27,24 @@
};
});
-builder.Services.AddAuth0Fga(x =>
+
+// Auth0 FGA
+builder.Services.AddOpenFga(x =>
{
- x.ClientId = builder.Configuration["Auth0Fga:ClientId"];
- x.ClientSecret = builder.Configuration["Auth0Fga:ClientSecret"];
+ x.WithAuth0FgaDefaults(builder.Configuration["Auth0Fga:ClientId"], builder.Configuration["Auth0Fga:ClientSecret"]);
+
x.StoreId = builder.Configuration["Auth0Fga:StoreId"];
});
+
+// OpenFGA
+/*builder.Services.AddOpenFga(x =>
+{
+ x.ApiScheme = builder.Configuration["Fga:ApiScheme"];
+ x.ApiHost = builder.Configuration["Fga:ApiHost"];
+ x.StoreId = builder.Configuration["Fga:StoreId"];
+});*/
+
builder.Services.AddAuthorization(options =>
{
options.AddPolicy(FgaAuthorizationDefaults.PolicyKey,
@@ -56,9 +67,8 @@
app.MapControllers();
-app.MapGet("/viewminimal/{documentId}",
- [Authorize(FgaAuthorizationDefaults.PolicyKey)]
- [EntityAuthorization("doc", "documentId")]
- (documentId) => Task.FromResult(documentId));
+app.MapGet("/viewminimal/{documentId}", (string documentId) => Task.FromResult(documentId))
+ .RequireAuthorization(FgaAuthorizationDefaults.PolicyKey)
+ .WithMetadata(new EntityAuthorizationAttribute("doc", "documentId"));
app.Run();
diff --git a/samples/Fga.Example.GenericHost/MyService.cs b/samples/Fga.Example.GenericHost/MyService.cs
index 5dd76aa..4ee0050 100644
--- a/samples/Fga.Example.GenericHost/MyService.cs
+++ b/samples/Fga.Example.GenericHost/MyService.cs
@@ -1,12 +1,12 @@
-using Auth0.Fga.Api;
+using OpenFga.Sdk.Api;
namespace Fga.Example.GenericHost
{
public class MyBackgroundWorker : BackgroundService
{
- private readonly Auth0FgaApi _authorizationClient;
+ private readonly OpenFgaApi _authorizationClient;
- public MyBackgroundWorker(Auth0FgaApi authorizationClient)
+ public MyBackgroundWorker(OpenFgaApi authorizationClient)
{
_authorizationClient = authorizationClient;
}
diff --git a/samples/Fga.Example.GenericHost/Program.cs b/samples/Fga.Example.GenericHost/Program.cs
index ad43cd3..362d1a1 100644
--- a/samples/Fga.Example.GenericHost/Program.cs
+++ b/samples/Fga.Example.GenericHost/Program.cs
@@ -1,15 +1,19 @@
using Fga.Example.GenericHost;
-using Fga.Net;
using Fga.Net.DependencyInjection;
var host = Host.CreateDefaultBuilder(args)
.ConfigureServices((context, services) =>
{
- services.AddAuth0FgaClient(config =>
+ services.AddOpenFgaClient(config =>
{
- config.ClientId = context.Configuration["Auth0Fga:ClientId"];
- config.ClientSecret = context.Configuration["Auth0Fga:ClientSecret"];
+ // Auth0 FGA
+ config.WithAuth0FgaDefaults(context.Configuration["Auth0Fga:ClientId"], context.Configuration["Auth0Fga:ClientSecret"]);
config.StoreId = context.Configuration["Auth0Fga:StoreId"];
+
+ // OpenFGA
+ config.ApiScheme = context.Configuration["Fga:ApiScheme"];
+ config.ApiHost = context.Configuration["Fga:ApiHost"];
+ config.StoreId = context.Configuration["Fga:StoreId"];
});
services.AddHostedService();
diff --git a/src/Fga.Net.AspNetCore/Authorization/FgaCheckDecorator.cs b/src/Fga.Net.AspNetCore/Authorization/FgaCheckDecorator.cs
index a506864..62449de 100644
--- a/src/Fga.Net.AspNetCore/Authorization/FgaCheckDecorator.cs
+++ b/src/Fga.Net.AspNetCore/Authorization/FgaCheckDecorator.cs
@@ -1,5 +1,5 @@
-using Auth0.Fga.Api;
-using Auth0.Fga.Model;
+using OpenFga.Sdk.Api;
+using OpenFga.Sdk.Model;
namespace Fga.Net.AspNetCore.Authorization;
@@ -8,13 +8,13 @@ namespace Fga.Net.AspNetCore.Authorization;
///
public class FgaCheckDecorator : IFgaCheckDecorator
{
- private readonly Auth0FgaApi _auth0FgaApi;
+ private readonly OpenFgaApi _auth0FgaApi;
///
///
///
///
- public FgaCheckDecorator(Auth0FgaApi auth0FgaApi)
+ public FgaCheckDecorator(OpenFgaApi auth0FgaApi)
{
_auth0FgaApi = auth0FgaApi;
}
diff --git a/src/Fga.Net.AspNetCore/Authorization/FineGrainedAuthorizationHandler.cs b/src/Fga.Net.AspNetCore/Authorization/FineGrainedAuthorizationHandler.cs
index 71493a0..cc97a0c 100644
--- a/src/Fga.Net.AspNetCore/Authorization/FineGrainedAuthorizationHandler.cs
+++ b/src/Fga.Net.AspNetCore/Authorization/FineGrainedAuthorizationHandler.cs
@@ -16,11 +16,11 @@ limitations under the License.
*/
#endregion
-using Auth0.Fga.Model;
using Fga.Net.AspNetCore.Authorization.Attributes;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
+using OpenFga.Sdk.Model;
namespace Fga.Net.AspNetCore.Authorization;
diff --git a/src/Fga.Net.AspNetCore/Controllers/FgaControllerBase.cs b/src/Fga.Net.AspNetCore/Controllers/FgaControllerBase.cs
index dd43c12..acacfcd 100644
--- a/src/Fga.Net.AspNetCore/Controllers/FgaControllerBase.cs
+++ b/src/Fga.Net.AspNetCore/Controllers/FgaControllerBase.cs
@@ -16,9 +16,9 @@ limitations under the License.
*/
#endregion
-using Auth0.Fga.Api;
-using Auth0.Fga.Model;
using Microsoft.AspNetCore.Mvc;
+using OpenFga.Sdk.Api;
+using OpenFga.Sdk.Model;
namespace Fga.Net.AspNetCore.Controllers;
@@ -27,12 +27,12 @@ namespace Fga.Net.AspNetCore.Controllers;
///
public class FgaControllerBase : ControllerBase
{
- private readonly Auth0FgaApi _client;
+ private readonly OpenFgaApi _client;
///
///
///
///
- public FgaControllerBase(Auth0FgaApi client)
+ public FgaControllerBase(OpenFgaApi client)
{
_client = client;
}
diff --git a/src/Fga.Net.AspNetCore/ServiceCollectionExtensions.cs b/src/Fga.Net.AspNetCore/ServiceCollectionExtensions.cs
index 2e9d6a9..70d11e7 100644
--- a/src/Fga.Net.AspNetCore/ServiceCollectionExtensions.cs
+++ b/src/Fga.Net.AspNetCore/ServiceCollectionExtensions.cs
@@ -16,11 +16,11 @@ limitations under the License.
*/
#endregion
-using Auth0.Fga.Api;
using Fga.Net.AspNetCore.Authorization;
using Fga.Net.DependencyInjection;
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.DependencyInjection;
+using OpenFga.Sdk.Api;
namespace Fga.Net.AspNetCore;
@@ -30,16 +30,16 @@ namespace Fga.Net.AspNetCore;
public static class ServiceCollectionExtensions
{
///
- /// Adds and configures an along with a .
+ /// Adds and configures an along with a .
///
/// The service collection
- /// The delegate for the that will be used to configure the
+ /// The delegate for the that will be used to configure the
/// The service collection
- public static IServiceCollection AddAuth0Fga(this IServiceCollection collection, Action config)
+ public static IServiceCollection AddOpenFga(this IServiceCollection collection, Action config)
{
ArgumentNullException.ThrowIfNull(config);
- collection.AddAuth0FgaClient(config);
+ collection.AddOpenFgaClient(config);
collection.AddScoped();
collection.AddScoped();
return collection;
diff --git a/src/Fga.Net/Fga.Net.DependencyInjection.csproj b/src/Fga.Net/Fga.Net.DependencyInjection.csproj
index 1a922af..37655b1 100644
--- a/src/Fga.Net/Fga.Net.DependencyInjection.csproj
+++ b/src/Fga.Net/Fga.Net.DependencyInjection.csproj
@@ -12,9 +12,9 @@
-
+
diff --git a/src/Fga.Net/FgaClientConfiguration.cs b/src/Fga.Net/FgaClientConfiguration.cs
index f29ca64..7a63a40 100644
--- a/src/Fga.Net/FgaClientConfiguration.cs
+++ b/src/Fga.Net/FgaClientConfiguration.cs
@@ -16,7 +16,8 @@ limitations under the License.
*/
#endregion
-using Auth0.Fga.Configuration;
+
+using OpenFga.Sdk.Configuration;
namespace Fga.Net.DependencyInjection;
@@ -25,4 +26,5 @@ namespace Fga.Net.DependencyInjection;
///
public class FgaClientConfiguration : Configuration
{
-}
\ No newline at end of file
+
+}
diff --git a/src/Fga.Net/FgaClientConfigurationExtensions.cs b/src/Fga.Net/FgaClientConfigurationExtensions.cs
new file mode 100644
index 0000000..e83d2cc
--- /dev/null
+++ b/src/Fga.Net/FgaClientConfigurationExtensions.cs
@@ -0,0 +1,34 @@
+using OpenFga.Sdk.Configuration;
+
+namespace Fga.Net.DependencyInjection;
+
+///
+/// Extensions for
+///
+public static class FgaClientConfigurationExtensions
+{
+
+ ///
+ /// Configures the client with connection defaults when using Auth0 FGA
+ ///
+ /// An instance of the configuration
+ /// The Auth0 FGA client ID
+ /// The Auth0 FGA client secret
+ public static void WithAuth0FgaDefaults(this FgaClientConfiguration config, string clientId, string clientSecret)
+ {
+ //TODO make environment configurable
+ config.ApiHost = "api.us1.fga.dev";
+ config.Credentials = new Credentials()
+ {
+ Method = CredentialsMethod.ClientCredentials,
+ Config = new CredentialsConfig()
+ {
+ ClientId = clientId,
+ ClientSecret = clientSecret,
+ ApiTokenIssuer = "fga.us.auth0.com",
+ ApiAudience = "https://api.us1.fga.dev/"
+ }
+ };
+ }
+
+}
\ No newline at end of file
diff --git a/src/Fga.Net/InjectableAuth0FgaApi.cs b/src/Fga.Net/InjectableAuth0FgaApi.cs
deleted file mode 100644
index 484141c..0000000
--- a/src/Fga.Net/InjectableAuth0FgaApi.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using Auth0.Fga.Api;
-using Microsoft.Extensions.Options;
-
-namespace Fga.Net.DependencyInjection
-{
- internal class InjectableAuth0FgaApi : Auth0FgaApi
- {
- public InjectableAuth0FgaApi(IOptions configuration, HttpClient httpClient) : base(configuration.Value, httpClient)
- {
- }
- }
-}
diff --git a/src/Fga.Net/InjectableFgaApi.cs b/src/Fga.Net/InjectableFgaApi.cs
new file mode 100644
index 0000000..2f90892
--- /dev/null
+++ b/src/Fga.Net/InjectableFgaApi.cs
@@ -0,0 +1,11 @@
+using Microsoft.Extensions.Options;
+using OpenFga.Sdk.Api;
+
+namespace Fga.Net.DependencyInjection;
+
+internal sealed class InjectableFgaApi : OpenFgaApi
+{
+ public InjectableFgaApi(IOptions configuration, HttpClient httpClient) : base(configuration.Value, httpClient)
+ {
+ }
+}
\ No newline at end of file
diff --git a/src/Fga.Net/ServiceCollectionExtensions.cs b/src/Fga.Net/ServiceCollectionExtensions.cs
index 0af7b70..15ae892 100644
--- a/src/Fga.Net/ServiceCollectionExtensions.cs
+++ b/src/Fga.Net/ServiceCollectionExtensions.cs
@@ -16,8 +16,8 @@ limitations under the License.
*/
#endregion
-using Auth0.Fga.Api;
using Microsoft.Extensions.DependencyInjection;
+using OpenFga.Sdk.Api;
namespace Fga.Net.DependencyInjection;
@@ -27,17 +27,17 @@ namespace Fga.Net.DependencyInjection;
public static class ServiceCollectionExtensions
{
///
- /// Registers and configures an for the provided service collection.
+ /// Registers and configures an for the provided service collection.
///
///
///
/// An that can be used to configure the .
- public static IHttpClientBuilder AddAuth0FgaClient(this IServiceCollection collection, Action configuration)
+ public static IHttpClientBuilder AddOpenFgaClient(this IServiceCollection collection, Action configuration)
{
ArgumentNullException.ThrowIfNull(configuration);
collection.Configure(configuration);
- return collection.AddHttpClient();
+ return collection.AddHttpClient();
}
}
diff --git a/tests/Fga.Net.Tests/Client/EndpointTests.cs b/tests/Fga.Net.Tests/Client/EndpointTests.cs
index 4f29381..da1cce7 100644
--- a/tests/Fga.Net.Tests/Client/EndpointTests.cs
+++ b/tests/Fga.Net.Tests/Client/EndpointTests.cs
@@ -1,9 +1,9 @@
using System.Linq;
using System.Threading.Tasks;
using Alba;
-using Auth0.Fga.Api;
-using Auth0.Fga.Model;
using Microsoft.Extensions.DependencyInjection;
+using OpenFga.Sdk.Api;
+using OpenFga.Sdk.Model;
using Xunit;
namespace Fga.Net.Tests.Client
@@ -22,7 +22,7 @@ public EndpointTests(EndpointWebAppFixture fixture)
private async Task GetEndpoints_Return_200()
{
using var scope = _host.Services.CreateScope();
- var client = scope.ServiceProvider.GetRequiredService();
+ var client = scope.ServiceProvider.GetRequiredService();
var modelsResponse = await client.ReadAuthorizationModels();
Assert.NotNull(modelsResponse);
diff --git a/tests/Fga.Net.Tests/Fga.Net.Tests.csproj b/tests/Fga.Net.Tests/Fga.Net.Tests.csproj
index cecc254..a685af5 100644
--- a/tests/Fga.Net.Tests/Fga.Net.Tests.csproj
+++ b/tests/Fga.Net.Tests/Fga.Net.Tests.csproj
@@ -9,9 +9,9 @@
-
-
-
+
+
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
diff --git a/tests/Fga.Net.Tests/Middleware/MiddlewareTests.cs b/tests/Fga.Net.Tests/Middleware/MiddlewareTests.cs
index 73c1d0e..8412079 100644
--- a/tests/Fga.Net.Tests/Middleware/MiddlewareTests.cs
+++ b/tests/Fga.Net.Tests/Middleware/MiddlewareTests.cs
@@ -1,9 +1,6 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
using System.Net;
using System.Security.Claims;
-using System.Text;
using System.Threading.Tasks;
using Alba;
using Xunit;
diff --git a/tests/Fga.Net.Tests/Middleware/WebAppFixture.cs b/tests/Fga.Net.Tests/Middleware/WebAppFixture.cs
index 4f0f480..0953022 100644
--- a/tests/Fga.Net.Tests/Middleware/WebAppFixture.cs
+++ b/tests/Fga.Net.Tests/Middleware/WebAppFixture.cs
@@ -1,11 +1,11 @@
using System.Threading;
using System.Threading.Tasks;
using Alba;
-using Auth0.Fga.Model;
using Fga.Net.AspNetCore.Authorization;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Moq;
+using OpenFga.Sdk.Model;
using Xunit;
namespace Fga.Net.Tests.Middleware;
diff --git a/tests/Fga.Net.Tests/Unit/ExtensionTests.cs b/tests/Fga.Net.Tests/Unit/ExtensionTests.cs
index 5e601fd..cf410de 100644
--- a/tests/Fga.Net.Tests/Unit/ExtensionTests.cs
+++ b/tests/Fga.Net.Tests/Unit/ExtensionTests.cs
@@ -1,10 +1,10 @@
-using System;
-using Auth0.Fga.Api;
+using System;
using Fga.Net.AspNetCore;
using Fga.Net.AspNetCore.Authorization;
using Fga.Net.DependencyInjection;
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.DependencyInjection;
+using OpenFga.Sdk.Api;
using Xunit;
namespace Fga.Net.Tests.Unit
@@ -16,18 +16,18 @@ public void ClientExtensions_RegisterCorrectly()
{
var collection = new ServiceCollection();
- collection.AddAuth0FgaClient(x =>
+ collection.AddOpenFgaClient(x =>
{
x.StoreId = Guid.NewGuid().ToString();
- x.ClientId = Guid.NewGuid().ToString();
- x.ClientSecret = Guid.NewGuid().ToString();
+ x.WithAuth0FgaDefaults(Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
+
});
var provider = collection.BuildServiceProvider();
- var authClient = provider.GetService();
+ var authClient = provider.GetService();
Assert.NotNull(authClient);
- Assert.IsType(authClient);
+ Assert.IsType(authClient);
}
[Fact]
@@ -35,11 +35,10 @@ public void AspNetCoreServiceExtensions_RegisterCorrectly()
{
var collection = new ServiceCollection();
- collection.AddAuth0Fga(x =>
+ collection.AddOpenFga(x =>
{
x.StoreId = Guid.NewGuid().ToString();
- x.ClientId = Guid.NewGuid().ToString();
- x.ClientSecret = Guid.NewGuid().ToString();
+ x.WithAuth0FgaDefaults(Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
});
var provider = collection.BuildServiceProvider();
@@ -48,9 +47,9 @@ public void AspNetCoreServiceExtensions_RegisterCorrectly()
Assert.Contains(col, handler => handler.GetType() == typeof(FineGrainedAuthorizationHandler));
- var authClient = provider.GetService();
+ var authClient = provider.GetService();
Assert.NotNull(authClient);
- Assert.IsType(authClient);
+ Assert.IsType(authClient);
}