mirror of
https://github.com/openfaas/faas.git
synced 2025-06-18 12:06:37 +00:00
Add error handling to basic auth injector
Fixes a problem where basic auth was disabled and a nill pointer was hit, causing a panic. Signed-off-by: Alex Ellis <alexellis2@gmail.com>
This commit is contained in:
20
gateway/handlers/basic_auth_injector.go
Normal file
20
gateway/handlers/basic_auth_injector.go
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright (c) OpenFaaS Author(s). All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/openfaas/faas-provider/auth"
|
||||
)
|
||||
|
||||
type BasicAuthInjector struct {
|
||||
Credentials *auth.BasicAuthCredentials
|
||||
}
|
||||
|
||||
func (b BasicAuthInjector) Inject(r *http.Request) {
|
||||
if r != nil && b.Credentials != nil {
|
||||
r.SetBasicAuth(b.Credentials.User, b.Credentials.Password)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user