Add Watch api and UI integration (#120)

Uses a similar approach as Trace and Console Logs by using
websockets. It also includes the integration with the UI which
needs 3 input fields that are sent as query parameters.
This commit is contained in:
César Nieto
2020-05-15 14:24:29 -07:00
committed by GitHub
parent acf480fd25
commit 6fef30f29d
23 changed files with 1169 additions and 236 deletions

View File

@@ -22,13 +22,14 @@ import (
"strings"
"github.com/go-openapi/errors"
"github.com/minio/mcs/pkg/auth"
"github.com/go-openapi/swag"
)
// Authenticate validates websocket header and returns mcs jwt claims
// GetTokenFromRequest returns a token from a http Request
// either defined on a cookie `token` or on Authorization header.
//
// Authorization Header needs to be like "Authorization Bearer <jwt_token>"
func Authenticate(r *http.Request) (*auth.DecryptedClaims, error) {
func GetTokenFromRequest(r *http.Request) (*string, error) {
// Get Auth token
var reqToken string
@@ -46,11 +47,5 @@ func Authenticate(r *http.Request) (*auth.DecryptedClaims, error) {
} else {
reqToken = strings.TrimSpace(tokenCookie.Value)
}
// Perform authentication before upgrading to a Websocket Connection
claims, err := auth.JWTAuthenticate(reqToken)
if err != nil {
return nil, errors.New(http.StatusUnauthorized, err.Error())
}
return claims, nil
return swag.String(reqToken), nil
}