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

Unified Diff: go/src/infra/libs/auth/internal/service.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/internal.infra_testing ('k') | go/src/infra/libs/auth/internal/user.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go/src/infra/libs/auth/internal/service.go
diff --git a/go/src/infra/libs/auth/internal/service.go b/go/src/infra/libs/auth/internal/service.go
deleted file mode 100644
index 7a95784f4e5ed4a58aad44c82c0bc1cd81fb5c3b..0000000000000000000000000000000000000000
--- a/go/src/infra/libs/auth/internal/service.go
+++ /dev/null
@@ -1,55 +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 (
- "io/ioutil"
-
- "golang.org/x/net/context"
- "golang.org/x/oauth2/google"
- "golang.org/x/oauth2/jwt"
-)
-
-type serviceAccountTokenProvider struct {
- oauthTokenProvider
-
- ctx context.Context
- config *jwt.Config
-}
-
-// NewServiceAccountTokenProvider returns TokenProvider that supports service accounts.
-func NewServiceAccountTokenProvider(ctx context.Context, credsPath string, scopes []string) (TokenProvider, error) {
- buf, err := ioutil.ReadFile(credsPath)
- if err != nil {
- return nil, err
- }
- config, err := google.JWTConfigFromJSON(buf, scopes...)
- if err != nil {
- return nil, err
- }
- return &serviceAccountTokenProvider{
- oauthTokenProvider: oauthTokenProvider{
- interactive: false,
- tokenFlavor: "service_account",
- },
- ctx: ctx,
- config: config,
- }, nil
-}
-
-func (p *serviceAccountTokenProvider) MintToken() (Token, error) {
- src := p.config.TokenSource(p.ctx)
- tok, err := src.Token()
- if err != nil {
- return nil, err
- }
- return makeToken(tok), nil
-}
-
-func (p *serviceAccountTokenProvider) RefreshToken(Token) (Token, error) {
- // JWT tokens are self sufficient, there's no need for refresh_token. Minting
- // a token and "refreshing" it is a same thing.
- return p.MintToken()
-}
« no previous file with comments | « go/src/infra/libs/auth/internal/internal.infra_testing ('k') | go/src/infra/libs/auth/internal/user.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698