Repository: go-openapi/runtime (go)

Issue:
Runtime Client: panic when enable OpenTracing with no AuthInfo
If create runtime.ClientTransport and enable OpenTracing via `client.New(host, path, schemes).WithOpenTracing()` can cause panic if AuthInfo is nil.

I found this issue when create client with go-swagger and add custom ClientTransport with WithOpenTracing() option.

related PR: #190 

### stack trace
```
runtime error: invalid memory address or nil pointer dereference","stacktrace":"service-a/restapi/middlewares.PanicRecovery.func1.1
	/app/restapi/middlewares/recovery.go:19
runtime.gopanic
	/usr/local/go/src/runtime/panic.go:965
runtime.panicmem
	/usr/local/go/src/runtime/panic.go:212
runtime.sigpanic
	/usr/local/go/src/runtime/signal_unix.go:734
github.com/go-openapi/runtime/client.(*tracingTransport).Submit.func2
	/app/vendor/github.com/go-openapi/runtime/client/opentracing.go:44
github.com/go-openapi/runtime.ClientAuthInfoWriterFunc.AuthenticateRequest
	/app/vendor/github.com/go-openapi/runtime/client_auth_info.go:24
github.com/go-openapi/runtime/client.(*request).buildHTTP
	/app/vendor/github.com/go-openapi/runtime/client/request.go:265
github.com/go-openapi/runtime/client.(*Runtime).Submit
	/app/vendor/github.com/go-openapi/runtime/client/runtime.go:400
github.com/go-openapi/runtime/client.(*tracingTransport).Submit
	/app/vendor/github.com/go-openapi/runtime/client/opentracing.go:58
... (trim)
```

### How to reproduce
Use any swagger file that doesn't have auth field ([petstore minimal](https://github.com/OAI/OpenAPI-Specification/blob/main/examples/v2.0/json/petstore-minimal.json) is also fine)

generate client with [go-swagger](https://github.com/go-swagger/go-swagger)

Create that client transport with OpenTracing
```go
cfg := client.DefaultTransportConfig()
tt := oapiclient.New(cfg.Host, cfg.BasePath, cfg.Schemes).WithOpenTracing()
httpClient := client.New(tt, nil).Operations
httpClient.GetPets(operations.NewGetPetsParams())
```

should got panic similar to above.

### Root cause
I suspect it's at line 44 of opentracing.go here: https://github.com/go-openapi/runtime/blob/master/client/opentracing.go#L44
that we try to use authInfo which possible to be nil.
code:
```go
42:    op.AuthInfo = runtime.ClientAuthInfoWriterFunc(func(req runtime.ClientRequest, reg strfmt.Registry) error {
43:        span = createClientSpan(op, req.GetHeaderParams(), t.host, t.opts)
44:        return authInfo.AuthenticateRequest(req, reg)
45:    })
```

### Suggest solution
I think maybe if that value is nil, we can create default authInfo that do nothing and always return nil would be solved?
```go
if authInfo == nil {
    authInfo = runtime.ClientAuthInfoWriterFunc(func(r runtime.ClientRequest, _ strfmt.Registry) error {
        return nil
    })
}
```

I'm not sure if original author @zeitlinger has time for this, do you want me to create a PR?

Pull request description:
fix nil pointer when auth info is nil
Fixes #199

Patch:
diff --git a/client/opentracing.go b/client/opentracing.go
index 87e0753..1b64da0 100644
--- a/client/opentracing.go
+++ b/client/opentracing.go
@@ -41,6 +41,9 @@ func (t *tracingTransport) Submit(op *runtime.ClientOperation) (interface{}, err
 
 	op.AuthInfo = runtime.ClientAuthInfoWriterFunc(func(req runtime.ClientRequest, reg strfmt.Registry) error {
 		span = createClientSpan(op, req.GetHeaderParams(), t.host, t.opts)
+		if authInfo == nil {
+			return nil
+		}
 		return authInfo.AuthenticateRequest(req, reg)
 	})
 


Test patch:
diff --git a/client/opentracing_test.go b/client/opentracing_test.go
index db1922a..f6e8667 100644
--- a/client/opentracing_test.go
+++ b/client/opentracing_test.go
@@ -62,6 +62,19 @@ func Test_TracingRuntime_submit(t *testing.T) {
 	t.Parallel()
 	tracer := mocktracer.New()
 	_, ctx := opentracing.StartSpanFromContextWithTracer(context.Background(), tracer, "op")
+	testSubmit(t, testOperation(ctx), tracer)
+}
+
+func Test_TracingRuntime_submit_nullAuthInfo(t *testing.T) {
+	t.Parallel()
+	tracer := mocktracer.New()
+	_, ctx := opentracing.StartSpanFromContextWithTracer(context.Background(), tracer, "op")
+	operation := testOperation(ctx)
+	operation.AuthInfo = nil
+	testSubmit(t, operation, tracer)
+}
+
+func testSubmit(t *testing.T, operation *runtime.ClientOperation, tracer *mocktracer.MockTracer) {
 
 	header := map[string][]string{}
 	r := newOpenTracingTransport(&mockRuntime{runtime.TestClientRequest{Headers: header}},
@@ -71,7 +84,7 @@ func Test_TracingRuntime_submit(t *testing.T) {
 			Value: "service",
 		}})
 
-	_, err := r.Submit(testOperation(ctx))
+	_, err := r.Submit(operation)
 	require.NoError(t, err)
 
 	if assert.Len(t, tracer.FinishedSpans(), 1) {