Unverified Commit 1d1e68ae authored by Eduardo de Moura Rodrigues's avatar Eduardo de Moura Rodrigues Committed by GitHub
Browse files

feat(smithy-http-auth): add api key auth types (#2153)



* feat(aws-types): add api key to configuration

* chore: set package version to 0.52.0

* feat(aws-smithy-types): create auth types

* chore: use auth from smithy types

* chore: fix return self type

* chore: create http auth definition type

* chore: add constructor for http auth definition

* chore: ensure properties are not moved

* chore: create convenience constructors

* chore: add some todo comments

* feat: move query writer to aws-smithy-http crate

* chore(codegen): expose smithy http tower dependency

* chore: remove setters for auth definition

* chore: fix logical error for scheme not allowed

* chore: add constructor for basic and digest auth

* chore: allow equality comparision for api key

* Revert "chore: set package version to 0.52.0"

This reverts commit da660fcf160e24605ebe082deb6f339213926340.

* chore: fix additional references to querywriter

* chore: implement from string for api key struct

* chore: disallow none api key in sdk config

* chore: fix formatting

* chore: add unit tests for auth types

* chore: add auth api key to external types

* chore: make query writer doc hidden

* feat: create aws-smithy-http-auth crate

* chore: use zeroing for auth api key

* chore: use builder pattern for auth definition

* chore: restructure http auth package

* chore: define default lint warning

* chore: include http auth in runtime common list

* chore: define setter for optional scheme

* chore: should panic while building auth definition

* chore: return missing required field error

* chore: make few code simplications for api key

* Revert "chore: add auth api key to external types"

This reverts commit b2318b02304fdeefbe5cb8eba80047ae307d08fa.

* chore: revert api key from sdk config

* chore: panic on missing required field

* Opt out of `clippy::derive_partial_eq_without_eq`

---------

Co-authored-by: default avatarEduardo Rodrigues <eduardomourar@users.noreply.github.com>
Co-authored-by: default avatarJohn DiSanti <jdisanti@amazon.com>
parent 10520d7f
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@

use crate::date_time::{format_date, format_date_time};
use crate::http_request::error::CanonicalRequestError;
use crate::http_request::query_writer::QueryWriter;
use crate::http_request::settings::UriPathNormalizationMode;
use crate::http_request::sign::SignableRequest;
use crate::http_request::uri_path_normalization::normalize_uri_path;
@@ -13,6 +12,7 @@ use crate::http_request::url_escape::percent_encode_path;
use crate::http_request::PercentEncodingMode;
use crate::http_request::{PayloadChecksumKind, SignableBody, SignatureLocation, SigningParams};
use crate::sign::sha256_hex_string;
use aws_smithy_http::query_writer::QueryWriter;
use http::header::{AsHeaderName, HeaderName, HOST};
use http::{HeaderMap, HeaderValue, Method, Uri};
use std::borrow::Cow;
@@ -519,13 +519,13 @@ mod tests {
    use crate::http_request::canonical_request::{
        normalize_header_value, trim_all, CanonicalRequest, SigningScope, StringToSign,
    };
    use crate::http_request::query_writer::QueryWriter;
    use crate::http_request::test::{test_canonical_request, test_request, test_sts};
    use crate::http_request::{
        PayloadChecksumKind, SignableBody, SignableRequest, SigningSettings,
    };
    use crate::http_request::{SignatureLocation, SigningParams};
    use crate::sign::sha256_hex_string;
    use aws_smithy_http::query_writer::QueryWriter;
    use http::Uri;
    use http::{header::HeaderName, HeaderValue};
    use pretty_assertions::assert_eq;
+0 −1
Original line number Diff line number Diff line
@@ -43,7 +43,6 @@

mod canonical_request;
mod error;
mod query_writer;
mod settings;
mod sign;
mod uri_path_normalization;
+1 −1
Original line number Diff line number Diff line
@@ -8,10 +8,10 @@ use super::{PayloadChecksumKind, SignatureLocation};
use crate::http_request::canonical_request::header;
use crate::http_request::canonical_request::param;
use crate::http_request::canonical_request::{CanonicalRequest, StringToSign, HMAC_256};
use crate::http_request::query_writer::QueryWriter;
use crate::http_request::SigningParams;
use crate::sign::{calculate_signature, generate_signing_key, sha256_hex_string};
use crate::SigningOutput;
use aws_smithy_http::query_writer::QueryWriter;
use http::header::HeaderValue;
use http::{HeaderMap, Method, Uri};
use std::borrow::Cow;
+1 −5
Original line number Diff line number Diff line
@@ -3,11 +3,7 @@
 * SPDX-License-Identifier: Apache-2.0
 */

use aws_smithy_http::{label, query};

pub(super) fn percent_encode_query(value: &str) -> String {
    query::fmt_string(value)
}
use aws_smithy_http::label;

pub(super) fn percent_encode_path(value: &str) -> String {
    label::fmt_string(value, label::EncodingStrategy::Greedy)
+1 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ object CrateSet {
        "aws-smithy-checksums",
        "aws-smithy-eventstream",
        "aws-smithy-http",
        "aws-smithy-http-auth",
        "aws-smithy-http-tower",
        "aws-smithy-json",
        "aws-smithy-protocol-test",
Loading