Skip to content

Commit

Permalink
feat: tie up some loose ends (#1300)
Browse files Browse the repository at this point in the history
* Add S3 control to list of services that use signed body & fix wrong method name in SigV4Util.

---------

Co-authored-by: Sichan Yoo <chanyoo@amazon.com>
  • Loading branch information
sichanyoo and Sichan Yoo authored Jan 16, 2024
1 parent f68dfeb commit 4069b54
Show file tree
Hide file tree
Showing 1,888 changed files with 115,124 additions and 357,655 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public struct SigV4AAuthScheme: ClientRuntime.AuthScheme {
updatedSigningProperties.set(key: AttributeKeys.unsignedBody, value: unsignedBody)

// Set signedBodyHeader flag
let useSignedBodyHeader = SigV4Util.serviceUsesUnsignedBodyHeader(serviceName: serviceName) && !unsignedBody
let useSignedBodyHeader = SigV4Util.serviceUsesSignedBodyHeader(serviceName: serviceName) && !unsignedBody
updatedSigningProperties.set(
key: AttributeKeys.signedBodyHeader,
value: useSignedBodyHeader ? .contentSha256 : AWSSignedBodyHeader.none
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public struct SigV4AuthScheme: ClientRuntime.AuthScheme {
updatedSigningProperties.set(key: AttributeKeys.unsignedBody, value: unsignedBody)

// Set signedBodyHeader flag
let useSignedBodyHeader = SigV4Util.serviceUsesUnsignedBodyHeader(serviceName: serviceName) && !unsignedBody
let useSignedBodyHeader = SigV4Util.serviceUsesSignedBodyHeader(serviceName: serviceName) && !unsignedBody
updatedSigningProperties.set(
key: AttributeKeys.signedBodyHeader,
value: useSignedBodyHeader ? .contentSha256 : AWSSignedBodyHeader.none
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation
import ClientRuntime

public class SigV4Util {
static let unsignedBodyHeader = ["S3", "Glacier"]
static let signedBodyHeader = ["S3", "Glacier", "S3 Control"]
static let forceUnsignedBodyForPresigningURL = [
"S3": ["getObject", "putObject"]
]
Expand All @@ -20,8 +20,8 @@ public class SigV4Util {
return serviceQualifies && flowQualifies && forceUnsignedBodyForPresigningURL[serviceName]!.contains(opName)
}

static func serviceUsesUnsignedBodyHeader(serviceName: String) -> Bool {
return unsignedBodyHeader.contains(serviceName)
static func serviceUsesSignedBodyHeader(serviceName: String) -> Bool {
return signedBodyHeader.contains(serviceName)
}

static func setS3SpecificFlags(signingProperties: inout Attributes, serviceName: String) {
Expand Down
398 changes: 97 additions & 301 deletions Sources/Services/AWSACM/ACMClient.swift

Large diffs are not rendered by default.

42 changes: 0 additions & 42 deletions Sources/Services/AWSACM/ACMClientProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@ public protocol ACMClientProtocol {
/// - `ThrottlingException` : The request was denied because it exceeded a quota.
/// - `TooManyTagsException` : The request contains too many tags. Try the request again with fewer tags.
func addTagsToCertificate(input: AddTagsToCertificateInput) async throws -> AddTagsToCertificateOutput
<<<<<<< HEAD
=======
/// Performs the `DeleteCertificate` operation on the `CertificateManager` service.
///
>>>>>>> main
/// Deletes a certificate and its associated private key. If this action succeeds, the certificate no longer appears in the list that can be displayed by calling the [ListCertificates] action or be retrieved by calling the [GetCertificate] action. The certificate will not be available for use by Amazon Web Services services integrated with ACM. You cannot delete an ACM certificate that is being used by another Amazon Web Services service. To delete a certificate that is in use, the certificate association must first be removed.
///
/// - Parameter DeleteCertificateInput : [no documentation found]
Expand All @@ -44,11 +41,8 @@ public protocol ACMClientProtocol {
/// - `ResourceNotFoundException` : The specified certificate cannot be found in the caller's account or the caller's account cannot be found.
/// - `ThrottlingException` : The request was denied because it exceeded a quota.
func deleteCertificate(input: DeleteCertificateInput) async throws -> DeleteCertificateOutput
<<<<<<< HEAD
=======
/// Performs the `DescribeCertificate` operation on the `CertificateManager` service.
///
>>>>>>> main
/// Returns detailed metadata about the specified ACM certificate. If you have just created a certificate using the RequestCertificate action, there is a delay of several seconds before you can retrieve information about it.
///
/// - Parameter DescribeCertificateInput : [no documentation found]
Expand All @@ -61,11 +55,8 @@ public protocol ACMClientProtocol {
/// - `InvalidArnException` : The requested Amazon Resource Name (ARN) does not refer to an existing resource.
/// - `ResourceNotFoundException` : The specified certificate cannot be found in the caller's account or the caller's account cannot be found.
func describeCertificate(input: DescribeCertificateInput) async throws -> DescribeCertificateOutput
<<<<<<< HEAD
=======
/// Performs the `ExportCertificate` operation on the `CertificateManager` service.
///
>>>>>>> main
/// Exports a private certificate issued by a private certificate authority (CA) for use anywhere. The exported file contains the certificate, the certificate chain, and the encrypted private 2048-bit RSA key associated with the public key that is embedded in the certificate. For security, you must assign a passphrase for the private key when exporting it. For information about exporting and formatting a certificate using the ACM console or CLI, see [Export a Private Certificate](https://docs.aws.amazon.com/acm/latest/userguide/gs-acm-export-private.html).
///
/// - Parameter ExportCertificateInput : [no documentation found]
Expand All @@ -79,11 +70,8 @@ public protocol ACMClientProtocol {
/// - `RequestInProgressException` : The certificate request is in process and the certificate in your account has not yet been issued.
/// - `ResourceNotFoundException` : The specified certificate cannot be found in the caller's account or the caller's account cannot be found.
func exportCertificate(input: ExportCertificateInput) async throws -> ExportCertificateOutput
<<<<<<< HEAD
=======
/// Performs the `GetAccountConfiguration` operation on the `CertificateManager` service.
///
>>>>>>> main
/// Returns the account configuration options associated with an Amazon Web Services account.
///
/// - Parameter GetAccountConfigurationInput : [no documentation found]
Expand All @@ -96,11 +84,8 @@ public protocol ACMClientProtocol {
/// - `AccessDeniedException` : You do not have access required to perform this action.
/// - `ThrottlingException` : The request was denied because it exceeded a quota.
func getAccountConfiguration(input: GetAccountConfigurationInput) async throws -> GetAccountConfigurationOutput
<<<<<<< HEAD
=======
/// Performs the `GetCertificate` operation on the `CertificateManager` service.
///
>>>>>>> main
/// Retrieves an Amazon-issued certificate and its certificate chain. The chain consists of the certificate of the issuing CA and the intermediate certificates of any other subordinate CAs. All of the certificates are base64 encoded. You can use [OpenSSL](https://wiki.openssl.org/index.php/Command_Line_Utilities) to decode the certificates and inspect individual fields.
///
/// - Parameter GetCertificateInput : [no documentation found]
Expand All @@ -114,11 +99,8 @@ public protocol ACMClientProtocol {
/// - `RequestInProgressException` : The certificate request is in process and the certificate in your account has not yet been issued.
/// - `ResourceNotFoundException` : The specified certificate cannot be found in the caller's account or the caller's account cannot be found.
func getCertificate(input: GetCertificateInput) async throws -> GetCertificateOutput
<<<<<<< HEAD
=======
/// Performs the `ImportCertificate` operation on the `CertificateManager` service.
///
>>>>>>> main
/// Imports a certificate into Certificate Manager (ACM) to use with services that are integrated with ACM. Note that [integrated services](https://docs.aws.amazon.com/acm/latest/userguide/acm-services.html) allow only certificate types and keys they support to be associated with their resources. Further, their support differs depending on whether the certificate is imported into IAM or into ACM. For more information, see the documentation for each service. For more information about importing certificates into ACM, see [Importing Certificates](https://docs.aws.amazon.com/acm/latest/userguide/import-certificate.html) in the Certificate Manager User Guide. ACM does not provide [managed renewal](https://docs.aws.amazon.com/acm/latest/userguide/acm-renewal.html) for certificates that you import. Note the following guidelines when importing third party certificates:
///
/// * You must enter the private key that matches the certificate you are importing.
Expand Down Expand Up @@ -165,11 +147,8 @@ public protocol ACMClientProtocol {
/// - `TagPolicyException` : A specified tag did not comply with an existing tag policy and was rejected.
/// - `TooManyTagsException` : The request contains too many tags. Try the request again with fewer tags.
func importCertificate(input: ImportCertificateInput) async throws -> ImportCertificateOutput
<<<<<<< HEAD
=======
/// Performs the `ListCertificates` operation on the `CertificateManager` service.
///
>>>>>>> main
/// Retrieves a list of certificate ARNs and domain names. You can request that only certificates that match a specific status be listed. You can also filter by specific attributes of the certificate. Default filtering returns only RSA_2048 certificates. For more information, see [Filters].
///
/// - Parameter ListCertificatesInput : [no documentation found]
Expand All @@ -182,11 +161,8 @@ public protocol ACMClientProtocol {
/// - `InvalidArgsException` : One or more of of request parameters specified is not valid.
/// - `ValidationException` : The supplied input failed to satisfy constraints of an Amazon Web Services service.
func listCertificates(input: ListCertificatesInput) async throws -> ListCertificatesOutput
<<<<<<< HEAD
=======
/// Performs the `ListTagsForCertificate` operation on the `CertificateManager` service.
///
>>>>>>> main
/// Lists the tags that have been applied to the ACM certificate. Use the certificate's Amazon Resource Name (ARN) to specify the certificate. To add a tag to an ACM certificate, use the [AddTagsToCertificate] action. To delete a tag, use the [RemoveTagsFromCertificate] action.
///
/// - Parameter ListTagsForCertificateInput : [no documentation found]
Expand All @@ -199,11 +175,8 @@ public protocol ACMClientProtocol {
/// - `InvalidArnException` : The requested Amazon Resource Name (ARN) does not refer to an existing resource.
/// - `ResourceNotFoundException` : The specified certificate cannot be found in the caller's account or the caller's account cannot be found.
func listTagsForCertificate(input: ListTagsForCertificateInput) async throws -> ListTagsForCertificateOutput
<<<<<<< HEAD
=======
/// Performs the `PutAccountConfiguration` operation on the `CertificateManager` service.
///
>>>>>>> main
/// Adds or modifies account-level configurations in ACM. The supported configuration option is DaysBeforeExpiry. This option specifies the number of days prior to certificate expiration when ACM starts generating EventBridge events. ACM sends one event per day per certificate until the certificate expires. By default, accounts receive events starting 45 days before certificate expiration.
///
/// - Parameter PutAccountConfigurationInput : [no documentation found]
Expand All @@ -218,11 +191,8 @@ public protocol ACMClientProtocol {
/// - `ThrottlingException` : The request was denied because it exceeded a quota.
/// - `ValidationException` : The supplied input failed to satisfy constraints of an Amazon Web Services service.
func putAccountConfiguration(input: PutAccountConfigurationInput) async throws -> PutAccountConfigurationOutput
<<<<<<< HEAD
=======
/// Performs the `RemoveTagsFromCertificate` operation on the `CertificateManager` service.
///
>>>>>>> main
/// Remove one or more tags from an ACM certificate. A tag consists of a key-value pair. If you do not specify the value portion of the tag when calling this function, the tag will be removed regardless of value. If you specify a value, the tag is removed only if it is associated with the specified value. To add tags to a certificate, use the [AddTagsToCertificate] action. To view all of the tags that have been applied to a specific ACM certificate, use the [ListTagsForCertificate] action.
///
/// - Parameter RemoveTagsFromCertificateInput : [no documentation found]
Expand All @@ -239,11 +209,8 @@ public protocol ACMClientProtocol {
/// - `TagPolicyException` : A specified tag did not comply with an existing tag policy and was rejected.
/// - `ThrottlingException` : The request was denied because it exceeded a quota.
func removeTagsFromCertificate(input: RemoveTagsFromCertificateInput) async throws -> RemoveTagsFromCertificateOutput
<<<<<<< HEAD
=======
/// Performs the `RenewCertificate` operation on the `CertificateManager` service.
///
>>>>>>> main
/// Renews an eligible ACM certificate. At this time, only exported private certificates can be renewed with this operation. In order to renew your Amazon Web Services Private CA certificates with ACM, you must first [grant the ACM service principal permission to do so](https://docs.aws.amazon.com/privateca/latest/userguide/PcaPermissions.html). For more information, see [Testing Managed Renewal](https://docs.aws.amazon.com/acm/latest/userguide/manual-renewal.html) in the ACM User Guide.
///
/// - Parameter RenewCertificateInput : [no documentation found]
Expand All @@ -256,11 +223,8 @@ public protocol ACMClientProtocol {
/// - `InvalidArnException` : The requested Amazon Resource Name (ARN) does not refer to an existing resource.
/// - `ResourceNotFoundException` : The specified certificate cannot be found in the caller's account or the caller's account cannot be found.
func renewCertificate(input: RenewCertificateInput) async throws -> RenewCertificateOutput
<<<<<<< HEAD
=======
/// Performs the `RequestCertificate` operation on the `CertificateManager` service.
///
>>>>>>> main
/// Requests an ACM certificate for use with other Amazon Web Services services. To request an ACM certificate, you must specify a fully qualified domain name (FQDN) in the DomainName parameter. You can also specify additional FQDNs in the SubjectAlternativeNames parameter. If you are requesting a private certificate, domain validation is not required. If you are requesting a public certificate, each domain name that you specify must be validated to verify that you own or control the domain. You can use [DNS validation](https://docs.aws.amazon.com/acm/latest/userguide/gs-acm-validate-dns.html) or [email validation](https://docs.aws.amazon.com/acm/latest/userguide/gs-acm-validate-email.html). We recommend that you use DNS validation. ACM issues public certificates after receiving approval from the domain owner. ACM behavior differs from the [RFC 6125](https://datatracker.ietf.org/doc/html/rfc6125#appendix-B.2) specification of the certificate validation process. ACM first checks for a Subject Alternative Name, and, if it finds one, ignores the common name (CN). After successful completion of the RequestCertificate action, there is a delay of several seconds before you can retrieve information about the new certificate.
///
/// - Parameter RequestCertificateInput : [no documentation found]
Expand All @@ -278,11 +242,8 @@ public protocol ACMClientProtocol {
/// - `TagPolicyException` : A specified tag did not comply with an existing tag policy and was rejected.
/// - `TooManyTagsException` : The request contains too many tags. Try the request again with fewer tags.
func requestCertificate(input: RequestCertificateInput) async throws -> RequestCertificateOutput
<<<<<<< HEAD
=======
/// Performs the `ResendValidationEmail` operation on the `CertificateManager` service.
///
>>>>>>> main
/// Resends the email that requests domain ownership validation. The domain owner or an authorized representative must approve the ACM certificate before it can be issued. The certificate can be approved by clicking a link in the mail to navigate to the Amazon certificate approval website and then clicking I Approve. However, the validation email can be blocked by spam filters. Therefore, if you do not receive the original mail, you can request that the mail be resent within 72 hours of requesting the ACM certificate. If more than 72 hours have elapsed since your original request or since your last attempt to resend validation mail, you must request a new certificate. For more information about setting up your contact email addresses, see [Configure Email for your Domain](https://docs.aws.amazon.com/acm/latest/userguide/setup-email.html).
///
/// - Parameter ResendValidationEmailInput : [no documentation found]
Expand All @@ -297,11 +258,8 @@ public protocol ACMClientProtocol {
/// - `InvalidStateException` : Processing has reached an invalid state.
/// - `ResourceNotFoundException` : The specified certificate cannot be found in the caller's account or the caller's account cannot be found.
func resendValidationEmail(input: ResendValidationEmailInput) async throws -> ResendValidationEmailOutput
<<<<<<< HEAD
=======
/// Performs the `UpdateCertificateOptions` operation on the `CertificateManager` service.
///
>>>>>>> main
/// Updates a certificate. Currently, you can use this function to specify whether to opt in to or out of recording your certificate in a certificate transparency log. For more information, see [ Opting Out of Certificate Transparency Logging](https://docs.aws.amazon.com/acm/latest/userguide/acm-bestpractices.html#best-practices-transparency).
///
/// - Parameter UpdateCertificateOptionsInput : [no documentation found]
Expand Down
43 changes: 43 additions & 0 deletions Sources/Services/AWSACM/AuthSchemeResolver.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Code generated by smithy-swift-codegen. DO NOT EDIT!

import ClientRuntime

public struct ACMAuthSchemeResolverParameters: ClientRuntime.AuthSchemeResolverParameters {
public let operation: String
// Region is used for SigV4 auth scheme
public let region: String?
}

public protocol ACMAuthSchemeResolver: ClientRuntime.AuthSchemeResolver {
// Intentionally empty.
// This is the parent protocol that all auth scheme resolver implementations of
// the service ACM must conform to.
}

public struct DefaultACMAuthSchemeResolver: ACMAuthSchemeResolver {
public func resolveAuthScheme(params: ClientRuntime.AuthSchemeResolverParameters) throws -> [AuthOption] {
var validAuthOptions = [AuthOption]()
guard let serviceParams = params as? ACMAuthSchemeResolverParameters else {
throw ClientError.authError("Service specific auth scheme parameters type must be passed to auth scheme resolver.")
}
switch serviceParams.operation {
default:
var sigV4Option = AuthOption(schemeID: "aws.auth#sigv4")
sigV4Option.signingProperties.set(key: AttributeKeys.signingName, value: "acm")
guard let region = serviceParams.region else {
throw ClientError.authError("Missing region in auth scheme parameters for SigV4 auth scheme.")
}
sigV4Option.signingProperties.set(key: AttributeKeys.signingRegion, value: region)
validAuthOptions.append(sigV4Option)
}
return validAuthOptions
}

public func constructParameters(context: HttpContext) throws -> ClientRuntime.AuthSchemeResolverParameters {
guard let opName = context.getOperation() else {
throw ClientError.dataNotFound("Operation name not configured in middleware context for auth scheme resolver params construction.")
}
let opRegion = context.getRegion()
return ACMAuthSchemeResolverParameters(operation: opName, region: opRegion)
}
}
Loading

0 comments on commit 4069b54

Please sign in to comment.