forked from vmware-archive/dispatch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.go
36 lines (29 loc) · 1.02 KB
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
///////////////////////////////////////////////////////////////////////
// Copyright (c) 2017 VMware, Inc. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
///////////////////////////////////////////////////////////////////////
package client
import (
"github.com/go-openapi/runtime"
swaggerclient "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
)
// NO TESTS
const TokenHeaderName = "cookie"
func AuthWithUserPassword(username string, password string) runtime.ClientAuthInfoWriter {
return swaggerclient.BasicAuth(username, password)
}
func AuthWithToken(token string) runtime.ClientAuthInfoWriter {
return swaggerclient.APIKeyAuth(TokenHeaderName, "header", token)
}
func AuthWithMulti(writers ...runtime.ClientAuthInfoWriter) runtime.ClientAuthInfoWriter {
return runtime.ClientAuthInfoWriterFunc(func(r runtime.ClientRequest, registry strfmt.Registry) error {
for _, w := range writers {
err := w.AuthenticateRequest(r, registry)
if err != nil {
return err
}
}
return nil
})
}