downscope: further updates and nits

This commit is contained in:
Patrick Jones
2021-06-22 09:25:17 -07:00
parent a362f28044
commit 304d28ba9e
3 changed files with 23 additions and 18 deletions

View File

@@ -1,3 +1,7 @@
// Copyright 2021 The Go 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 downscope_test
import (
@@ -9,9 +13,9 @@ import (
func ExampleNewTokenSource() {
ctx := context.Background()
// Initializes an accessBoundary with one Rule
// Initializes an accessBoundary with one Rule.
accessBoundary := []downscope.AccessBoundaryRule{
downscope.AccessBoundaryRule{
{
AvailableResource: "//storage.googleapis.com/projects/_/buckets/foo",
AvailablePermissions: []string{"inRole:roles/storage.objectViewer"},
},
@@ -23,7 +27,7 @@ func ExampleNewTokenSource() {
// rootSource, err := google.DefaultTokenSource(ctx, "https://www.googleapis.com/auth/cloud-platform")
dts := downscope.DownscopingTokenSource{ctx, downscope.DownscopingConfig{RootSource: rootSource, Rules: accessBoundary}}
dts := downscope.NewTokenSource(ctx, downscope.DownscopingConfig{RootSource: rootSource, Rules: accessBoundary})
_ = dts
// You can now use the token held in myTokenSource to make
// Google Cloud Storage calls, as follows: