Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 7 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,48 +9,29 @@ on:
types: [created]

jobs:
format:
if: github.repository_owner == 'essinghigh-org'
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ github.head_ref }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install formatters
run: pip install black isort
- name: Format code
run: black . && isort --profile black .
- name: Commit changes
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add .
if git diff --staged --quiet; then
echo "No changes to commit"
else
git commit -m "style: formatting"
git push
fi
- uses: oven-sh/setup-bun@v1
- run: bun install
- run: bun test

opencode:
if: |
github.repository_owner == 'essinghigh-org' &&
(github.event_name == 'pull_request' ||
contains(github.event.comment.body, '/oc') || contains(github.event.comment.body, '/opencode'))
runs-on: ubuntu-latest
needs: format
needs: test
permissions:
id-token: write
contents: write
pull-requests: write
issues: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
uses: actions/checkout@v4
with:
persist-credentials: false

Expand Down
42 changes: 0 additions & 42 deletions .github/workflows/publish-image.yml.disabled

This file was deleted.

35 changes: 33 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
# dependencies (bun install)
node_modules
bun.lock
package-lock.json

# output
out
dist
*.tgz

# code coverage
coverage
*.lcov

# logs
logs
_.log
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# caches
.eslintcache
.cache
*.tsbuildinfo

# IntelliJ based IDEs
.idea

# Finder (MacOS) folder config
.DS_Store
11 changes: 0 additions & 11 deletions .vscode/mcp.json

This file was deleted.

72 changes: 70 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,71 @@
# Grafana OAUTH2 to RADIUS Login
# ts-radius-client

<img width="1623" height="760" alt="image" src="https://github.com/user-attachments/assets/a2f9d54d-d5c7-44a6-988a-af1438938485" />
A standards-compliant RADIUS client for TypeScript/Bun, extracted from a production OAuth2 proxy.

## Features

- **Standards Compliant**: Supports RFC 2865 (PAP authentication) and RFC 2869.
- **Failover**: Automatic failover to backup hosts on timeout.
- **Health Checks**: Background health checks to restore primary hosts.
- **Configurable**: extensive configuration for timeouts, retries, and attribute extraction.
- **TypeScript**: Written in TypeScript with full type definitions.
- **Bun**: Optimized for Bun runtime.

## Installation

Install directly from GitHub:

```bash
bun add github:essinghigh-org/ts-radius
```

## Usage

```typescript
import { RadiusClient, RadiusConfig } from "ts-radius-client";

const config: RadiusConfig = {
host: "10.0.0.1",
hosts: ["10.0.0.1", "10.0.0.2"], // Failover hosts
secret: "my-shared-secret",
timeoutMs: 5000,
};

const client = new RadiusClient(config);

try {
const result = await client.authenticate("username", "password");

if (result.ok) {
console.log("Authentication successful!");
if (result.class) {
console.log("Received Class attribute:", result.class);
}
} else {
console.log("Authentication failed:", result.error || "Unknown error");
}
} catch (err) {
console.error("Client error:", err);
} finally {
// Clean up timers if shutting down the app
client.shutdown();
}
```

## Configuration (`RadiusConfig`)

| Option | Type | Default | Description |
|Prefix|---|---|---|
| `host` | `string` | (Required) | Primary RADIUS host IP/hostname. |
| `hosts` | `string[]` | `[host]` | Ordered list of hosts for failover. |
| `secret` | `string` | (Required) | Shared secret. |
| `port` | `number` | `1812` | RADIUS port. |
| `timeoutMs` | `number` | `5000` | Request timeout in milliseconds. |
| `healthCheckIntervalMs` | `number` | `1800000` | (30m) Interval for background health checks. |
| `healthCheckUser` | `string` | (Required) | Username for health probes. |
| `healthCheckPassword` | `string` | (Required) | Password for health probes. |
| `assignmentAttributeId` | `number` | `25` | Attribute ID to extract (e.g., 25 for Class). |

## License

MIT
26 changes: 26 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 0 additions & 21 deletions docker-compose.yml

This file was deleted.

41 changes: 0 additions & 41 deletions docs/01-introduction/01-overview.md

This file was deleted.

Loading