Table of Contents

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 IServiceCollection

The service collection to which to add authentication.

configuration IConfiguration

The Configuration object.

configureJwtBearerOptions Action<JwtBearerOptions>

A delegate to configure the JwtBearerOptions.

configSectionName string

The configuration section with the necessary settings to initialize authentication options. Default value is "KeycloakAuthenticationOptions.Section".

jwtBearerScheme string

The 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 IServiceCollection

The service collection to which to add authentication.

configuration IConfiguration

The Configuration object.

configSectionName string

The configuration section with the necessary settings to initialize authentication options. Default value is "KeycloakAuthenticationOptions.Section".

jwtBearerScheme string

The 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 IServiceCollection

The service collection to which to add authentication.

configurationSection IConfigurationSection

The Configuration section object.

jwtBearerScheme string

The 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 IServiceCollection

The service collection to which to add authentication.

configureKeycloakOptions Action<KeycloakAuthenticationOptions>
configureJwtBearerOptions Action<JwtBearerOptions>
jwtBearerScheme string

The JwtBearer scheme name to be used. Default value is "JwtBearerDefaults.AuthenticationScheme".

Returns

KeycloakWebApiAuthenticationBuilder

The authentication builder to chain extension methods.