Browse Source

Backport the README.md changes to the release branch

pull/670/head
Kévin Chalet 8 years ago
parent
commit
3c7fd20400
  1. 101
      README.md

101
README.md

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

Loading…
Cancel
Save