aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2025-12-13 16:11:45 -0600
committerJP Dillingham <jp@dillingham.me>2025-12-13 16:11:45 -0600
commit804f661ab5d0e3b6ffdfd6a5b38959ac1b1690be (patch)
tree9a6097f53f68b6fbe0dd1f7063fcae22be4d08ea /docs
parent9296ec4295a7d6a2371e19d38d6a32ef285eb373 (diff)
downloadslskd-804f661ab5d0e3b6ffdfd6a5b38959ac1b1690be.tar.gz
docs for API keys
Diffstat (limited to 'docs')
-rw-r--r--docs/config.md16
1 files changed, 16 insertions, 0 deletions
diff --git a/docs/config.md b/docs/config.md
index 40f186f6..6ba5bd2a 100644
--- a/docs/config.md
+++ b/docs/config.md
@@ -864,10 +864,16 @@ web:
Authentication for the web UI (and underlying API) is enabled by default, and the default username and password are both `slskd`. Changing both the username and password during the initial configuration is highly recommended.
+### JWT (Json Web Token)
+
+JWTs are used to authenticate the UI, and are generated by making an API call and supplying a username and password.
+
By default, a random JWT secret key is generated at each start. It is convenient and secure, but restarting the application will invalidate any issued JWTs, causing users to sign in again. To avoid this, supply a custom secret at least 16 characters in length. Note that the secret can be used to generate valid JWTs for the application, so keep this value secret.
The JWT TTL option determines how long issued JWTs are valid, defaulting to 7 days.
+### API Keys
+
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 `--generate-secret` at the command line.
@@ -876,6 +882,15 @@ An optional comma separated list of [CIDRs](https://en.wikipedia.org/wiki/Classl
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.
+An optional 'primary' API key can be configured by passiing it via `-k` or `--api-key` on the command line, or by setting the `SLSKD_API_KEY` environment variable. As with other API keys, a role and list of CIDRs can be supplied, but because the command line and environment variables are limited to a simple string, the role and CIDRs must be passed via tuples separated by semicolons:
+
+```
+role=ReadOnly;cidr=0.0.0.0/0,::/0;<16 to 255 character string>
+```
+
+By default, the role associated with the 'primary' API key is `Administrator` (other API keys default to `ReadOnly`) and list of CIDRs is `0.0.0.0/0,::0` (same as other API keys).
+
+#### Cautions
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.
@@ -885,6 +900,7 @@ Please also note that using API key authentication without HTTPS is **NOT RECOMM
| `-X\|--no-auth` | `SLSKD_NO_AUTH` | Determines whether authentication is to be disabled |
| `-u\|--username` | `SLSKD_USERNAME` | The username for the web UI |
| `-p\|--password` | `SLSKD_PASSWORD` | The password for the web UI |
+| `-k\|--api-key` | `SLSKD_API_KEY` | The primary API key |
| `--jwt-key` | `SLSKD_JWT_KEY` | The secret key used to sign JWTs |
| `--jwt-ttl` | `SLSKD_JWT_TTL` | The TTL (duration) of JWTs, in milliseconds |