Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

631/proxy-authentication #632

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ SERVER_BENCHMARKING = false
# SERVER PROXY CONFIG
SERVER_PROXY_HOST =
SERVER_PROXY_PORT =
SERVER_PROXY_USERNAME =
SERVER_PROXY_PASSWORD =
SERVER_PROXY_TIMEOUT = 5000

# SERVER RATE LIMITING CONFIG
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 4.0.3

_New Features:_

- Added proxy authentication [(#631)](https://github.com/highcharts/node-export-server/issues/631).

# 4.0.2

_Hotfix_:
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ The format, along with its default values, is as follows (using the recommended
"proxy": {
"host": "",
"port": 8080,
"username": false,
"password": false,
"timeout": 5000
},
"rateLimiting": {
Expand Down Expand Up @@ -321,6 +323,8 @@ These variables are set in your environment and take precedence over options fro

- `SERVER_PROXY_HOST`: The host of the proxy server to use, if it exists (defaults to ``).
- `SERVER_PROXY_PORT`: The port of the proxy server to use, if it exists (defaults to ``).
- `SERVER_PROXY_USERNAME`: If used proxy with authentication, need to pass username and password (defaults to ``).
- `SERVER_PROXY_PASSWORD`: If used proxy with authentication, need to pass username and password (defaults to ``).
- `SERVER_PROXY_TIMEOUT`: The timeout for the proxy server to use, if it exists (defaults to ``).

### Server Rate Limiting Config
Expand Down Expand Up @@ -416,6 +420,8 @@ _Available options:_
- `--serverBenchmarking`: Indicates whether to display the duration, in milliseconds, of specific actions that occur on the server while serving a request (defaults to `false`).
- `--proxyHost`: The host of the proxy server to use, if it exists (defaults to `false`).
- `--proxyPort`: The port of the proxy server to use, if it exists (defaults to `false`).
- `--proxyUsername`: If you want your proxy to be authenticated, pass the username with password (defaults to `false`).
- `--proxyPassword`: If you want your proxy to be authenticated, pass the username with password (defaults to `false`).
- `--proxyTimeout`: The timeout for the proxy server to use, if it exists (defaults to `5000`).
- `--enableRateLimiting`: Enables rate limiting for the server (defaults to `false`).
- `--maxRequests`: The maximum number of requests allowed in one minute (defaults to `10`).
Expand Down
2 changes: 0 additions & 2 deletions dist/index.cjs

This file was deleted.

2 changes: 0 additions & 2 deletions dist/index.esm.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/index.esm.js.map

This file was deleted.

10 changes: 5 additions & 5 deletions lib/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,15 @@ export const fetchScripts = async (
) => {
// Configure proxy if exists
let proxyAgent;
const proxyHost = proxyOptions.host;
const proxyPort = proxyOptions.port;
const { host, port, username, password } = proxyOptions;

// Try to create a Proxy Agent
if (proxyHost && proxyPort) {
if (host && port) {
try {
proxyAgent = new HttpsProxyAgent({
host: proxyHost,
port: proxyPort
host,
port,
...(username && password ? { username, password } : {})
});
} catch (error) {
throw new ExportError('[cache] Could not create a Proxy Agent.').setError(
Expand Down
2 changes: 2 additions & 0 deletions lib/envs.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ export const Config = z.object({
// server proxy
SERVER_PROXY_HOST: v.string(),
SERVER_PROXY_PORT: v.positiveNum(),
SERVER_PROXY_USERNAME: v.string(),
SERVER_PROXY_PASSWORD: v.string(),
SERVER_PROXY_TIMEOUT: v.nonNegativeNum(),

// server rate limiting
Expand Down
6 changes: 1 addition & 5 deletions lib/highcharts.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,7 @@ export async function triggerExport(chartOptions, options, displayErrors) {
let constr = options.export.constr || 'chart';
constr = typeof Highcharts[constr] !== 'undefined' ? constr : 'chart';

Highcharts[constr](
'container',
finalOptions,
finalCallback
);
Highcharts[constr]('container', finalOptions, finalCallback);

// Get the current global options
const defaultOptions = getOptions();
Expand Down
14 changes: 14 additions & 0 deletions lib/schemas/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,20 @@ export const defaultConfig = {
cliName: 'proxyPort',
description: 'The port of the proxy server to use, if it exists.'
},
username: {
value: false,
type: 'string',
envLink: 'SERVER_PROXY_USERNAME',
cliName: 'proxyUsername',
description: 'The username for the proxy server, if it exists.'
},
password: {
value: false,
type: 'string',
envLink: 'SERVER_PROXY_PASSWORD',
cliName: 'proxyPassword',
description: 'The password for the proxy server, if it exists.'
},
timeout: {
value: 5000,
type: 'number',
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"author": "Highsoft AS <[email protected]> (http://www.highcharts.com/about)",
"license": "MIT",
"type": "module",
"version": "4.0.2",
"version": "4.0.3",
"main": "./dist/index.esm.js",
"engines": {
"node": ">=18.12.0"
Expand Down
Loading