Skip to content

Commit 298c71b

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 298c71b

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

docs/2-usage/5-authentication.md

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -148,48 +148,52 @@ 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

155155
```
156156
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
157157
```
158158

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
159+
2. Open the Keycloak web UI on http://localhost:8080, click on _Administration Console_ and log in.
160160

161-
3. Open page _Client scopes_, _create client scope_, set name to `mediamtx`, Save
161+
3. Click on _master_ in the top left corner, _Create realm_, set realm name to `mediamtx`, _Create_.
162162

163-
4. Open tab _Mappers_, _Configure a new Mapper_, _User Attribute_
163+
4. Open page _Client scopes_, _Create client scope_, set name to `mediamtx`, _Save_.
164+
165+
5. Open tab _Mappers_, _Configure a new Mapper_, _User Attribute_:
164166
- Name: `mediamtx_permissions`
165167
- User Attribute: `mediamtx_permissions`
166168
- Token Claim Name: `mediamtx_permissions`
167169
- Claim JSON Type: `JSON`
168170
- Multivalued: `On`
169171

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

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

174-
6. Open tab _Credentials_, copy client secret somewhere
178+
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.
175179

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

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

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

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

186-
10. In MediaMTX, use the following URL:
190+
12. In MediaMTX, use the following JWKS URL:
187191

188192
```yml
189193
authJWTJWKS: http://localhost:8080/realms/mediamtx/protocol/openid-connect/certs
190194
```
191195

192-
11. Perform authentication on Keycloak:
196+
13. Perform authentication on Keycloak:
193197

194198
```
195199
curl \

0 commit comments

Comments
 (0)