Fix verifying token for RTMP requests
This commit is contained in:
parent
bc8d1cc112
commit
5dc8fc5ff1
@ -1,7 +1,6 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
@ -71,8 +70,8 @@ func (rtmph *RTMPHandler) Play(c echo.Context) error {
|
|||||||
|
|
||||||
r, err := rtmph.rtmp.PlayFLV(addr, u)
|
r, err := rtmph.rtmp.PlayFLV(addr, u)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
var rtmperr rtmp.PlayError
|
rtmperr, ok := err.(*rtmp.PlayError)
|
||||||
if errors.As(err, &rtmperr) {
|
if ok {
|
||||||
status := http.StatusInternalServerError
|
status := http.StatusInternalServerError
|
||||||
switch rtmperr.Message {
|
switch rtmperr.Message {
|
||||||
case "FORBIDDEN":
|
case "FORBIDDEN":
|
||||||
|
|||||||
@ -250,7 +250,7 @@ func (s *server) play(remote net.Addr, u *url.URL) (*channel, string, string, er
|
|||||||
resource := playpath
|
resource := playpath
|
||||||
|
|
||||||
if !s.iam.Enforce(identity, domain, "rtmp", resource, "PLAY") {
|
if !s.iam.Enforce(identity, domain, "rtmp", resource, "PLAY") {
|
||||||
return nil, identity, playpath, &PlayError{"FORBIDDEN", "", playpath, "access denies", nil}
|
return nil, identity, playpath, &PlayError{"FORBIDDEN", "", playpath, "access denied", nil}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Look for the stream
|
// Look for the stream
|
||||||
@ -512,6 +512,8 @@ func (s *server) findIdentityFromStreamKey(key string) (string, error) {
|
|||||||
if ok, err := identity.VerifyServiceToken(token); !ok {
|
if ok, err := identity.VerifyServiceToken(token); !ok {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("invalid token: %w", err)
|
err = fmt.Errorf("invalid token: %w", err)
|
||||||
|
} else {
|
||||||
|
err = fmt.Errorf("invlid token")
|
||||||
}
|
}
|
||||||
|
|
||||||
if isDefaultIdentity {
|
if isDefaultIdentity {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user