Bewit.Extensions.HotChocolate
5.0.0-preview.6
See the version list below for details.
dotnet add package Bewit.Extensions.HotChocolate --version 5.0.0-preview.6
NuGet\Install-Package Bewit.Extensions.HotChocolate -Version 5.0.0-preview.6
<PackageReference Include="Bewit.Extensions.HotChocolate" Version="5.0.0-preview.6" />
paket add Bewit.Extensions.HotChocolate --version 5.0.0-preview.6
#r "nuget: Bewit.Extensions.HotChocolate, 5.0.0-preview.6"
// Install Bewit.Extensions.HotChocolate as a Cake Addin #addin nuget:?package=Bewit.Extensions.HotChocolate&version=5.0.0-preview.6&prerelease // Install Bewit.Extensions.HotChocolate as a Cake Tool #tool nuget:?package=Bewit.Extensions.HotChocolate&version=5.0.0-preview.6&prerelease
Bewit is an authentication scheme alternative to cookies and bearer tokens.
Bewit enables you to provide authentication in use cases where cookies and authentication headers can not be used. With support for both stateful and stateless authentication, Bewit is a practical solution for many scenarii, including file downloads and temporary or single-use links.
Getting Started
We've prepared a simple example of how to use Bewit to provide stateless secure file downloads for a HotChocolate Server. In this scenario, a HotChocolate server will be used to generate secure links. These links can then be used to download content from an Asp.Net MVC Server without cookies or authentication headers.
Install
You will need the following package for your HotChocolate Server:
dotnet add package Bewit.Extensions.HotChocolate
On your MVC Server, add the following package:
dotnet add package Bewit.Extensions.Mvc
HotChocolate Server
First create a simple HotChocolate API with the following Schema:
const string mvcApiUrl = "http://localhost:5000"; //your mvc api url here
ISchema schema = SchemaBuilder.New()
.SetOptions(new SchemaOptions
{
StrictValidation = false //because we don't have a QueryType in this example
})
.AddMutationType(
new ObjectType(
d =>
{
d.Name("Mutation");
d.Field("RequestAccessUrl")
.Type<NonNullType<StringType>>()
.Resolver(ctx => $"{mvcApiUrl}/api/file/123")
.UseBewitUrlProtection();
}))
.Create();
You'll also need to register some things in the service container:
services.AddBewitGeneration<string>(
new BewitOptions
{
Secret = "my encryption key",
TokenDuration = TimeSpan.FromMinutes(1) //lifespan of the generated url
},
builder => builder.UseHmacSha256Encryption()
);
MVC Server
Create a simple Asp.Net MVC Server with the following Controller:
[Route("api/[controller]")]
[ApiController]
public class FileController: Controller
{
[HttpGet("{id}")]
[BewitUrlAuthorization]
public FileResult GetFile(string id)
{
return File(/* your file here*/);
}
}
You'll also need to register some things in the service container:
services.AddBewitUrlAuthorizationFilter(
new BewitOptions
{
Secret = "my encryption key"
},
builder => builder
.UseHmacSha256Encryption()
);
Use
You can now generate secure download urls by calling your mutation:
mutation foo {
requestAccessUrl
}
Features
Generating secured Links
- Vanilla (no overhead)
- HotChocolate integration
- graphql-dotnet integration
Authentication
- Asp.Net MVC
Persistance (for Stateful authentication)
- MongoDb
- Sql Server
- Azure Blob Storage
- PostgresSQL
Community
This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community. For more information, see the Swiss Life OSS Code of Conduct.
Product | Versions 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 is compatible. 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 is compatible. 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. |
-
net6.0
- Bewit (>= 5.0.0-preview.6)
- Bewit.Generation (>= 5.0.0-preview.6)
- Bewit.Validation (>= 5.0.0-preview.6)
- HotChocolate.Execution (>= 14.0.0-rc.3)
- HotChocolate.Types (>= 14.0.0-rc.3)
-
net7.0
- Bewit (>= 5.0.0-preview.6)
- Bewit.Generation (>= 5.0.0-preview.6)
- Bewit.Validation (>= 5.0.0-preview.6)
- HotChocolate.Execution (>= 14.0.0-rc.3)
- HotChocolate.Types (>= 14.0.0-rc.3)
-
net8.0
- Bewit (>= 5.0.0-preview.6)
- Bewit.Generation (>= 5.0.0-preview.6)
- Bewit.Validation (>= 5.0.0-preview.6)
- HotChocolate.Execution (>= 14.0.0-rc.3)
- HotChocolate.Types (>= 14.0.0-rc.3)
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 |
---|---|---|
5.0.0-rc.2 | 112 | 11/14/2024 |
5.0.0-rc.1 | 49 | 10/17/2024 |
5.0.0-preview.7 | 57 | 10/9/2024 |
5.0.0-preview.6 | 53 | 10/9/2024 |
5.0.0-preview.5 | 59 | 10/8/2024 |
5.0.0-preview.4 | 51 | 10/8/2024 |
5.0.0-preview.3 | 49 | 10/8/2024 |
4.0.0 | 3,919 | 2/10/2023 |
3.1.0 | 1,006 | 10/7/2022 |
3.1.0-preview.3 | 132 | 10/6/2022 |
3.1.0-preview.2 | 104 | 10/6/2022 |
3.0.0 | 416 | 10/3/2022 |
2.1.0 | 438 | 10/27/2021 |
2.0.0-preview.6 | 19,357 | 3/4/2021 |
2.0.0-preview.5 | 182 | 3/3/2021 |
2.0.0-preview.4 | 212 | 3/3/2021 |
2.0.0-preview.3 | 201 | 3/2/2021 |
2.0.0-preview.2 | 186 | 3/2/2021 |
2.0.0-preview.1 | 204 | 3/2/2021 |
1.0.1 | 386 | 3/2/2021 |
1.0.0 | 362 | 3/1/2021 |
0.2.0-preview.1 | 300 | 11/6/2020 |
0.1.0 | 312 | 10/5/2020 |
0.1.0-preview.4 | 262 | 10/5/2020 |
0.1.0-preview.3 | 250 | 10/5/2020 |
Release notes: https://github.com/SwissLife-OSS/bewit/releases/