mirror of
https://github.com/openfaas/faas.git
synced 2025-06-18 20:16: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:
@ -89,7 +89,11 @@ func main() {
|
||||
functionURLTransformer = nilURLTransformer
|
||||
}
|
||||
|
||||
serviceAuthInjector := &BasicAuthInjector{Credentials: credentials}
|
||||
var serviceAuthInjector handlers.AuthInjector
|
||||
|
||||
if config.UseBasicAuth {
|
||||
serviceAuthInjector = &handlers.BasicAuthInjector{Credentials: credentials}
|
||||
}
|
||||
|
||||
decorateExternalAuth := handlers.MakeExternalAuthHandler
|
||||
|
||||
@ -257,11 +261,3 @@ func runMetricsServer() {
|
||||
|
||||
log.Fatal(s.ListenAndServe())
|
||||
}
|
||||
|
||||
type BasicAuthInjector struct {
|
||||
Credentials *auth.BasicAuthCredentials
|
||||
}
|
||||
|
||||
func (b BasicAuthInjector) Inject(r *http.Request) {
|
||||
r.SetBasicAuth(b.Credentials.User, b.Credentials.Password)
|
||||
}
|
||||
|
Reference in New Issue
Block a user