18 Commits
v0.2.1 ... main

Author SHA1 Message Date
fcb9daa30c chore(changelog): update changelog for v0.5.0
All checks were successful
Build and upload Docker release image / upload-assets (release) Successful in 2m58s
2025-05-11 14:10:38 +00:00
36a1b08052 chore(version): bump version to 0.5.0
All checks were successful
Auto Changelog & Release / detect-version-change (push) Successful in 5s
Auto Changelog & Release / changelog-only (push) Has been skipped
Auto Changelog & Release / release (push) Successful in 10s
Build and upload Docker nightly image / build-and-push (push) Successful in 2m55s
2025-05-11 16:10:21 +02:00
9d902dce55 docs: update LanguageTool backend port in README
- Change the default `LT_SERVER_PORT` from 8010 to 8081 in usage examples
- Reflect the updated port in the environment variables table
2025-05-11 16:10:20 +02:00
f15cfec74f feat(env): update default LanguageTool server port to 8081 2025-05-11 16:10:20 +02:00
8106f5b1a1 chore(changelog): update unreleased changelog 2025-05-11 14:09:16 +00:00
427cee1884 docs(readme): update service configuration and license link
All checks were successful
Auto Changelog & Release / detect-version-change (push) Successful in 5s
Auto Changelog & Release / release (push) Has been skipped
Auto Changelog & Release / changelog-only (push) Successful in 9s
Build and upload Docker nightly image / build-and-push (push) Successful in 1m20s
- Switch language tool server image and add restart policy
- Update user, network, and API key configurations
- Adjust port for language tool server
- Add note about SSL encryption requirement
- Update license section with link to LICENSE file
- Add a horizontal rule for improved visual separation
- Include project link at the end for easier navigation
2025-05-11 16:08:57 +02:00
92b075df55 docs(readme): update service configuration and license link
Some checks failed
Auto Changelog & Release / detect-version-change (push) Has been cancelled
Build and upload Docker nightly image / build-and-push (push) Has been cancelled
Auto Changelog & Release / changelog-only (push) Has been cancelled
Auto Changelog & Release / release (push) Has been cancelled
- Switch language tool server image and add restart policy
- Update user, network, and API key configurations
- Adjust port for language tool server
- Add note about SSL encryption requirement
- Update license section with link to LICENSE file
2025-05-11 16:07:54 +02:00
a7035a6bac chore(changelog): update unreleased changelog 2025-05-11 10:33:18 +00:00
5597c2ae3f docs(readme): add project time badge
All checks were successful
Auto Changelog & Release / detect-version-change (push) Successful in 5s
Auto Changelog & Release / release (push) Has been skipped
Auto Changelog & Release / changelog-only (push) Successful in 9s
Build and upload Docker nightly image / build-and-push (push) Successful in 1m16s
- Add a badge displaying daily project time to the README
2025-05-11 12:33:02 +02:00
9e1fefaa2f chore(changelog): update changelog for v0.4.0
All checks were successful
Build and upload Docker release image / upload-assets (release) Successful in 2m53s
2025-05-11 10:24:19 +00:00
a79eb29dab chore(version): bump to 0.4.0
All checks were successful
Auto Changelog & Release / detect-version-change (push) Successful in 4s
Auto Changelog & Release / changelog-only (push) Has been skipped
Auto Changelog & Release / release (push) Successful in 10s
Build and upload Docker nightly image / build-and-push (push) Successful in 2m48s
2025-05-11 12:24:01 +02:00
5f28d5ca7a chore(changelog): update unreleased changelog 2025-05-11 10:23:58 +00:00
d57cc27e19 feat(server): add graceful shutdown handling
Some checks failed
Auto Changelog & Release / detect-version-change (push) Successful in 4s
Auto Changelog & Release / changelog-only (push) Successful in 8s
Auto Changelog & Release / release (push) Has been skipped
Build and upload Docker nightly image / build-and-push (push) Has been cancelled
- Introduce signal listeners for SIGINT and SIGTERM to handle shutdown
- Use AbortController to terminate the server gracefully
- Improve server reliability and resource cleanup during termination
2025-05-11 12:23:38 +02:00
05fcd4b0f8 chore(changelog): update changelog for v0.3.0
All checks were successful
Build and upload Docker release image / upload-assets (release) Successful in 2m44s
2025-05-11 09:17:10 +00:00
f7b55bb26c chore(version): bump to 0.3.0
All checks were successful
Auto Changelog & Release / detect-version-change (push) Successful in 5s
Auto Changelog & Release / changelog-only (push) Has been skipped
Auto Changelog & Release / release (push) Successful in 11s
Build and upload Docker nightly image / build-and-push (push) Successful in 2m45s
2025-05-11 11:16:53 +02:00
0d26bf4cf8 chore(changelog): update unreleased changelog 2025-05-11 09:16:38 +00:00
3299419726 feat(logging): add debug logs for key validation and request handling
Some checks failed
Auto Changelog & Release / detect-version-change (push) Successful in 5s
Auto Changelog & Release / release (push) Has been skipped
Auto Changelog & Release / changelog-only (push) Successful in 8s
Build and upload Docker nightly image / build-and-push (push) Has been cancelled
- Add debug logs for invalid and valid API key masking
- Log unsupported content types in middleware
- Log forwarded request URLs and response statuses from LT server
2025-05-11 11:16:22 +02:00
79dfbcf053 feat(utils): add utility to mask API keys
- Introduces a function to mask API keys for improved security
- Masks null or short keys entirely with asterisks
- Partially masks longer keys, retaining the first five characters
2025-05-11 11:16:11 +02:00
8 changed files with 71 additions and 11 deletions

View File

@@ -2,6 +2,32 @@
All notable changes to this project will be documented in this file.
## [0.5.0](https://git.0xmax42.io/maxp/lt-auth-proxy/compare/v0.4.0..v0.5.0) - 2025-05-11
### 🚀 Features
- *(env)* Update default LanguageTool server port to 8081 - ([f15cfec](https://git.0xmax42.io/maxp/lt-auth-proxy/commit/f15cfec74f9fb8325e90c7acc40ff7a166b9f9df))
### 📚 Documentation
- Update LanguageTool backend port in README - ([9d902dc](https://git.0xmax42.io/maxp/lt-auth-proxy/commit/9d902dce55f12d274d3b9bd75cc3d3b0f75384c6))
- *(readme)* Update service configuration and license link - ([427cee1](https://git.0xmax42.io/maxp/lt-auth-proxy/commit/427cee188404b00ec30c8f52f4a66c4609511a8f))
- *(readme)* Update service configuration and license link - ([92b075d](https://git.0xmax42.io/maxp/lt-auth-proxy/commit/92b075df558d2d52da9496f74f84c149d3b18df5))
- *(readme)* Add project time badge - ([5597c2a](https://git.0xmax42.io/maxp/lt-auth-proxy/commit/5597c2ae3fa3920340499e0b5924b75352591729))
## [0.4.0](https://git.0xmax42.io/maxp/lt-auth-proxy/compare/v0.3.0..v0.4.0) - 2025-05-11
### 🚀 Features
- *(server)* Add graceful shutdown handling - ([d57cc27](https://git.0xmax42.io/maxp/lt-auth-proxy/commit/d57cc27e19e68c13ac08af223c3721a9c45fafd1))
## [0.3.0](https://git.0xmax42.io/maxp/lt-auth-proxy/compare/v0.2.1..v0.3.0) - 2025-05-11
### 🚀 Features
- *(logging)* Add debug logs for key validation and request handling - ([3299419](https://git.0xmax42.io/maxp/lt-auth-proxy/commit/32994197261e9ab5a46df5f90f2faed89cd68558))
- *(utils)* Add utility to mask API keys - ([79dfbcf](https://git.0xmax42.io/maxp/lt-auth-proxy/commit/79dfbcf053d613fe3fff63bfd24537a1665c9389))
## [0.2.1](https://git.0xmax42.io/maxp/lt-auth-proxy/compare/v0.1.1..v0.2.1) - 2025-05-11
### 🚀 Features

View File

@@ -1,5 +1,7 @@
# lt-auth-proxy
![Project Time](https://waka.0xmax42.io/api/badge/0XMax42/interval:today/project:lt-auth-proxy?label=Project%20Time)
A lightweight, production-ready reverse proxy for [LanguageTool](https://languagetool.org) with API key authentication.
This service acts as a transparent gateway that verifies an `apiKey` before forwarding requests to a running LanguageTool server instance. It is fully self-contained, built in Deno, and distributed as a minimal multi-architecture Docker image.
@@ -25,7 +27,7 @@ You can run the proxy via Docker:
docker run -p 8011:8011 \
-e API_KEYS="demo-key,another-key" \
-e LT_SERVER_HOST=lt-server \
-e LT_SERVER_PORT=8010 \
-e LT_SERVER_PORT=8081 \
git.0xmax42.io/simdev/lt-auth-proxy:latest
```
@@ -39,7 +41,7 @@ docker run -p 8011:8011 \
| `PROXY_HOST` | ❌ no | `0.0.0.0` | Host/IP address to bind the proxy to |
| `PROXY_PORT` | ❌ no | `8011` | Port the proxy listens on |
| `LT_SERVER_HOST` | ❌ no | `localhost` | Hostname of the LanguageTool backend |
| `LT_SERVER_PORT` | ❌ no | `8010` | Port of the LanguageTool backend |
| `LT_SERVER_PORT` | ❌ no | `8081` | Port of the LanguageTool backend |
---
@@ -60,23 +62,30 @@ src/
```yaml
services:
lt-server:
image: languagetool/languagetool:latest
ports:
- "8010:8010"
image: meyay/languagetool:latest
restart: unless-stopped
user: "783:783"
networks:
- default
proxy:
image: git.0xmax42.io/maxp/lt-auth-proxy:latest
ports:
- "8011:8011"
environment:
- API_KEYS=demo-key
- API_KEYS=demo-key,another-key
- LT_SERVER_HOST=lt-server
- LT_SERVER_PORT=8010
- LT_SERVER_PORT=8081
```
Please note that this setup does not include SSL encryption. A reverse proxy such as Traefik should be used for this.
---
## 📖 License
MIT © 0xMax42
[MIT © 0xMax42](./LICENSE)
---
[https://git.0xmax42.io/maxp/lt-auth-proxy](https://git.0xmax42.io/maxp/lt-auth-proxy)

View File

@@ -1 +1 @@
0.2.1
0.5.0

View File

@@ -53,10 +53,10 @@ export class Env {
return this._ltServerHost;
}
/** Port of the LanguageTool backend (default: 8010) */
/** Port of the LanguageTool backend (default: 8081) */
static get ltServerPort(): number {
if (this._ltServerPort === undefined) {
this._ltServerPort = Number(this.getEnv('LT_SERVER_PORT') || 8010);
this._ltServerPort = Number(this.getEnv('LT_SERVER_PORT') || 8081);
}
return this._ltServerPort;
}

View File

@@ -1,5 +1,6 @@
import { Middleware } from 'http-kernel/Types/mod.ts';
import { Env } from './env.ts';
import { maskApiKey } from './utils.ts';
/**
* Middleware that checks for a valid API key via form param.
@@ -17,12 +18,15 @@ export const authMiddleware: Middleware = async (ctx, next) => {
const key = params.get('apiKey');
if (!key || !Env.apiKeys.includes(key)) {
console.debug('Invalid API key:', maskApiKey(key));
return new Response('Forbidden – Invalid API key', { status: 403 });
}
} else {
console.debug('Unsupported content type:', contentType);
return new Response('Unsupported content type', { status: 415 });
}
console.debug('Valid API key:', maskApiKey(ctx.req.headers.get('apiKey')));
return await next();
};

View File

@@ -37,12 +37,16 @@ export const handler: Handler = async (ctx) => {
const headers = new Headers(ctx.req.headers);
headers.delete('content-length');
console.debug('Forwarding request to:', proxyUrl.toString());
const forwarded = await fetch(proxyUrl.toString(), {
method: ctx.req.method,
headers,
body,
});
console.debug('Received response from LT server:', forwarded.status);
const respHeaders = new Headers(forwarded.headers);
return new Response(forwarded.body, {
status: forwarded.status,

View File

@@ -3,6 +3,7 @@ import { Env } from './env.ts';
import { ltProxyAuth } from './ltProxyAuth.ts';
import { ltProxyHandler } from './ltProxyHandler.ts';
const ac = new AbortController();
const httpKernel = new HttpKernel();
httpKernel.route({
@@ -11,9 +12,19 @@ httpKernel.route({
}).middleware(ltProxyAuth).handle(ltProxyHandler);
Deno.serve({
signal: ac.signal,
port: Env.proxyPort,
hostname: Env.proxyHost,
onListen: ({ hostname, port }) => {
console.info(`lt-auth-proxy listening on ${hostname}:${port}`);
},
}, async (req) => await httpKernel.handle(req));
const shutdown = () => {
console.info('Shutting down the server...');
ac.abort();
console.info('Server shut down successfully.');
};
Deno.addSignalListener('SIGINT', shutdown);
Deno.addSignalListener('SIGTERM', shutdown);

6
src/utils.ts Normal file
View File

@@ -0,0 +1,6 @@
export const maskApiKey = (key: string | null): string => {
if (!key) return '*****';
return key.length <= 5
? '*'.repeat(key.length)
: key.slice(0, 5) + '*'.repeat(key.length - 5);
};