Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1214)

Unified Diff: go/src/infra/libs/auth/internal/gce.go

Issue 1153883002: go: infra/libs/* now live in luci-go. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: move the rest too Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « go/src/infra/libs/auth/internal/common.go ('k') | go/src/infra/libs/auth/internal/internal.infra_testing » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go/src/infra/libs/auth/internal/gce.go
diff --git a/go/src/infra/libs/auth/internal/gce.go b/go/src/infra/libs/auth/internal/gce.go
deleted file mode 100644
index 560c15d8b6ed545f914f00698525cced875cc901..0000000000000000000000000000000000000000
--- a/go/src/infra/libs/auth/internal/gce.go
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package internal
-
-import (
- "golang.org/x/oauth2/google"
- "google.golang.org/cloud/compute/metadata"
-)
-
-type gceTokenProvider struct {
- oauthTokenProvider
-
- account string
-}
-
-// NewGCETokenProvider returns TokenProvider that knows how to use GCE metadata server.
-func NewGCETokenProvider(account string, scopes []string) (TokenProvider, error) {
- // Ensure account has requested scopes.
- availableScopes, err := metadata.Scopes(account)
- if err != nil {
- return nil, err
- }
- for requested := range scopes {
- ok := false
- for available := range availableScopes {
- if requested == available {
- ok = true
- break
- }
- }
- if !ok {
- return nil, ErrInsufficientAccess
- }
- }
- return &gceTokenProvider{
- oauthTokenProvider: oauthTokenProvider{
- interactive: false,
- tokenFlavor: "gce",
- },
- account: account,
- }, nil
-}
-
-func (p *gceTokenProvider) MintToken() (Token, error) {
- src := google.ComputeTokenSource(p.account)
- tok, err := src.Token()
- if err != nil {
- return nil, err
- }
- return makeToken(tok), nil
-}
-
-func (p *gceTokenProvider) RefreshToken(Token) (Token, error) {
- // Minting and refreshing on GCE is the same thing: a call to metadata server.
- return p.MintToken()
-}
« no previous file with comments | « go/src/infra/libs/auth/internal/common.go ('k') | go/src/infra/libs/auth/internal/internal.infra_testing » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698