mirror of
https://github.com/owncast/owncast.git
synced 2024-11-27 08:00:16 +03:00
fix(api): validate stream key payload. Closes #3082
This commit is contained in:
parent
26686dd6da
commit
9b44ff107f
2 changed files with 24 additions and 0 deletions
|
@ -850,6 +850,18 @@ func SetStreamKeys(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
if len(streamKeys.Value) == 0 {
|
||||
controllers.WriteSimpleResponse(w, false, "must provide at least one valid stream key")
|
||||
return
|
||||
}
|
||||
|
||||
for _, streamKey := range streamKeys.Value {
|
||||
if streamKey.Key == "" {
|
||||
controllers.WriteSimpleResponse(w, false, "stream key cannot be empty")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if err := data.SetStreamKeys(streamKeys.Value); err != nil {
|
||||
controllers.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
|
|
|
@ -187,6 +187,18 @@ test('verify default admin configuration', async (done) => {
|
|||
done();
|
||||
});
|
||||
|
||||
test('verify stream key validation', async (done) => {
|
||||
const badPayload = { id: 'zz', comment: 'ouch' };
|
||||
const url = '/api/admin/config/streamkeys';
|
||||
const res = await request
|
||||
.post(url)
|
||||
.auth('admin', defaultAdminPassword)
|
||||
.send(badPayload)
|
||||
.expect(400);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
test('set server name', async (done) => {
|
||||
const res = await sendAdminRequest('config/name', newServerName);
|
||||
done();
|
||||
|
|
Loading…
Reference in a new issue