fix: change to repository event types and removed unused code (#3386)

* fix: change to repository event types and removed unused code

* some fixes

* remove unused code
This commit is contained in:
Livio Amstutz
2022-03-31 11:36:26 +02:00
committed by GitHub
parent 55af4a18a2
commit 87560157c1
170 changed files with 999 additions and 9581 deletions

View File

@@ -51,9 +51,9 @@ func setInstance(r *http.Request, verifier authz.InstanceVerifier, headerName st
authCtx, span := tracing.NewServerInterceptorSpan(ctx)
defer func() { span.EndWithError(err) }()
host := r.Header.Get(headerName)
if host == "" {
return nil, fmt.Errorf("host header %s not found", headerName)
host, err := getHost(r, headerName)
if err != nil {
return nil, err
}
instance, err := verifier.InstanceByHost(authCtx, host)
@@ -63,3 +63,14 @@ func setInstance(r *http.Request, verifier authz.InstanceVerifier, headerName st
span.End()
return authz.WithInstance(ctx, instance), nil
}
func getHost(r *http.Request, headerName string) (string, error) {
host := r.Host
if headerName != "host" {
host = r.Header.Get(headerName)
}
if host == "" {
return "", fmt.Errorf("host header `%s` not found", headerName)
}
return host, nil
}