mirror of https://github.com/abpframework/abp.git
1 changed files with 185 additions and 0 deletions
@ -0,0 +1,185 @@ |
|||
# OpenIddict Blazor Wasm UI Migration Guide |
|||
|
|||
## Blazor Project |
|||
|
|||
- In the **MyApplicationBlazorModule.cs** update the `ConfigureAuthentication` method: |
|||
|
|||
```csharp |
|||
builder.Services.AddOidcAuthentication(options => |
|||
{ |
|||
... |
|||
options.UserOptions.RoleClaim = JwtClaimTypes.Role; |
|||
|
|||
options.ProviderOptions.DefaultScopes.Add("role"); |
|||
... |
|||
}); |
|||
``` |
|||
|
|||
Update **UserOptions** and **role scope** as below |
|||
|
|||
```csharp |
|||
builder.Services.AddOidcAuthentication(options => |
|||
{ |
|||
... |
|||
options.UserOptions.NameClaim = OpenIddictConstants.Claims.Name; |
|||
options.UserOptions.RoleClaim = OpenIddictConstants.Claims.Role; |
|||
|
|||
options.ProviderOptions.DefaultScopes.Add("roles"); |
|||
... |
|||
}); |
|||
``` |
|||
|
|||
## Http.Api.Host (Non-Separated IdentityServer) |
|||
|
|||
- In the **MyApplication.HttpApi.Host.csproj** replace **project references**: |
|||
|
|||
```csharp |
|||
<PackageReference Include="Volo.Abp.AspNetCore.Authentication.JwtBearer" Version="6.0.0-rc.1" /> |
|||
<PackageReference Include="Volo.Abp.Account.Web.IdentityServer" Version="6.0.0-rc.1" /> |
|||
``` |
|||
|
|||
with |
|||
|
|||
```csharp |
|||
<PackageReference Include="Volo.Abp.Account.Web.OpenIddict" Version="6.0.0-rc.1" /> |
|||
``` |
|||
|
|||
- In the **MyApplicationHttpApiHostModule.cs** replace usings and **module dependencies**: |
|||
|
|||
```csharp |
|||
using System.Net.Http; |
|||
using Volo.Abp.AspNetCore.Authentication.JwtBearer; |
|||
... |
|||
typeof(AbpAspNetCoreAuthenticationJwtBearerModule), |
|||
typeof(AbpAccountWebIdentityServerModule), |
|||
``` |
|||
|
|||
with |
|||
|
|||
```csharp |
|||
using OpenIddict.Validation.AspNetCore; |
|||
... |
|||
typeof(AbpAccountWebOpenIddictModule), |
|||
``` |
|||
|
|||
- In the **MyApplicationBlazorModule.cs** add `PreConfigureServices` like below with your application name as the audience: |
|||
|
|||
```csharp |
|||
public override void PreConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
PreConfigure<OpenIddictBuilder>(builder => |
|||
{ |
|||
builder.AddValidation(options => |
|||
{ |
|||
options.AddAudiences("MyApplication"); // Replace with your application name |
|||
options.UseLocalServer(); |
|||
options.UseAspNetCore(); |
|||
}); |
|||
}); |
|||
} |
|||
``` |
|||
|
|||
- In the **MyApplicationBlazorModule.cs** `ConfigureServices` method, **replace the method call**: |
|||
|
|||
From `ConfigureAuthentication(context, configuration);` to `ConfigureAuthentication(context);` and update the method as: |
|||
|
|||
```csharp |
|||
private void ConfigureAuthentication(ServiceConfigurationContext context) |
|||
{ |
|||
context.Services.ForwardIdentityAuthenticationForBearer(OpenIddictValidationAspNetCoreDefaults.AuthenticationScheme); |
|||
} |
|||
``` |
|||
|
|||
- In the **MyApplicationBlazorModule.cs** `OnApplicationInitialization` method, **replace the midware**: |
|||
|
|||
```csharp |
|||
app.UseJwtTokenMiddleware(); |
|||
app.UseIdentityServer(); |
|||
``` |
|||
|
|||
with |
|||
|
|||
``` |
|||
app.UseAbpOpenIddictValidation(); |
|||
``` |
|||
|
|||
- Delete `c.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);` in `app.UseAbpSwaggerUI` options configurations which is no longer needed. |
|||
|
|||
- In `appsettings.json` delete **SwaggerClientSecret** from the *AuthServer* section like below: |
|||
|
|||
```json |
|||
"AuthServer": { |
|||
"Authority": "https://localhost:44345", |
|||
"RequireHttpsMetadata": "false", |
|||
"SwaggerClientId": "MyApplication_Swagger" |
|||
}, |
|||
``` |
|||
|
|||
## Http.Api.Host (Separated IdentityServer) |
|||
|
|||
- In the **MyApplicationHttpApiHostModule.cs** `OnApplicationInitialization` method, delete `c.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);` in `app.UseAbpSwaggerUI` options configurations which is no longer needed. |
|||
|
|||
- In `appsettings.json` delete **SwaggerClientSecret** from the *AuthServer* section like below: |
|||
|
|||
```json |
|||
"AuthServer": { |
|||
"Authority": "https://localhost:44345", |
|||
"RequireHttpsMetadata": "false", |
|||
"SwaggerClientId": "MyApplication_Swagger" |
|||
}, |
|||
``` |
|||
|
|||
## MyApplication.IdentityServer |
|||
|
|||
This project is renamed to **MyApplication.AuthServer** after v6.0.0-rc1. |
|||
|
|||
- In **MyApplication.IdentityServer.csproj** replace **project references**: |
|||
|
|||
```csharp |
|||
<PackageReference Include="Volo.Abp.Account.Web.IdentityServer" Version="6.0.0-rc.1" /> |
|||
``` |
|||
|
|||
with |
|||
|
|||
```csharp |
|||
<PackageReference Include="Volo.Abp.Account.Web.OpenIddict" Version="6.0.0-rc.1" /> |
|||
``` |
|||
|
|||
- In the **MyApplicationIdentityServerModule.cs** replace usings and **module dependencies**: |
|||
|
|||
```csharp |
|||
typeof(AbpAccountWebIdentityServerModule), |
|||
``` |
|||
|
|||
with |
|||
|
|||
```csharp |
|||
typeof(AbpAccountWebOpenIddictModule), |
|||
``` |
|||
|
|||
- In the **MyApplicationIdentityServerModule.cs** add `PreConfigureServices` like below with your application name as the audience: |
|||
|
|||
```csharp |
|||
public override void PreConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
PreConfigure<OpenIddictBuilder>(builder => |
|||
{ |
|||
builder.AddValidation(options => |
|||
{ |
|||
options.AddAudiences("MyApplication"); // Replace with your application name |
|||
options.UseLocalServer(); |
|||
options.UseAspNetCore(); |
|||
}); |
|||
}); |
|||
} |
|||
``` |
|||
|
|||
- In the **MyApplicationIdentityServerModule.cs** `OnApplicationInitialization` method, **remove the midware**: |
|||
|
|||
```csharp |
|||
app.UseIdentityServer(); |
|||
``` |
|||
|
|||
## See Also |
|||
|
|||
* [OpenIddict Step-by-Step Guide](./OpenIddict-Step-by-Step.md) |
|||
Loading…
Reference in new issue