# Owin

**Kind:** Service

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

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

NuGet package dependency

`Owin` is a NuGet package dependency declared by `Pams.Security.csproj`. It supplies OWIN interfaces used to connect security middleware to the application request pipeline in the legacy project format.

## Diagram

```mermaid
sequenceDiagram
    participant Client
    participant Host as OWIN Host
    participant Security as Pams.Security Middleware
    participant App as Application

    Client->>Host: HTTP request
    Host->>Security: Invoke OWIN middleware
    Security->>Security: Evaluate security context
    Security->>App: Continue request pipeline
    App-->>Host: HTTP response
    Host-->>Client: HTTP response
```

## Usage

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

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

  return response.json();
}
```

## AI Coding Instructions

- Keep OWIN-related dependencies declared in `Pams.Security.csproj` with the existing legacy package reference style.
- Add security behavior through the OWIN middleware pipeline rather than handling authentication separately in each endpoint.
- Ensure middleware passes the request to the next OWIN component after security checks succeed.
- Verify client requests send the authentication headers expected by the OWIN security middleware.
