diff options
| author | skar07 <sanskarpandey0@gmail.com> | 2022-10-03 22:10:25 +0530 |
|---|---|---|
| committer | skar07 <sanskarpandey0@gmail.com> | 2022-10-03 22:10:25 +0530 |
| commit | af0f92f80f7a348322c0a9f8258b184d2446e9d7 (patch) | |
| tree | b7c73344d0c78d1107dfd5973ac5fa1ba7833b8d /docs | |
| parent | 208b2818af5cbbe595d35b1c89847181e9c4c355 (diff) | |
| parent | 272e4bde3a043d347278ee22c3e7ffb9ec3af2f7 (diff) | |
| download | slskd-af0f92f80f7a348322c0a9f8258b184d2446e9d7.tar.gz | |
chore: merge branch after pull
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/config.md | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/docs/config.md b/docs/config.md index 82b46e63..aa09ddec 100644 --- a/docs/config.md +++ b/docs/config.md @@ -558,6 +558,18 @@ By default, a random JWT secret key is generated at each start. It is convenient The JWT TTL option determines how long issued JWTs are valid, defaulting to 7 days. +API keys can be configured to allow for secure communication without requiring the caller to obtain a JWT by signing in with a username and password. Each key must be given a name and a key with a length between 16 and 255 characters (inclusive). Callers may then supply one of the configured keys in the `X-API-Key` header when making web requests. Remember that API keys are secrets, so keep them safe. + +You can generate a random, 32 bit API key by starting the application with `-k` or `--generate-api-key` at the command line. + +An optional comma separated list of [CIDRs](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing) can be defined for each key, which will restrict usage of the key to callers with a remote IP address that falls within one of the defined CIDRs. The default CIDR list for each key is `0.0.0.0/0,::0`, which applies to any IP address (IPv4 or IPv6). + +A common use case for CIDR filtering might be to restrict API access to clients within your home network. Assuming your network uses the common `192.168.1.x` addressing, you could specify a `cidr` of `192.168.1.0/24`, which would apply to any IP between `192.168.1.1` and `192.168.1.254`, inclusive. + +Note that CIDR filtering may not work as expected behind a reverse proxy, ingress controller, or load balancer, because the remote IP address will be that of the device that's handling ingress. This application doesn't support the `X-Forwarded-For` header (or anything like it) because a bad actor can easily fake it. If you wish to use CIDR filtering in this scenario, you'll need to do it at the point of ingress to your network. + +Please also note that using API key authentication without HTTPS is **NOT RECOMMENDED**. API keys are sent in HTTP headers (and in the case of SignalR, in query parameters) and will be easily accessible to anyone eavesdropping on the network. This is a risk with JWTs as well, but JWTs expire and API keys don't. If you choose to use API keys over plain HTTP, seriously consider using CIDR filtering. + | Command-Line | Environment Variable | Description | | ---------------- | -------------------------- | --------------------------------------------------- | | `-X\|--no-auth` | `SLSKD_NO_AUTH` | Determines whether authentication is to be disabled | @@ -576,6 +588,10 @@ web: jwt: key: ~ ttl: 604800000 + api_keys: + my_api_key: + key: <some example string between 16 and 255 characters> + cidr: 0.0.0.0/0,::/0 ``` # Filters @@ -778,9 +794,10 @@ flags: The application can be run in "command mode", causing it to execute a command and quit immediately. Available commands are: -| Command | Description | -| --------------------- | --------------------------------------------------- | -| `-v\|--version` | Display the current application version | -| `-h\|--help` | Display available command-line arguments | -| `-e\|--envars` | Display available environment variables | -| `-g\|--generate-cert` | Generate an X509 certificate and password for HTTPS | +| Command | Description | +| ------------------------ | --------------------------------------------------- | +| `-v\|--version` | Display the current application version | +| `-h\|--help` | Display available command-line arguments | +| `-e\|--envars` | Display available environment variables | +| `-g\|--generate-cert` | Generate an X509 certificate and password for HTTPS | +| `-k\|--generate-api-key` | Generate a random 32 bit API key | |
