diff --git a/README.md b/README.md index 8b295219..c306f654 100644 --- a/README.md +++ b/README.md @@ -83,32 +83,35 @@ public void ConfigureServices(IServiceCollection services) .AddEntityFrameworkStores() .AddDefaultTokenProviders(); - // Register the OAuth2 validation handler. - services.AddAuthentication() - .AddOAuthValidation(); - // Register the OpenIddict services. - // Note: use the generic overload if you need - // to replace the default OpenIddict entities. - services.AddOpenIddict(options => - { - // Register the Entity Framework stores. - options.AddEntityFrameworkCoreStores(); + services.AddOpenIddict() + .AddCore(options => + { + // Configure OpenIddict to use the default entities. + options.UseDefaultModels(); - // Register the ASP.NET Core MVC binder used by OpenIddict. - // Note: if you don't call this method, you won't be able to - // bind OpenIdConnectRequest or OpenIdConnectResponse parameters. - options.AddMvcBinders(); + // Register the Entity Framework stores. + options.AddEntityFrameworkCoreStores(); + }) - // Enable the token endpoint (required to use the password flow). - options.EnableTokenEndpoint("/connect/token"); + .AddServer(options => + { + // Register the ASP.NET Core MVC binder used by OpenIddict. + // Note: if you don't call this method, you won't be able to + // bind OpenIdConnectRequest or OpenIdConnectResponse parameters. + options.AddMvcBinders(); - // Allow client applications to use the grant_type=password flow. - options.AllowPasswordFlow(); + // Enable the token endpoint (required to use the password flow). + options.EnableTokenEndpoint("/connect/token"); - // During development, you can disable the HTTPS requirement. - options.DisableHttpsRequirement(); - }); + // Allow client applications to use the grant_type=password flow. + options.AllowPasswordFlow(); + + // During development, you can disable the HTTPS requirement. + options.DisableHttpsRequirement(); + }) + + .AddValidation(); } ``` @@ -142,12 +145,19 @@ services.AddDbContext(options => }); ``` -> **Note:** if you change the default entity primary key (e.g. to `int` or `Guid` instead of `string`), make sure to use the `services.AddOpenIddict()` extension accepting a `TKey` generic argument and use the generic `options.UseOpenIddict()` overload: +> **Note:** if you change the default entity primary key (e.g. to `int` or `Guid` instead of `string`), make sure you use the `options.UseDefaultModels()` extension accepting a `TKey` generic argument and use the generic `options.UseOpenIddict()` overload to configure Entity Framework Core to use the specified key type: ```csharp -services.AddOpenIddict() - .AddEntityFrameworkCoreStores() +services.AddOpenIddict() + .AddCore(options => + { + // Configure OpenIddict to use the default entities. + options.UseDefaultModels(); + + // Register the Entity Framework stores. + options.AddEntityFrameworkCoreStores(); + }); services.AddDbContext(options => { @@ -171,28 +181,35 @@ The **Mvc.Server sample comes with an [`AuthorizationController` that supports b public void ConfigureServices(IServiceCollection services) { // Register the OpenIddict services. - // Note: use the generic overload if you need - // to replace the default OpenIddict entities. - services.AddOpenIddict(options => - { - // Register the Entity Framework stores. - options.AddEntityFrameworkCoreStores(); + services.AddOpenIddict() + .AddCore(options => + { + // Configure OpenIddict to use the default entities. + options.UseDefaultModels(); + + // Register the Entity Framework stores. + options.AddEntityFrameworkCoreStores(); + }) - // Register the ASP.NET Core MVC binder used by OpenIddict. - // Note: if you don't call this method, you won't be able to - // bind OpenIdConnectRequest or OpenIdConnectResponse parameters. - options.AddMvcBinders(); + .AddServer(options => + { + // Register the ASP.NET Core MVC binder used by OpenIddict. + // Note: if you don't call this method, you won't be able to + // bind OpenIdConnectRequest or OpenIdConnectResponse parameters. + options.AddMvcBinders(); - // Enable the authorization and token endpoints (required to use the code flow). - options.EnableAuthorizationEndpoint("/connect/authorize") - .EnableTokenEndpoint("/connect/token"); + // Enable the authorization and token endpoints (required to use the code flow). + options.EnableAuthorizationEndpoint("/connect/authorize") + .EnableTokenEndpoint("/connect/token"); - // Allow client applications to use the code flow. - options.AllowAuthorizationCodeFlow(); + // Allow client applications to use the code flow. + options.AllowAuthorizationCodeFlow(); - // During development, you can disable the HTTPS requirement. - options.DisableHttpsRequirement(); - }); + // During development, you can disable the HTTPS requirement. + options.DisableHttpsRequirement(); + }) + + .AddValidation(); } ```