Class KeycloakWebApiServiceCollectionExtensions
- Namespace
- Keycloak.AuthServices.Authentication
- Assembly
- Keycloak.AuthServices.Authentication.dll
Extension for IServiceCollection for startup initialization of web APIs.
public static class KeycloakWebApiServiceCollectionExtensions
- Inheritance
-
KeycloakWebApiServiceCollectionExtensions
- Inherited Members
Methods
AddKeycloakWebApiAuthentication(IServiceCollection, IConfiguration, Action<JwtBearerOptions>, string, string)
Protects the web API with Keycloak. This method expects the configuration file will have a section, named "Keycloak" as default, with the necessary settings to initialize authentication options.
public static KeycloakWebApiAuthenticationBuilder AddKeycloakWebApiAuthentication(this IServiceCollection services, IConfiguration configuration, Action<JwtBearerOptions> configureJwtBearerOptions, string configSectionName = "Keycloak", string jwtBearerScheme = "Bearer")
Parameters
services
IServiceCollectionThe service collection to which to add authentication.
configuration
IConfigurationThe Configuration object.
configureJwtBearerOptions
Action<JwtBearerOptions>A delegate to configure the JwtBearerOptions.
configSectionName
stringThe configuration section with the necessary settings to initialize authentication options. Default value is "KeycloakAuthenticationOptions.Section".
jwtBearerScheme
stringThe JwtBearer scheme name to be used. Default value is "JwtBearerDefaults.AuthenticationScheme".
Returns
- KeycloakWebApiAuthenticationBuilder
The authentication builder to chain extension methods.
AddKeycloakWebApiAuthentication(IServiceCollection, IConfiguration, string, string)
Protects the web API with Keycloak. This method expects the configuration file will have a section, named "Keycloak" as default, with the necessary settings to initialize authentication options.
public static KeycloakWebApiAuthenticationBuilder AddKeycloakWebApiAuthentication(this IServiceCollection services, IConfiguration configuration, string configSectionName = "Keycloak", string jwtBearerScheme = "Bearer")
Parameters
services
IServiceCollectionThe service collection to which to add authentication.
configuration
IConfigurationThe Configuration object.
configSectionName
stringThe configuration section with the necessary settings to initialize authentication options. Default value is "KeycloakAuthenticationOptions.Section".
jwtBearerScheme
stringThe JwtBearer scheme name to be used. Default value is "JwtBearerDefaults.AuthenticationScheme".
Returns
- KeycloakWebApiAuthenticationBuilder
The authentication builder to chain extension methods.
AddKeycloakWebApiAuthentication(IServiceCollection, IConfigurationSection, string)
Protects the web API with Keycloak. This method expects the configuration file will have a section, named "Keycloak" as default, with the necessary settings to initialize authentication options.
public static KeycloakWebApiAuthenticationBuilder AddKeycloakWebApiAuthentication(this IServiceCollection services, IConfigurationSection configurationSection, string jwtBearerScheme = "Bearer")
Parameters
services
IServiceCollectionThe service collection to which to add authentication.
configurationSection
IConfigurationSectionThe Configuration section object.
jwtBearerScheme
stringThe JwtBearer scheme name to be used. Default value is "JwtBearerDefaults.AuthenticationScheme".
Returns
- KeycloakWebApiAuthenticationBuilder
The authentication builder to chain extension methods.
AddKeycloakWebApiAuthentication(IServiceCollection, Action<KeycloakAuthenticationOptions>, Action<JwtBearerOptions>?, string)
Protects the web API with Keycloak.
public static KeycloakWebApiAuthenticationBuilder AddKeycloakWebApiAuthentication(this IServiceCollection services, Action<KeycloakAuthenticationOptions> configureKeycloakOptions, Action<JwtBearerOptions>? configureJwtBearerOptions = null, string jwtBearerScheme = "Bearer")
Parameters
services
IServiceCollectionThe service collection to which to add authentication.
configureKeycloakOptions
Action<KeycloakAuthenticationOptions>configureJwtBearerOptions
Action<JwtBearerOptions>jwtBearerScheme
stringThe JwtBearer scheme name to be used. Default value is "JwtBearerDefaults.AuthenticationScheme".
Returns
- KeycloakWebApiAuthenticationBuilder
The authentication builder to chain extension methods.