|
1 |
| -# BFF.Blazor |
| 1 | +# Duende.BFF.Blazor |
| 2 | + |
| 3 | +[](https://www.nuget.org/packages/BFF.Blazor) |
| 4 | + |
| 5 | +`Duende.BFF.Blazor` is a specialized .NET library designed to support secure browser-based applications, mainly using the Backend for Frontend (BFF) pattern in combination with Blazor Server, Blazor WASM (WebAssembly), and SPA frontends. |
| 6 | + |
| 7 | +It facilitates simpler and safer implementations of OpenID Connect (OIDC) and OAuth2 flows by moving token handling and other protocol interactions to the server. |
| 8 | + |
| 9 | +[Learn more about the BFF pattern](https://docs.duendesoftware.com/bff/). |
| 10 | + |
| 11 | +--- |
| 12 | + |
| 13 | +## Features |
| 14 | + |
| 15 | +- **Token Management**: Provides server-side storage and handling of access tokens, improving security by removing tokens from the browser. |
| 16 | +- **Seamless Integration With Blazor**: Easily integrates with Blazor Server or Blazor WASM applications, streamlining authentication functionalities. |
| 17 | +- **Customizable Security**: Includes extension points to customize claims transformation, authentication logic, and session management. |
| 18 | +- **Supports Modern OAuth2 and OIDC Flows**: Works around browser privacy restrictions affecting OAuth/OIDC protocols. |
| 19 | +- **Proxies for Secure API Access**: Enables secure API calls via the server to prevent token exposure to the client. |
| 20 | + |
| 21 | +--- |
| 22 | + |
| 23 | +## Getting Started |
| 24 | + |
| 25 | +To get started with **Duende.BFF.Blazor**, follow these steps: |
| 26 | + |
| 27 | +### Installation via NuGet |
| 28 | + |
| 29 | +You can install the library via NuGet: |
| 30 | + |
| 31 | +```bash |
| 32 | +dotnet add package Duende.BFF.Blazor |
| 33 | +``` |
| 34 | + |
| 35 | +### Dependencies |
| 36 | + |
| 37 | +Ensure your project targets **.NET 8.0 or higher** and references ASP.NET Core for Blazor development. |
| 38 | + |
| 39 | +This library also integrates seamlessly with [Duende IdentityServer](https://duendesoftware.com/products/identityserver) or other compliant providers for OIDC and OAuth2. |
| 40 | + |
| 41 | +--- |
| 42 | + |
| 43 | +## Usage |
| 44 | + |
| 45 | +### Quick Example |
| 46 | + |
| 47 | +1. **Configure Services** |
| 48 | + Add the necessary services in your `Startup.cs` or `Program.cs`: |
| 49 | + |
| 50 | + ```csharp |
| 51 | + builder.Services.AddBff() |
| 52 | + .AddBlazorBffServer() |
| 53 | + .AddServerSideManagementClaims(); |
| 54 | + ``` |
| 55 | + |
| 56 | +2. **Update Middleware Pipeline** |
| 57 | + Update your app's middleware pipeline to include BFF features: |
| 58 | + |
| 59 | + ```csharp |
| 60 | + app.UseRouting(); |
| 61 | + app.UseAuthentication(); |
| 62 | + app.UseBff(); |
| 63 | + app.UseAuthorization(); |
| 64 | + |
| 65 | + app.MapBffManagementApis(); |
| 66 | + app.MapControllers(); |
| 67 | + ``` |
| 68 | + |
| 69 | +3. **Secure API Endpoints** |
| 70 | + Secure your API endpoints using the `[Authorize]` attribute to ensure they adhere to authentication and authorization policies. |
| 71 | + |
| 72 | + ```csharp |
| 73 | + [Authorize] |
| 74 | + [HttpGet("/api/secure-data")] |
| 75 | + public IActionResult GetSecureData() |
| 76 | + { |
| 77 | + return Ok(new { Message = "Secure data accessed" }); |
| 78 | + } |
| 79 | + ``` |
| 80 | + |
| 81 | +4. **Integrate with Blazor Components** |
| 82 | + Use `AuthenticationStateProvider` or other related services to manage authentication state within your Blazor components. |
| 83 | + |
| 84 | +## Documentation |
| 85 | + |
| 86 | +Extensive documentation is available to guide you through key concepts, setup details, and advanced configuration options: |
| 87 | + |
| 88 | +- [API Documentation](https://docs.duendesoftware.com/bff/fundamentals/) |
| 89 | +- [Blazor Integration Guide](https://docs.duendesoftware.com/bff/fundamentals/blazor/) |
| 90 | + |
| 91 | +## Related Projects |
| 92 | + |
| 93 | +- [Duende.IdentityServer](https://github.com/DuendeSoftware/products) - Standards-compliant OpenID Connect and OAuth 2.0 framework. |
| 94 | +- [BFF.YARP](https://www.nuget.org/packages/Duende.BFF.Yarp) - BFF integration with YARP for reverse proxying. |
| 95 | + |
| 96 | +## Licensing |
| 97 | + |
| 98 | +**BFF.Blazor** is source-available, but requires a paid license for production use: |
| 99 | + |
| 100 | +- **Development and Testing**: Free to use and explore for personal or development purposes. |
| 101 | +- **Production Use**: A commercial license is required. Visit [Duende Licensing](https://duendesoftware.com/license) for details. |
| 102 | +- **Community Edition**: A free Community Edition license is available for qualifying organizations. Learn more [here](https://duendesoftware.com/products/communityedition). |
| 103 | + |
| 104 | +By using **Duende.BFF.Blazor**, you agree to abide by its [licensing terms](https://duendesoftware.com/license). |
| 105 | + |
| 106 | +## Contributing |
| 107 | + |
| 108 | +We welcome community contributions. Please refer to our [contributing guidelines](https://github.com/YourGitHub/bff-blazor/blob/main/CONTRIBUTING.md) for more information. |
| 109 | + |
| 110 | +## Support and Issues |
| 111 | + |
| 112 | +- **Report Issues**: Use [GitHub Issues](https://github.com/duendesoftware/products/issues) for bugs and feature requests. |
| 113 | +- **Security Concerns **: For security-related inquiries, contact **[email protected]**. |
| 114 | +- **Community Discussions**: Join our [developer forum](https://github.com/duendesoftware/community). |
| 115 | + |
0 commit comments