Support streaming via API key (#1279)

* Support api key via url query parameter
* Add api key to stream URL
This commit is contained in:
WithoutPants
2021-04-12 11:05:49 +10:00
committed by GitHub
parent f6ffda7504
commit f5dc654f6b
4 changed files with 19 additions and 2 deletions

View File

@@ -37,7 +37,10 @@ var uiBox *packr.Box
//var legacyUiBox *packr.Box
var loginUIBox *packr.Box
const ApiKeyHeader = "ApiKey"
const (
ApiKeyHeader = "ApiKey"
ApiKeyParameter = "apikey"
)
func allowUnauthenticated(r *http.Request) bool {
return strings.HasPrefix(r.URL.Path, "/login") || r.URL.Path == "/css"
@@ -54,6 +57,11 @@ func authenticateHandler() func(http.Handler) http.Handler {
apiKey := r.Header.Get(ApiKeyHeader)
var err error
// try getting the api key as a query parameter
if apiKey == "" {
apiKey = r.URL.Query().Get(ApiKeyParameter)
}
if apiKey != "" {
// match against configured API and set userID to the
// configured username. In future, we'll want to