Skip to content

Commit

Permalink
Remove all references to IAMAuthToken. (google#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
mahiuchun authored and shinfan committed Sep 18, 2018
1 parent 54ecccd commit 587ef66
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 23 deletions.
3 changes: 1 addition & 2 deletions sgauth/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
package sgauth

import (
"crypto/x509"
"golang.org/x/net/context"
"google.golang.org/grpc"
"crypto/x509"
"google.golang.org/grpc/credentials"

"fmt"
Expand All @@ -37,7 +37,6 @@ func NewGrpcConn(ctx context.Context, settings *Settings, host string, port stri
perRPC := internal.GrpcTokenSource{
QuotaUser: settings.QuotaUser,
QuotaProject: settings.QuotaProject,
IAMAuthToken: settings.IAMAuthToken,
}

if settings.APIKey != "" {
Expand Down
3 changes: 1 addition & 2 deletions sgauth/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ package sgauth

import (
"github.com/google/oauth2l/sgauth/internal"
"net/http"
"golang.org/x/net/context"
"net/http"
)

var DefaultScope = "https://www.googleapis.com/auth/cloud-platform"
Expand All @@ -28,7 +28,6 @@ func NewHTTPClient(ctx context.Context, settings *Settings) (*http.Client, error
Base: http.DefaultClient.Transport,
QuotaUser: settings.QuotaUser,
QuotaProject: settings.QuotaProject,
IAMAuthToken: settings.IAMAuthToken,
}

if settings.APIKey != "" {
Expand Down
7 changes: 3 additions & 4 deletions sgauth/internal/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ package internal

// Keys for HTTP google headers
const (
headerAuth = "authorization"
headerApiKey = "X-Goog-Api-Key"
headerQuotaUser = "X-Goog-Quota-User"
headerAuth = "authorization"
headerApiKey = "X-Goog-Api-Key"
headerQuotaUser = "X-Goog-Quota-User"
headerQuotaProject = "X-Goog-User-Project"
headerIAMAuthToken = "X-Goog-IAM-Authorization-Token"
)
4 changes: 0 additions & 4 deletions sgauth/internal/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ type GrpcTokenSource struct {
// Additional metadata attached as headers
QuotaUser string
QuotaProject string
IAMAuthToken string
}

// GetRequestMetadata gets the request metadata as a map from a TokenSource.
Expand Down Expand Up @@ -56,7 +55,4 @@ func attachAdditionalMetadata(metadata map[string]string, ts GrpcTokenSource) {
if ts.QuotaProject != "" {
metadata[headerQuotaProject] = ts.QuotaProject
}
if ts.IAMAuthToken != "" {
metadata[headerIAMAuthToken] = ts.IAMAuthToken
}
}
8 changes: 2 additions & 6 deletions sgauth/internal/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ type Transport struct {
// Additional metadata attached as headers
QuotaUser string
QuotaProject string
IAMAuthToken string

// Base is the base RoundTripper used to make HTTP requests.
// If nil, http.DefaultTransport is used.
Expand Down Expand Up @@ -166,13 +165,10 @@ func (r *onEOFReader) runFunc() {
}

func attachAdditionalHeaders(t *Transport, req *http.Request) {
if (t.QuotaUser != "") {
if t.QuotaUser != "" {
req.Header.Set(headerQuotaUser, t.QuotaUser)
}
if (t.QuotaProject != "") {
if t.QuotaProject != "" {
req.Header.Set(headerQuotaProject, t.QuotaProject)
}
if (t.IAMAuthToken != "") {
req.Header.Set(headerIAMAuthToken, t.IAMAuthToken)
}
}
6 changes: 1 addition & 5 deletions sgauth/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ type Settings struct {
// A user specified project that is responsible for the request quota and
// billing charges.
QuotaProject string
// IAM context attributes
// UNIMPLEMENTED
IAMAuthToken string
// End-user OAuth Flow handler that redirects the user to the given URL
// and returns the token.
OAuthFlowHandler func(url string) (token string, err error)
Expand All @@ -52,12 +49,11 @@ type Settings struct {
State string
}

func (s Settings)AuthMethod() string {
func (s Settings) AuthMethod() string {
if s.APIKey != "" {
return MethodAPIKey
} else if s.Scope != "" {
return MethodOAuth
}
return MethodJWT
}

0 comments on commit 587ef66

Please sign in to comment.