Skip to content

Commit 6e5cd2f

Browse files
committed
docs: explain how to decrease JWT length in Keycloak
this prevents errors when passing JWT with FFmpeg and GStreamer.
1 parent 400af1a commit 6e5cd2f

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

docs/2-usage/5-authentication.md

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -148,48 +148,54 @@ The JWT is expected to contain a claim, with a list of permissions in the same f
148148

149149
#### Keycloak setup
150150

151-
Here's a tutorial on how to setup the [Keycloak identity server](https://www.keycloak.org/) in order to provide JWTs:
151+
Here's a tutorial on how to setup the [Keycloak identity server](https://www.keycloak.org/) in order to provide JWTs.
152152

153153
1. Start Keycloak:
154154

155+
```sh
156+
docker run --name=keycloak -p 8080:8080 \
157+
-e KEYCLOAK_ADMIN=admin -e KEYCLOAK_ADMIN_PASSWORD=admin \
158+
quay.io/keycloak/keycloak:23.0.7 start-dev
155159
```
156-
docker run --name=keycloak -p 8080:8080 -e KEYCLOAK_ADMIN=admin -e KEYCLOAK_ADMIN_PASSWORD=admin quay.io/keycloak/keycloak:23.0.7 start-dev
157-
```
158160

159-
2. Open the Keycloak administration console on http://localhost:8080, click on _master_ in the top left corner, _create realm_, set realm name to `mediamtx`, Save
161+
2. Open the Keycloak web UI on http://localhost:8080, click on _Administration Console_ and log in.
162+
163+
3. Click on _master_ in the top left corner, _Create realm_, set realm name to `mediamtx`, _Create_.
160164

161-
3. Open page _Client scopes_, _create client scope_, set name to `mediamtx`, Save
165+
4. Open page _Client scopes_, _Create client scope_, set name to `mediamtx`, _Save_.
162166

163-
4. Open tab _Mappers_, _Configure a new Mapper_, _User Attribute_
167+
5. Open tab _Mappers_, _Configure a new Mapper_, _User Attribute_:
164168
- Name: `mediamtx_permissions`
165169
- User Attribute: `mediamtx_permissions`
166170
- Token Claim Name: `mediamtx_permissions`
167171
- Claim JSON Type: `JSON`
168172
- Multivalued: `On`
169173

170-
Save
174+
Save.
175+
176+
6. Open page _Clients_, _Create client_, set Client ID to `mediamtx`, _Next_, _Client authentication_ `On`, _Next_, _Save_.
171177

172-
5. Open page _Clients_, _Create client_, set Client ID to `mediamtx`, Next, Client authentication `On`, Next, Save
178+
7. Open tab _Credentials_, copy client secret somewhere.
173179

174-
6. Open tab _Credentials_, copy client secret somewhere
180+
8. Open tab _Client scopes_, set _Assigned type_ of all existing client scopes to _Optional_. This decreases the length of the JWT, since many clients impose limits on it.
175181

176-
7. Open tab _Client scopes_, _Add client scope_, Select `mediamtx`, Add, Default
182+
9. In tab _Client scopes_, _Add client scope_, Select `mediamtx`, _Add_, _Default_.
177183

178-
8. Open page _Users_, _Add user_, Username `testuser`, Tab credentials, _Set password_, pick a password, Save
184+
10. Open page _Users_, _Add user_, Username `testuser`, _Create_, Tab _Credentials_, _Set password_, pick a password, _Save_.
179185

180-
9. Open tab _Attributes_, _Add an attribute_
181-
- Key: `mediamtx_permissions`
182-
- Value: `{"action":"publish", "path": ""}`
186+
11. Open tab _Attributes_, _Add an attribute_:
187+
- Key: `mediamtx_permissions`
188+
- Value: `{"action":"publish", "path": ""}`
183189

184-
You can add as many attributes with key `mediamtx_permissions` as you want, each with a single permission in it
190+
You can add as many attributes with key `mediamtx_permissions` as you want, each with a single permission in it.
185191

186-
10. In MediaMTX, use the following URL:
192+
12. In MediaMTX, use the following JWKS URL:
187193

188194
```yml
189195
authJWTJWKS: http://localhost:8080/realms/mediamtx/protocol/openid-connect/certs
190196
```
191197

192-
11. Perform authentication on Keycloak:
198+
13. Perform authentication on Keycloak:
193199

194200
```
195201
curl \

0 commit comments

Comments
 (0)