Skip to content

Commit 3a12976

Browse files
committed
clean up sample
1 parent 621b146 commit 3a12976

File tree

1 file changed

+10
-7
lines changed
  • aspnetcore/migration/fx-to-core/areas

1 file changed

+10
-7
lines changed

aspnetcore/migration/fx-to-core/areas/owin.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@ Register OWIN authentication as an ASP.NET Core authentication handler:
107107
```csharp
108108
var builder = WebApplication.CreateBuilder(args);
109109

110-
builder.Services
111-
.AddSystemWebAdapters()
112-
.AddAuthentication()
110+
builder.Services.AddAuthentication()
113111
.AddOwinAuthentication((owinApp, services) =>
114112
{
115113
owinApp.UseCookieAuthentication(new CookieAuthenticationOptions
@@ -124,6 +122,8 @@ var app = builder.Build();
124122
app.UseAuthentication();
125123
app.UseAuthorization();
126124

125+
// Additional middleware or endpoint mapping
126+
127127
app.Run();
128128
```
129129

@@ -168,13 +168,16 @@ For more information about authentication schemes and how they work in ASP.NET C
168168
Continue using the OWIN `IAuthenticationManager` interface:
169169

170170
```csharp
171-
var owinContext = HttpContext.GetOwinContext();
172-
var authManager = owinContext.Authentication;
171+
var authManager = HttpContext.GetOwinContext().Authentication;
173172

174173
authManager.SignIn(identity);
175174
authManager.SignOut();
176175
```
177176

177+
### <xref:System.Security.Claims.ClaimsPrincipal.Current?displayProperty=nameWithType>
178+
179+
If code is expecting to use <xref:System.Security.Claims.ClaimsPrincipal.Current?displayProperty=nameWithType>, then see <xref:migration/fx-to-core/areas/claimsprincipal-current> for options to enable setting that property.
180+
178181
## Migrating ASP.NET Framework Identity
179182

180183
A common migration scenario involves ASP.NET Framework Identity with OWIN cookie authentication. This example shows how to maintain compatibility during migration.
@@ -199,15 +202,15 @@ Set up OWIN authentication with Identity services:
199202
```csharp
200203
builder.Services
201204
.AddAuthentication()
202-
.AddOwinAuthentication("SharedCookie", (app, services) =>
205+
.AddOwinAuthentication("AppAuthenticationScheme", (app, services) =>
203206
{
204207
app.CreatePerOwinContext(ApplicationDbContext.Create);
205208
app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
206209
app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);
207210

208211
var dataProtector = services.GetDataProtector(
209212
"Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware",
210-
"SharedCookie",
213+
"AppAuthenticationScheme",
211214
"v2");
212215

213216
app.UseCookieAuthentication(new CookieAuthenticationOptions

0 commit comments

Comments
 (0)