|
4 | 4 |
|
5 | 5 | /* |
6 | 6 | Package downscope implements the ability to downscope, or restrict, the |
7 | | -Identity and AccessManagement permissions that a short-lived Token |
| 7 | +Identity and Access Management permissions that a short-lived Token |
8 | 8 | can use. Please note that only Google Cloud Storage supports this feature. |
9 | 9 | For complete documentation, see https://cloud.google.com/iam/docs/downscoping-short-lived-credentials |
| 10 | +
|
| 11 | +To downscope permissions of a source credential, you need to define |
| 12 | +a Credential Access Boundary. Said Boundary specifies which resources |
| 13 | +the newly created credential can access, an upper bound on the permissions |
| 14 | +it has over those resources, and optionally attribute-based conditional |
| 15 | +access to the aforementioned resources. For more information on IAM |
| 16 | +Conditions, see https://cloud.google.com/iam/docs/conditions-overview. |
| 17 | +
|
| 18 | +This functionality would typically be used to provide a third party with |
| 19 | +limited access to and permissions on resources held by the owner of the root |
| 20 | +credential or internally in conjunction with the principle of least privilege |
| 21 | +to ensure that internal services only hold the minimum necessary privileges |
| 22 | +for their function. |
| 23 | +
|
| 24 | +For example, a token broker can be set up on a server in a private network. |
| 25 | +Various workloads (token consumers) in the same network will send authenticated |
| 26 | +requests to that broker for downscoped tokens to access or modify specific google |
| 27 | +cloud storage buckets. See the NewTokenSource example for an example of how a |
| 28 | +token broker would use this package. |
| 29 | +
|
| 30 | +The broker will use the functionality in this package to generate a downscoped |
| 31 | +token with the requested configuration, and then pass it back to the token |
| 32 | +consumer. These downscoped access tokens can then be used to access Google |
| 33 | +Storage resources. For instance, you can create a NewClient from the |
| 34 | +"cloud.google.com/go/storage" package and pass in option.WithTokenSource(yourTokenSource)) |
10 | 35 | */ |
11 | 36 | package downscope |
12 | 37 |
|
@@ -91,7 +116,7 @@ type downscopingTokenSource struct { |
91 | 116 | config DownscopingConfig |
92 | 117 | } |
93 | 118 |
|
94 | | -// NewTokenSource returns an empty downscopingTokenSource. |
| 119 | +// NewTokenSource returns a configured downscopingTokenSource. |
95 | 120 | func NewTokenSource(ctx context.Context, conf DownscopingConfig) (oauth2.TokenSource, error) { |
96 | 121 | if conf.RootSource == nil { |
97 | 122 | return nil, fmt.Errorf("downscope: rootSource cannot be nil") |
|
0 commit comments