# Microsoft.Owin.Security

**Kind:** Service

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

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

NuGet package dependency

`Microsoft.Owin.Security` is a NuGet package dependency in the Pams API project that supports authentication and authorization middleware for OWIN-based requests. It participates in the API request pipeline by reading authentication data and setting the request identity used by protected endpoints.

## Diagram

```mermaid
sequenceDiagram
    participant Client
    participant PamsAPI as Pams API
    participant OwinSecurity as Microsoft.Owin.Security
    participant Endpoint as Protected Endpoint

    Client->>PamsAPI: Send request with authentication data
    PamsAPI->>OwinSecurity: Process authentication middleware
    OwinSecurity->>PamsAPI: Set authenticated identity or reject request
    PamsAPI->>Endpoint: Invoke authorized endpoint
    Endpoint-->>Client: Return API response
```

## Usage

```typescript
async function getProtectedPamsData(token: string) {
  const response = await fetch("/api/pams/protected-resource", {
    headers: {
      Authorization: `Bearer ${token}`,
      Accept: "application/json"
    }
  });

  if (!response.ok) {
    throw new Error(`Pams API request failed: ${response.status}`);
  }

  return response.json();
}
```

## AI Coding Instructions

- Treat `Microsoft.Owin.Security` as a server-side dependency configured in the Pams API OWIN pipeline, not as a browser package.
- Send authentication credentials through the expected HTTP header format when calling protected Pams API endpoints.
- Keep authentication middleware registration before routes or middleware that require an authenticated identity.
- Check the installed package version and related OWIN packages in `Pams.API.csproj` before changing authentication configuration.
