# scorpiox-identity-server-native

Native C CGI route handlers for **Personal Identity Server** — a local OpenID Connect (OIDC) and OAuth 2.0 authorization server.

Powered by `scorpiox-server.dll` (pure C HTTP engine) with zero external runtime dependencies.

## Architecture

```
scorpiox-server.dll   web_server_start(port, {root_dir: handlers/})
        │
        ▼  (native CGI executable dispatch)
  wellknown  authorize  token  userinfo  jwks  login  logout  api  index  _fallback
        │
        ▼
  JSON Data Store in IDENTITY_DATA_DIR:
    users.json    clients.json    tokens.json    secret.key
```

## Features

- **OpenID Connect Discovery**: `/.well-known/openid-configuration` & `/wellknown`
- **OAuth 2.0 Authorization Code Flow + PKCE**:
  - `S256` and `plain` code challenge methods supported
  - Secure redirect URI validation (exact matching)
- **Token Endpoint**:
  - `grant_type=authorization_code` (PKCE verification -> access_token + id_token + refresh_token)
  - `grant_type=refresh_token` (single-use refresh token rotation)
- **JWT HS256**: Embedded pure-C SHA-256 / HMAC-SHA256 / PBKDF2 (100,000 iterations)
- **User Management**: Session cookies, login form / JSON authentication, password hashing
- **Administration API**: `/api?r=users`, `/api?r=clients`, `/api?r=tokens`, `/api?r=status`
- **Zero Dependencies**: Pure C99, vendored `yyjson` (MIT), embedded crypto.

## Build

### Linux
```bash
mkdir build && cd build
cmake ..
cmake --build . -j8
```

### Windows (MinGW static)
```powershell
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -S . -B build
cmake --build build --config Release
```

## License
MIT / Public Domain.
