Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
barry cho
Rancher
Commits
b015e871
Unverified
Commit
b015e871
authored
4 years ago
by
Denise
Committed by
GitHub
4 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Revert "[2.4] Add OAuth2 for GKE in proxy server"
parent
d0ccfb42
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pkg/clusterrouter/proxy/proxy_server.go
+6
-20
pkg/clusterrouter/proxy/proxy_server.go
with
6 additions
and
20 deletions
+6
-20
pkg/clusterrouter/proxy/proxy_server.go
+
6
-
20
View file @
b015e871
package
proxy
import
(
"context"
"crypto/tls"
"crypto/x509"
"encoding/base64"
...
...
@@ -12,12 +11,10 @@ import (
"strings"
"sync"
"github.com/rancher/kontainer-engine/drivers/gke"
"github.com/rancher/norman/httperror"
factory
"github.com/rancher/rancher/pkg/dialer"
v3
"github.com/rancher/types/apis/management.cattle.io/v3"
"github.com/rancher/types/config/dialer"
"golang.org/x/oauth2"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/httpstream"
utilnet
"k8s.io/apimachinery/pkg/util/net"
...
...
@@ -222,23 +219,7 @@ func (r *RemoteService) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
}
req
.
URL
.
Host
=
req
.
Host
transport
,
err
:=
r
.
getTransport
()
if
err
!=
nil
{
er
.
Error
(
rw
,
req
,
err
)
return
}
if
r
.
cluster
.
Status
.
Driver
==
"googleKubernetesEngine"
&&
r
.
cluster
.
Spec
.
GenericEngineConfig
!=
nil
{
cred
,
_
:=
(
*
r
.
cluster
.
Spec
.
GenericEngineConfig
)[
"credential"
]
.
(
string
)
ts
,
err
:=
gke
.
GetTokenSource
(
context
.
Background
(),
cred
)
if
err
!=
nil
{
er
.
Error
(
rw
,
req
,
fmt
.
Errorf
(
"unable to retrieve token source for GKE oauth2: %v"
,
err
))
return
}
transport
=
&
oauth2
.
Transport
{
Source
:
ts
,
Base
:
transport
,
}
}
else
if
r
.
auth
==
nil
{
if
r
.
auth
==
nil
{
req
.
Header
.
Del
(
"Authorization"
)
}
else
{
token
,
err
:=
r
.
auth
()
...
...
@@ -248,6 +229,11 @@ func (r *RemoteService) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
}
req
.
Header
.
Set
(
"Authorization"
,
token
)
}
transport
,
err
:=
r
.
getTransport
()
if
err
!=
nil
{
er
.
Error
(
rw
,
req
,
err
)
return
}
if
httpstream
.
IsUpgradeRequest
(
req
)
{
upgradeProxy
:=
NewUpgradeProxy
(
&
u
,
transport
)
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help