support access token via query params
This commit is contained in:
@@ -90,7 +90,7 @@ func joinRoom(c *cli.Context) error {
|
||||
} else {
|
||||
// dev mode, will pass these as overrides
|
||||
v := url.Values{}
|
||||
v.Set("room_id", roomId)
|
||||
v.Set("room", roomId)
|
||||
v.Set("name", name)
|
||||
u.RawQuery = v.Encode()
|
||||
}
|
||||
|
||||
+9
-1
@@ -15,6 +15,7 @@ const (
|
||||
authorizationHeader = "Authorization"
|
||||
bearerPrefix = "Bearer "
|
||||
grantsKey = "grants"
|
||||
accessTokenParam = "access_token"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -35,6 +36,7 @@ func NewAPIKeyAuthMiddleware(provider auth.KeyProvider) *APIKeyAuthMiddleware {
|
||||
|
||||
func (m *APIKeyAuthMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
|
||||
authHeader := r.Header.Get(authorizationHeader)
|
||||
var authToken string
|
||||
|
||||
if authHeader != "" {
|
||||
if !strings.HasPrefix(authHeader, bearerPrefix) {
|
||||
@@ -43,7 +45,13 @@ func (m *APIKeyAuthMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request,
|
||||
return
|
||||
}
|
||||
|
||||
authToken := authHeader[len(bearerPrefix):]
|
||||
authToken = authHeader[len(bearerPrefix):]
|
||||
} else {
|
||||
// attempt to find from request header
|
||||
authToken = r.FormValue(accessTokenParam)
|
||||
}
|
||||
|
||||
if authToken != "" {
|
||||
v, err := auth.ParseAPIToken(authToken)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ func NewRTCService(conf *config.Config, manager *rtc.RoomManager) *RTCService {
|
||||
}
|
||||
|
||||
func (s *RTCService) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
roomId := r.FormValue("room_id")
|
||||
roomId := r.FormValue("room")
|
||||
var pName string
|
||||
if s.isDev {
|
||||
r.FormValue("name")
|
||||
|
||||
Reference in New Issue
Block a user