# Microsoft.AspNet.Identity.Owin

**Kind:** Service

**Source:** `Pams/Core/Pams.Security/Pams.Security.csproj` (line 1)

**Part of:** [Pams](subsystem-pams)

NuGet package dependency

`Microsoft.AspNet.Identity.Owin` is a NuGet package dependency declared by the Pams.Security project. It connects ASP.NET Identity authentication components with the OWIN request pipeline so the application can create, validate, and access authenticated user identities.

## Diagram

```mermaid
sequenceDiagram
    participant Client
    participant App as ASP.NET Application
    participant OWIN as OWIN Pipeline
    participant Identity as ASP.NET Identity

    Client->>App: Send authenticated request
    App->>OWIN: Process request
    OWIN->>Identity: Validate authentication cookie
    Identity-->>OWIN: Return user identity
    OWIN-->>App: Populate authenticated principal
    App-->>Client: Return protected response
```

## Usage

```typescript
// A frontend client sends requests to an ASP.NET application that
// authenticates requests through Microsoft.AspNet.Identity.Owin.

async function loadCurrentUser() {
  const response = await fetch("/api/account/current", {
    credentials: "include",
    headers: {
      Accept: "application/json",
    },
  });

  if (!response.ok) {
    throw new Error("Authentication is required.");
  }

  return response.json();
}

loadCurrentUser().then((user) => {
  console.log("Authenticated user:", user);
});
```

## AI Coding Instructions

- Keep `Microsoft.AspNet.Identity.Owin` package references aligned with the ASP.NET Identity and OWIN package versions used by Pams.Security.
- Configure authentication middleware before endpoints that require an authenticated user.
- Access the authenticated principal from the OWIN or ASP.NET request context rather than trusting client-provided user identifiers.
- Preserve the legacy project package reference format when editing `Pams.Security.csproj` unless the project is intentionally migrated.
