You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by md...@apache.org on 2018/09/10 21:27:15 UTC
[incubator-openwhisk-client-go] branch master updated: allow
additional headers to override auth header val (#100)
This is an automated email from the ASF dual-hosted git repository.
mdeuser pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-client-go.git
The following commit(s) were added to refs/heads/master by this push:
new 61f21e1 allow additional headers to override auth header val (#100)
61f21e1 is described below
commit 61f21e18e17480f16ec8f82062a7ebe4dc39c075
Author: David Cariello <dr...@us.ibm.com>
AuthorDate: Mon Sep 10 16:27:13 2018 -0500
allow additional headers to override auth header val (#100)
* allow additional headers to override auth header val
* Deuser review
* actual Deuser review
* Deuser review x2
---
whisk/client.go | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/whisk/client.go b/whisk/client.go
index c1b3630..c710efd 100644
--- a/whisk/client.go
+++ b/whisk/client.go
@@ -301,7 +301,11 @@ func (c *Client) NewRequest(method, urlStr string, body interface{}, includeName
}
func (c *Client) addAuthHeader(req *http.Request, authRequired bool) error {
- if c.Config.AuthToken != "" {
+ // Allow for authorization override via Additional Headers
+ authHeaderValue := c.Config.AdditionalHeaders.Get("Authorization")
+ if authHeaderValue != "" {
+ Debug(DbgInfo, "Using additional header authorization\n")
+ } else if c.Config.AuthToken != "" {
encodedAuthToken := base64.StdEncoding.EncodeToString([]byte(c.Config.AuthToken))
req.Header.Add("Authorization", fmt.Sprintf("Basic %s", encodedAuthToken))
Debug(DbgInfo, "Adding basic auth header; using authkey\n")