func NewTokenSource(ctx context.Context, conf DownscopingConfig) (oauth2.TokenSource, error)
NewTokenSource returns a configured downscopingTokenSource.
▹ Example
An AccessBoundaryRule Sets the permissions (and optionally conditions) that the new token has on given resource.
type AccessBoundaryRule struct { // AvailableResource is the full resource name of the Cloud Storage bucket that the rule applies to. // Use the format //storage.googleapis.com/projects/_/buckets/bucket-name. AvailableResource string `json:"availableResource"` // AvailablePermissions is a list that defines the upper bound on the available permissions // for the resource. Each value is the identifier for an IAM predefined role or custom role, // with the prefix inRole:. For example: inRole:roles/storage.objectViewer. // Only the permissions in these roles will be available. AvailablePermissions []string `json:"availablePermissions"` // An Condition restricts the availability of permissions // to specific Cloud Storage objects. Optional. // // A Condition can be used to make permissions available for specific objects, // rather than all objects in a Cloud Storage bucket. Condition *AvailabilityCondition `json:"availabilityCondition,omitempty"` }
An AvailabilityCondition restricts access to a given Resource.
type AvailabilityCondition struct { // An Expression specifies the Cloud Storage objects where // permissions are available. For further documentation, see // https://cloud.google.com/iam/docs/conditions-overview Expression string `json:"expression"` // Title is short string that identifies the purpose of the condition. Optional. Title string `json:"title,omitempty"` // Description details about the purpose of the condition. Optional. Description string `json:"description,omitempty"` }
DownscopingConfig specifies the information necessary to request a downscoped token.
type DownscopingConfig struct { // RootSource is the TokenSource used to create the downscoped token. // The downscoped token therefore has some subset of the accesses of // the original RootSource. RootSource oauth2.TokenSource // Rules defines the accesses held by the new // downscoped Token. One or more AccessBoundaryRules are required to // define permissions for the new downscoped token. Each one defines an // access (or set of accesses) that the new token has to a given resource. // There can be a maximum of 10 AccessBoundaryRules. Rules []AccessBoundaryRule // UniverseDomain is the default service domain for a given Cloud universe. // The default value is "googleapis.com". Optional. UniverseDomain string }