| 
									
										
										
										
											2021-04-19 03:41:13 +08:00
										 |  |  | // Copyright (c) 2015-2021 MinIO, Inc.
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // This file is part of MinIO Object Storage stack
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // This program is free software: you can redistribute it and/or modify
 | 
					
						
							|  |  |  | // it under the terms of the GNU Affero General Public License as published by
 | 
					
						
							|  |  |  | // the Free Software Foundation, either version 3 of the License, or
 | 
					
						
							|  |  |  | // (at your option) any later version.
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // This program is distributed in the hope that it will be useful
 | 
					
						
							|  |  |  | // but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					
						
							|  |  |  | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					
						
							|  |  |  | // GNU Affero General Public License for more details.
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // You should have received a copy of the GNU Affero General Public License
 | 
					
						
							|  |  |  | // along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
					
						
							| 
									
										
										
										
											2019-01-05 05:48:12 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | package cmd | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							|  |  |  | 	"encoding/xml" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-02 05:59:40 +08:00
										 |  |  | 	"github.com/minio/minio/internal/auth" | 
					
						
							| 
									
										
										
										
											2019-01-05 05:48:12 +08:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // AssumedRoleUser - The identifiers for the temporary security credentials that
 | 
					
						
							|  |  |  | // the operation returns. Please also see https://docs.aws.amazon.com/goto/WebAPI/sts-2011-06-15/AssumedRoleUser
 | 
					
						
							|  |  |  | type AssumedRoleUser struct { | 
					
						
							|  |  |  | 	// The ARN of the temporary security credentials that are returned from the
 | 
					
						
							|  |  |  | 	// AssumeRole action. For more information about ARNs and how to use them in
 | 
					
						
							|  |  |  | 	// policies, see IAM Identifiers (http://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html)
 | 
					
						
							|  |  |  | 	// in Using IAM.
 | 
					
						
							|  |  |  | 	//
 | 
					
						
							|  |  |  | 	// Arn is a required field
 | 
					
						
							|  |  |  | 	Arn string | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// A unique identifier that contains the role ID and the role session name of
 | 
					
						
							|  |  |  | 	// the role that is being assumed. The role ID is generated by AWS when the
 | 
					
						
							|  |  |  | 	// role is created.
 | 
					
						
							|  |  |  | 	//
 | 
					
						
							|  |  |  | 	// AssumedRoleId is a required field
 | 
					
						
							|  |  |  | 	AssumedRoleID string `xml:"AssumeRoleId"` | 
					
						
							|  |  |  | 	// contains filtered or unexported fields
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-28 09:46:55 +08:00
										 |  |  | // AssumeRoleResponse contains the result of successful AssumeRole request.
 | 
					
						
							|  |  |  | type AssumeRoleResponse struct { | 
					
						
							|  |  |  | 	XMLName xml.Name `xml:"https://sts.amazonaws.com/doc/2011-06-15/ AssumeRoleResponse" json:"-"` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Result           AssumeRoleResult `xml:"AssumeRoleResult"` | 
					
						
							|  |  |  | 	ResponseMetadata struct { | 
					
						
							|  |  |  | 		RequestID string `xml:"RequestId,omitempty"` | 
					
						
							|  |  |  | 	} `xml:"ResponseMetadata,omitempty"` | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // AssumeRoleResult - Contains the response to a successful AssumeRole
 | 
					
						
							|  |  |  | // request, including temporary credentials that can be used to make
 | 
					
						
							| 
									
										
										
										
											2019-04-10 02:39:42 +08:00
										 |  |  | // MinIO API requests.
 | 
					
						
							| 
									
										
										
										
											2019-02-28 09:46:55 +08:00
										 |  |  | type AssumeRoleResult struct { | 
					
						
							|  |  |  | 	// The identifiers for the temporary security credentials that the operation
 | 
					
						
							|  |  |  | 	// returns.
 | 
					
						
							|  |  |  | 	AssumedRoleUser AssumedRoleUser `xml:",omitempty"` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// The temporary security credentials, which include an access key ID, a secret
 | 
					
						
							|  |  |  | 	// access key, and a security (or session) token.
 | 
					
						
							|  |  |  | 	//
 | 
					
						
							|  |  |  | 	// Note: The size of the security token that STS APIs return is not fixed. We
 | 
					
						
							|  |  |  | 	// strongly recommend that you make no assumptions about the maximum size. As
 | 
					
						
							|  |  |  | 	// of this writing, the typical size is less than 4096 bytes, but that can vary.
 | 
					
						
							|  |  |  | 	// Also, future updates to AWS might require larger sizes.
 | 
					
						
							|  |  |  | 	Credentials auth.Credentials `xml:",omitempty"` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// A percentage value that indicates the size of the policy in packed form.
 | 
					
						
							|  |  |  | 	// The service rejects any policy with a packed size greater than 100 percent,
 | 
					
						
							|  |  |  | 	// which means the policy exceeded the allowed space.
 | 
					
						
							|  |  |  | 	PackedPolicySize int `xml:",omitempty"` | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-05 05:48:12 +08:00
										 |  |  | // AssumeRoleWithWebIdentityResponse contains the result of successful AssumeRoleWithWebIdentity request.
 | 
					
						
							|  |  |  | type AssumeRoleWithWebIdentityResponse struct { | 
					
						
							|  |  |  | 	XMLName          xml.Name          `xml:"https://sts.amazonaws.com/doc/2011-06-15/ AssumeRoleWithWebIdentityResponse" json:"-"` | 
					
						
							|  |  |  | 	Result           WebIdentityResult `xml:"AssumeRoleWithWebIdentityResult"` | 
					
						
							|  |  |  | 	ResponseMetadata struct { | 
					
						
							|  |  |  | 		RequestID string `xml:"RequestId,omitempty"` | 
					
						
							|  |  |  | 	} `xml:"ResponseMetadata,omitempty"` | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // WebIdentityResult - Contains the response to a successful AssumeRoleWithWebIdentity
 | 
					
						
							| 
									
										
										
										
											2019-04-10 02:39:42 +08:00
										 |  |  | // request, including temporary credentials that can be used to make MinIO API requests.
 | 
					
						
							| 
									
										
										
										
											2019-01-05 05:48:12 +08:00
										 |  |  | type WebIdentityResult struct { | 
					
						
							|  |  |  | 	// The identifiers for the temporary security credentials that the operation
 | 
					
						
							|  |  |  | 	// returns.
 | 
					
						
							|  |  |  | 	AssumedRoleUser AssumedRoleUser `xml:",omitempty"` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// The intended audience (also known as client ID) of the web identity token.
 | 
					
						
							|  |  |  | 	// This is traditionally the client identifier issued to the application that
 | 
					
						
							|  |  |  | 	// requested the client grants.
 | 
					
						
							|  |  |  | 	Audience string `xml:",omitempty"` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// The temporary security credentials, which include an access key ID, a secret
 | 
					
						
							|  |  |  | 	// access key, and a security (or session) token.
 | 
					
						
							|  |  |  | 	//
 | 
					
						
							|  |  |  | 	// Note: The size of the security token that STS APIs return is not fixed. We
 | 
					
						
							|  |  |  | 	// strongly recommend that you make no assumptions about the maximum size. As
 | 
					
						
							|  |  |  | 	// of this writing, the typical size is less than 4096 bytes, but that can vary.
 | 
					
						
							|  |  |  | 	// Also, future updates to AWS might require larger sizes.
 | 
					
						
							|  |  |  | 	Credentials auth.Credentials `xml:",omitempty"` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// A percentage value that indicates the size of the policy in packed form.
 | 
					
						
							|  |  |  | 	// The service rejects any policy with a packed size greater than 100 percent,
 | 
					
						
							|  |  |  | 	// which means the policy exceeded the allowed space.
 | 
					
						
							|  |  |  | 	PackedPolicySize int `xml:",omitempty"` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// The issuing authority of the web identity token presented. For OpenID Connect
 | 
					
						
							| 
									
										
										
										
											2021-07-28 13:38:12 +08:00
										 |  |  | 	// ID tokens, this contains the value of the iss field. For OAuth 2.0 id_tokens,
 | 
					
						
							| 
									
										
										
										
											2019-01-05 05:48:12 +08:00
										 |  |  | 	// this contains the value of the ProviderId parameter that was passed in the
 | 
					
						
							|  |  |  | 	// AssumeRoleWithWebIdentity request.
 | 
					
						
							|  |  |  | 	Provider string `xml:",omitempty"` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// The unique user identifier that is returned by the identity provider.
 | 
					
						
							|  |  |  | 	// This identifier is associated with the Token that was submitted
 | 
					
						
							|  |  |  | 	// with the AssumeRoleWithWebIdentity call. The identifier is typically unique to
 | 
					
						
							|  |  |  | 	// the user and the application that acquired the WebIdentityToken (pairwise identifier).
 | 
					
						
							|  |  |  | 	// For OpenID Connect ID tokens, this field contains the value returned by the identity
 | 
					
						
							|  |  |  | 	// provider as the token's sub (Subject) claim.
 | 
					
						
							|  |  |  | 	SubjectFromWebIdentityToken string `xml:",omitempty"` | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // AssumeRoleWithClientGrantsResponse contains the result of successful AssumeRoleWithClientGrants request.
 | 
					
						
							|  |  |  | type AssumeRoleWithClientGrantsResponse struct { | 
					
						
							|  |  |  | 	XMLName          xml.Name           `xml:"https://sts.amazonaws.com/doc/2011-06-15/ AssumeRoleWithClientGrantsResponse" json:"-"` | 
					
						
							|  |  |  | 	Result           ClientGrantsResult `xml:"AssumeRoleWithClientGrantsResult"` | 
					
						
							|  |  |  | 	ResponseMetadata struct { | 
					
						
							|  |  |  | 		RequestID string `xml:"RequestId,omitempty"` | 
					
						
							|  |  |  | 	} `xml:"ResponseMetadata,omitempty"` | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // ClientGrantsResult - Contains the response to a successful AssumeRoleWithClientGrants
 | 
					
						
							| 
									
										
										
										
											2019-04-10 02:39:42 +08:00
										 |  |  | // request, including temporary credentials that can be used to make MinIO API requests.
 | 
					
						
							| 
									
										
										
										
											2019-01-05 05:48:12 +08:00
										 |  |  | type ClientGrantsResult struct { | 
					
						
							|  |  |  | 	// The identifiers for the temporary security credentials that the operation
 | 
					
						
							|  |  |  | 	// returns.
 | 
					
						
							|  |  |  | 	AssumedRoleUser AssumedRoleUser `xml:",omitempty"` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// The intended audience (also known as client ID) of the web identity token.
 | 
					
						
							|  |  |  | 	// This is traditionally the client identifier issued to the application that
 | 
					
						
							|  |  |  | 	// requested the client grants.
 | 
					
						
							|  |  |  | 	Audience string `xml:",omitempty"` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// The temporary security credentials, which include an access key ID, a secret
 | 
					
						
							|  |  |  | 	// access key, and a security (or session) token.
 | 
					
						
							|  |  |  | 	//
 | 
					
						
							|  |  |  | 	// Note: The size of the security token that STS APIs return is not fixed. We
 | 
					
						
							|  |  |  | 	// strongly recommend that you make no assumptions about the maximum size. As
 | 
					
						
							|  |  |  | 	// of this writing, the typical size is less than 4096 bytes, but that can vary.
 | 
					
						
							|  |  |  | 	// Also, future updates to AWS might require larger sizes.
 | 
					
						
							|  |  |  | 	Credentials auth.Credentials `xml:",omitempty"` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// A percentage value that indicates the size of the policy in packed form.
 | 
					
						
							|  |  |  | 	// The service rejects any policy with a packed size greater than 100 percent,
 | 
					
						
							|  |  |  | 	// which means the policy exceeded the allowed space.
 | 
					
						
							|  |  |  | 	PackedPolicySize int `xml:",omitempty"` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// The issuing authority of the web identity token presented. For OpenID Connect
 | 
					
						
							| 
									
										
										
										
											2021-07-28 13:38:12 +08:00
										 |  |  | 	// ID tokens, this contains the value of the iss field. For OAuth 2.0 id_tokens,
 | 
					
						
							| 
									
										
										
										
											2019-01-05 05:48:12 +08:00
										 |  |  | 	// this contains the value of the ProviderId parameter that was passed in the
 | 
					
						
							|  |  |  | 	// AssumeRoleWithClientGrants request.
 | 
					
						
							|  |  |  | 	Provider string `xml:",omitempty"` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// The unique user identifier that is returned by the identity provider.
 | 
					
						
							|  |  |  | 	// This identifier is associated with the Token that was submitted
 | 
					
						
							|  |  |  | 	// with the AssumeRoleWithClientGrants call. The identifier is typically unique to
 | 
					
						
							|  |  |  | 	// the user and the application that acquired the ClientGrantsToken (pairwise identifier).
 | 
					
						
							|  |  |  | 	// For OpenID Connect ID tokens, this field contains the value returned by the identity
 | 
					
						
							|  |  |  | 	// provider as the token's sub (Subject) claim.
 | 
					
						
							|  |  |  | 	SubjectFromToken string `xml:",omitempty"` | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2019-09-10 07:12:29 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | // AssumeRoleWithLDAPResponse contains the result of successful
 | 
					
						
							|  |  |  | // AssumeRoleWithLDAPIdentity request
 | 
					
						
							|  |  |  | type AssumeRoleWithLDAPResponse struct { | 
					
						
							| 
									
										
										
										
											2019-09-24 06:21:16 +08:00
										 |  |  | 	XMLName          xml.Name           `xml:"https://sts.amazonaws.com/doc/2011-06-15/ AssumeRoleWithLDAPIdentityResponse" json:"-"` | 
					
						
							|  |  |  | 	Result           LDAPIdentityResult `xml:"AssumeRoleWithLDAPIdentityResult"` | 
					
						
							| 
									
										
										
										
											2019-09-10 07:12:29 +08:00
										 |  |  | 	ResponseMetadata struct { | 
					
						
							|  |  |  | 		RequestID string `xml:"RequestId,omitempty"` | 
					
						
							|  |  |  | 	} `xml:"ResponseMetadata,omitempty"` | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // LDAPIdentityResult - contains credentials for a successful
 | 
					
						
							|  |  |  | // AssumeRoleWithLDAPIdentity request.
 | 
					
						
							|  |  |  | type LDAPIdentityResult struct { | 
					
						
							|  |  |  | 	Credentials auth.Credentials `xml:",omitempty"` | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2021-09-08 10:03:48 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | // AssumeRoleWithCertificateResponse contains the result of
 | 
					
						
							|  |  |  | // a successful AssumeRoleWithCertificate request.
 | 
					
						
							|  |  |  | type AssumeRoleWithCertificateResponse struct { | 
					
						
							|  |  |  | 	XMLName xml.Name `xml:"https://sts.amazonaws.com/doc/2011-06-15/ AssumeRoleWithCertificateResponse" json:"-"` | 
					
						
							|  |  |  | 	Result  struct { | 
					
						
							|  |  |  | 		Credentials auth.Credentials `xml:"Credentials,omitempty"` | 
					
						
							|  |  |  | 	} `xml:"AssumeRoleWithCertificateResult"` | 
					
						
							|  |  |  | 	Metadata struct { | 
					
						
							|  |  |  | 		RequestID string `xml:"RequestId,omitempty"` | 
					
						
							|  |  |  | 	} `xml:"ResponseMetadata,omitempty"` | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-05-27 08:58:09 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | // AssumeRoleWithCustomTokenResponse contains the result of a successful
 | 
					
						
							|  |  |  | // AssumeRoleWithCustomToken request.
 | 
					
						
							|  |  |  | type AssumeRoleWithCustomTokenResponse struct { | 
					
						
							|  |  |  | 	XMLName xml.Name `xml:"https://sts.amazonaws.com/doc/2011-06-15/ AssumeRoleWithCustomTokenResponse" json:"-"` | 
					
						
							|  |  |  | 	Result  struct { | 
					
						
							|  |  |  | 		Credentials auth.Credentials `xml:"Credentials,omitempty"` | 
					
						
							|  |  |  | 		AssumedUser string           `xml:"AssumedUser,omitempty"` | 
					
						
							|  |  |  | 	} `xml:"AssumeRoleWithCustomTokenResult"` | 
					
						
							|  |  |  | 	Metadata struct { | 
					
						
							|  |  |  | 		RequestID string `xml:"RequestId,omitempty"` | 
					
						
							|  |  |  | 	} `xml:"ResponseMetadata,omitempty"` | 
					
						
							|  |  |  | } |