28 28 | &'a self,
|
29 29 | params: &'a ::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams,
|
30 30 | cfg: &'a ::aws_smithy_types::config_bag::ConfigBag,
|
31 31 | runtime_components: &'a ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponents,
|
32 32 | ) -> ::aws_smithy_runtime_api::client::auth::AuthSchemeOptionsFuture<'a> {
|
33 33 | match params.get::<crate::config::auth::Params>() {
|
34 34 | ::std::option::Option::Some(concrete_params) => self.0.resolve_auth_scheme(concrete_params, cfg, runtime_components),
|
35 35 | ::std::option::Option::None => ::aws_smithy_runtime_api::client::auth::AuthSchemeOptionsFuture::ready(::std::result::Result::Err(
|
36 36 | "params of expected type was not present".into(),
|
37 37 | )),
|
38 38 | }
|
39 39 | }
|
40 40 | }
|
41 41 |
|
42 42 | /// The default auth scheme resolver
|
43 43 | #[derive(Debug)]
|
44 44 | #[allow(dead_code)]
|
45 45 | pub struct DefaultAuthSchemeResolver {
|
46 46 | service_defaults: Vec<::aws_smithy_runtime_api::client::auth::AuthSchemeOption>,
|
47 47 | operation_overrides: ::std::collections::HashMap<&'static str, Vec<::aws_smithy_runtime_api::client::auth::AuthSchemeOption>>,
|
48 48 | }
|
49 49 |
|
50 50 | // TODO(https://github.com/smithy-lang/smithy-rs/issues/4177): Remove `allow(...)` once the issue is addressed.
|
51 51 | // When generating code for tests (e.g., `codegen-client-test`), this manual implementation
|
52 52 | // of the `Default` trait may appear as if it could be derived automatically.
|
53 53 | // However, that is not the case in production.
|
54 54 | #[allow(clippy::derivable_impls)]
|
55 55 | impl Default for DefaultAuthSchemeResolver {
|
56 56 | fn default() -> Self {
|
57 57 | Self {
|
58 - | service_defaults: vec![::aws_smithy_runtime_api::client::auth::AuthSchemeOption::from(
|
59 - | ::aws_smithy_runtime::client::auth::no_auth::NO_AUTH_SCHEME_ID,
|
60 - | )],
|
58 + | service_defaults: vec![],
|
61 59 | operation_overrides: ::std::collections::HashMap::new(),
|
62 60 | }
|
63 61 | }
|
64 62 | }
|
65 63 |
|
66 64 | impl crate::config::auth::ResolveAuthScheme for DefaultAuthSchemeResolver {
|
67 65 | fn resolve_auth_scheme<'a>(
|
68 66 | &'a self,
|
69 67 | params: &'a crate::config::auth::Params,
|
70 68 | _cfg: &'a ::aws_smithy_types::config_bag::ConfigBag,
|
71 69 | _runtime_components: &'a ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponents,
|
72 70 | ) -> ::aws_smithy_runtime_api::client::auth::AuthSchemeOptionsFuture<'a> {
|
73 71 | let operation_name = params.operation_name();
|
74 72 |
|
75 73 | let modeled_auth_options = match self.operation_overrides.get(operation_name) {
|
76 74 | Some(overrides) => overrides,
|
77 75 | None => &self.service_defaults,
|
78 76 | };
|
79 77 |
|
80 78 | let _fut = ::aws_smithy_runtime_api::client::auth::AuthSchemeOptionsFuture::ready(Ok(modeled_auth_options.clone()));
|
81 79 |
|
82 80 | _fut
|
83 81 | }
|
84 82 | }
|
85 83 |
|
86 84 | /// Configuration parameters for resolving the correct auth scheme
|
87 85 | #[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
|
88 86 | pub struct Params {
|
89 87 | operation_name: ::std::borrow::Cow<'static, str>,
|
90 88 | }
|