Fix authorization (real)
parent
57a75ef495
commit
681cb1ca4f
|
@ -1 +1,2 @@
|
||||||
/streams.db
|
/streams.db
|
||||||
|
/wish-server
|
||||||
|
|
|
@ -133,10 +133,13 @@ func HandleWHIP(res http.ResponseWriter, req *http.Request) {
|
||||||
logHTTPError(res, "Authorization was not set", http.StatusBadRequest)
|
logHTTPError(res, "Authorization was not set", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
streamName, streamPassword, _ := strings.Cut(authorization, ":")
|
streamName, streamPassword, _ := strings.Cut(authorization, ":")
|
||||||
if err := db.QueryRow("SELECT * FROM streams WHERE stream = ? AND password = ?", streamName, streamPassword).Scan(); err != nil {
|
streamName, _ = strings.CutPrefix(strings.ToLower(streamName), "Bearer ")
|
||||||
logHTTPError(res, "Invalid stream authorization", http.StatusUnauthorized)
|
|
||||||
|
var qN string
|
||||||
|
var qP string
|
||||||
|
if err := db.QueryRow("SELECT * FROM streams WHERE stream = ? AND password = ?", streamName, streamPassword).Scan(&qN, &qP); err != nil {
|
||||||
|
logHTTPError(res, "Invalid stream authorization for: "+streamName+" - "+err.Error(), http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue