Class OidcOptionsExtensions
- Namespace
- Htmx.Components
- Assembly
- Htmx.Components.dll
Provides extension methods for configuring OpenID Connect authentication with HTMX support.
public static class OidcOptionsExtensions
- Inheritance
-
OidcOptionsExtensions
- Inherited Members
Remarks
These extensions modify the OIDC authentication flow to work seamlessly with HTMX requests by providing alternative handling for authentication challenges and access denied scenarios. Instead of performing redirects that would break HTMX functionality, these methods return appropriate HTTP status codes and headers that HTMX can handle.
Methods
ConfigureHtmxAuthPopup(OpenIdConnectOptions, string)
Configures OpenID Connect options to handle authentication popups for HTMX requests.
public static void ConfigureHtmxAuthPopup(this OpenIdConnectOptions oidc, string url)
Parameters
oidc
OpenIdConnectOptionsThe OpenID Connect options to configure.
url
stringThe URL to display in the authentication popup.
Examples
services.Configure<OpenIdConnectOptions>("oidc", options =>
{
options.ConfigureHtmxAuthPopup("/auth/login");
// ... other OIDC configuration
});
Remarks
This method modifies the OIDC authentication flow to be compatible with HTMX requests. When an HTMX request encounters an authentication challenge, instead of performing a redirect that would break the HTMX flow, it returns a 401 status with a custom header that instructs the client to open a popup for authentication.
Similarly, when access is denied, it returns a 403 status with an HTMX trigger that can be handled by client-side JavaScript.
Exceptions
- ArgumentNullException
Thrown when
oidc
orurl
is null.