Skip to main content

aws_sdk_sts/operation/get_web_identity_token/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::get_web_identity_token::_get_web_identity_token_input::GetWebIdentityTokenInputBuilder;
3
4pub use crate::operation::get_web_identity_token::_get_web_identity_token_output::GetWebIdentityTokenOutputBuilder;
5
6impl crate::operation::get_web_identity_token::builders::GetWebIdentityTokenInputBuilder {
7    /// Sends a request with this input using the given client.
8    pub async fn send_with(
9        self,
10        client: &crate::Client,
11    ) -> ::std::result::Result<
12        crate::operation::get_web_identity_token::GetWebIdentityTokenOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::get_web_identity_token::GetWebIdentityTokenError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.get_web_identity_token();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `GetWebIdentityToken`.
24///
25/// <p>Returns a signed JSON Web Token (JWT) that represents the calling Amazon Web Services identity or, if you set <code>SubjectMode</code> to <code>OriginIdentity</code>, the human user or workload on whose behalf the calling session acts. The returned JWT can be used to authenticate with external services that support OIDC discovery. The token is signed by Amazon Web Services STS and can be publicly verified using the verification keys published at the issuer's JWKS endpoint.</p>
26/// <p>The <code>sub</code> (subject) claim contains the identity that <code>SubjectMode</code> selects. Whichever subject mode you use, the <code>principal_id</code> claim under the <code>https://sts.amazonaws.com/</code> namespace contains the ARN of the principal that requested the token, when that principal has an ARN. For a role session, this is the ARN of the role.</p><note>
27/// <p>The <code>GetWebIdentityToken</code> API is not available on the STS Global endpoint.</p>
28/// </note>
29#[derive(::std::clone::Clone, ::std::fmt::Debug)]
30pub struct GetWebIdentityTokenFluentBuilder {
31    handle: ::std::sync::Arc<crate::client::Handle>,
32    inner: crate::operation::get_web_identity_token::builders::GetWebIdentityTokenInputBuilder,
33    config_override: ::std::option::Option<crate::config::Builder>,
34}
35impl
36    crate::client::customize::internal::CustomizableSend<
37        crate::operation::get_web_identity_token::GetWebIdentityTokenOutput,
38        crate::operation::get_web_identity_token::GetWebIdentityTokenError,
39    > for GetWebIdentityTokenFluentBuilder
40{
41    fn send(
42        self,
43        config_override: crate::config::Builder,
44    ) -> crate::client::customize::internal::BoxFuture<
45        crate::client::customize::internal::SendResult<
46            crate::operation::get_web_identity_token::GetWebIdentityTokenOutput,
47            crate::operation::get_web_identity_token::GetWebIdentityTokenError,
48        >,
49    > {
50        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
51    }
52}
53impl GetWebIdentityTokenFluentBuilder {
54    /// Creates a new `GetWebIdentityTokenFluentBuilder`.
55    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
56        Self {
57            handle,
58            inner: ::std::default::Default::default(),
59            config_override: ::std::option::Option::None,
60        }
61    }
62    /// Access the GetWebIdentityToken as a reference.
63    pub fn as_input(&self) -> &crate::operation::get_web_identity_token::builders::GetWebIdentityTokenInputBuilder {
64        &self.inner
65    }
66    /// Sends the request and returns the response.
67    ///
68    /// If an error occurs, an `SdkError` will be returned with additional details that
69    /// can be matched against.
70    ///
71    /// By default, any retryable failures will be retried twice. Retry behavior
72    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
73    /// set when configuring the client.
74    pub async fn send(
75        self,
76    ) -> ::std::result::Result<
77        crate::operation::get_web_identity_token::GetWebIdentityTokenOutput,
78        ::aws_smithy_runtime_api::client::result::SdkError<
79            crate::operation::get_web_identity_token::GetWebIdentityTokenError,
80            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
81        >,
82    > {
83        let input = self
84            .inner
85            .build()
86            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
87        let runtime_plugins = crate::operation::get_web_identity_token::GetWebIdentityToken::operation_runtime_plugins(
88            self.handle.runtime_plugins.clone(),
89            &self.handle.conf,
90            self.config_override,
91        );
92        crate::operation::get_web_identity_token::GetWebIdentityToken::orchestrate(&runtime_plugins, input).await
93    }
94
95    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
96    pub fn customize(
97        self,
98    ) -> crate::client::customize::CustomizableOperation<
99        crate::operation::get_web_identity_token::GetWebIdentityTokenOutput,
100        crate::operation::get_web_identity_token::GetWebIdentityTokenError,
101        Self,
102    > {
103        crate::client::customize::CustomizableOperation::new(self)
104    }
105    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
106        self.set_config_override(::std::option::Option::Some(config_override.into()));
107        self
108    }
109
110    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
111        self.config_override = config_override;
112        self
113    }
114    ///
115    /// Appends an item to `Audience`.
116    ///
117    /// To override the contents of this collection use [`set_audience`](Self::set_audience).
118    ///
119    /// <p>The intended recipient of the web identity token. This value populates the <code>aud</code> claim in the JWT and should identify the service or application that will validate and use the token. The external service should verify this claim to ensure the token was intended for their use.</p>
120    pub fn audience(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
121        self.inner = self.inner.audience(input.into());
122        self
123    }
124    /// <p>The intended recipient of the web identity token. This value populates the <code>aud</code> claim in the JWT and should identify the service or application that will validate and use the token. The external service should verify this claim to ensure the token was intended for their use.</p>
125    pub fn set_audience(mut self, input: ::std::option::Option<::std::vec::Vec<::std::string::String>>) -> Self {
126        self.inner = self.inner.set_audience(input);
127        self
128    }
129    /// <p>The intended recipient of the web identity token. This value populates the <code>aud</code> claim in the JWT and should identify the service or application that will validate and use the token. The external service should verify this claim to ensure the token was intended for their use.</p>
130    pub fn get_audience(&self) -> &::std::option::Option<::std::vec::Vec<::std::string::String>> {
131        self.inner.get_audience()
132    }
133    /// <p>The duration, in seconds, for which the JSON Web Token (JWT) will remain valid. The value can range from 60 seconds (1 minute) to 3600 seconds (1 hour). If not specified, the default duration is 300 seconds (5 minutes). The token is designed to be short-lived and should be used for proof of identity, then exchanged for credentials or short-lived tokens in the external service.</p>
134    pub fn duration_seconds(mut self, input: i32) -> Self {
135        self.inner = self.inner.duration_seconds(input);
136        self
137    }
138    /// <p>The duration, in seconds, for which the JSON Web Token (JWT) will remain valid. The value can range from 60 seconds (1 minute) to 3600 seconds (1 hour). If not specified, the default duration is 300 seconds (5 minutes). The token is designed to be short-lived and should be used for proof of identity, then exchanged for credentials or short-lived tokens in the external service.</p>
139    pub fn set_duration_seconds(mut self, input: ::std::option::Option<i32>) -> Self {
140        self.inner = self.inner.set_duration_seconds(input);
141        self
142    }
143    /// <p>The duration, in seconds, for which the JSON Web Token (JWT) will remain valid. The value can range from 60 seconds (1 minute) to 3600 seconds (1 hour). If not specified, the default duration is 300 seconds (5 minutes). The token is designed to be short-lived and should be used for proof of identity, then exchanged for credentials or short-lived tokens in the external service.</p>
144    pub fn get_duration_seconds(&self) -> &::std::option::Option<i32> {
145        self.inner.get_duration_seconds()
146    }
147    /// <p>The cryptographic algorithm to use for signing the JSON Web Token (JWT). Valid values are RS256 (RSA with SHA-256) and ES384 (ECDSA using P-384 curve with SHA-384).</p>
148    pub fn signing_algorithm(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
149        self.inner = self.inner.signing_algorithm(input.into());
150        self
151    }
152    /// <p>The cryptographic algorithm to use for signing the JSON Web Token (JWT). Valid values are RS256 (RSA with SHA-256) and ES384 (ECDSA using P-384 curve with SHA-384).</p>
153    pub fn set_signing_algorithm(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
154        self.inner = self.inner.set_signing_algorithm(input);
155        self
156    }
157    /// <p>The cryptographic algorithm to use for signing the JSON Web Token (JWT). Valid values are RS256 (RSA with SHA-256) and ES384 (ECDSA using P-384 curve with SHA-384).</p>
158    pub fn get_signing_algorithm(&self) -> &::std::option::Option<::std::string::String> {
159        self.inner.get_signing_algorithm()
160    }
161    /// <p>One or more OAuth 2.0 scope values to include in the JSON Web Token (JWT). Amazon Web Services STS copies the value exactly as you send it into the top-level <code>scope</code> claim of the token. If you don't specify <code>Scope</code>, the token doesn't include a <code>scope</code> claim.</p>
162    /// <p>Separate multiple values with a single space, as defined in <a href="https://www.rfc-editor.org/rfc/rfc6749#section-3.3">RFC 6749, section 3.3</a> on the IETF website. Don't begin or end <code>Scope</code> with a space. Each scope value can contain printable ASCII characters except spaces, double quotation marks (<code>"</code>), commas (<code>,</code>), and backslashes (<code>\</code>).</p>
163    /// <p>You can't repeat a scope value. Scope values are case sensitive. This means that <code>read</code> and <code>READ</code> are separate values.</p>
164    /// <p>You can specify <code>Scope</code> only when <code>SubjectMode</code> is <code>OriginIdentity</code> and you request exactly one audience. To specify <code>Scope</code>, the calling principal must have permission for the <code>sts:SetWebIdentityTokenScope</code> action in addition to <code>sts:GetWebIdentityToken</code>. You can use the multivalued <code>sts:IdentityTokenScope</code> condition key in a policy to control which scope values a principal can request.</p>
165    pub fn scope(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
166        self.inner = self.inner.scope(input.into());
167        self
168    }
169    /// <p>One or more OAuth 2.0 scope values to include in the JSON Web Token (JWT). Amazon Web Services STS copies the value exactly as you send it into the top-level <code>scope</code> claim of the token. If you don't specify <code>Scope</code>, the token doesn't include a <code>scope</code> claim.</p>
170    /// <p>Separate multiple values with a single space, as defined in <a href="https://www.rfc-editor.org/rfc/rfc6749#section-3.3">RFC 6749, section 3.3</a> on the IETF website. Don't begin or end <code>Scope</code> with a space. Each scope value can contain printable ASCII characters except spaces, double quotation marks (<code>"</code>), commas (<code>,</code>), and backslashes (<code>\</code>).</p>
171    /// <p>You can't repeat a scope value. Scope values are case sensitive. This means that <code>read</code> and <code>READ</code> are separate values.</p>
172    /// <p>You can specify <code>Scope</code> only when <code>SubjectMode</code> is <code>OriginIdentity</code> and you request exactly one audience. To specify <code>Scope</code>, the calling principal must have permission for the <code>sts:SetWebIdentityTokenScope</code> action in addition to <code>sts:GetWebIdentityToken</code>. You can use the multivalued <code>sts:IdentityTokenScope</code> condition key in a policy to control which scope values a principal can request.</p>
173    pub fn set_scope(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
174        self.inner = self.inner.set_scope(input);
175        self
176    }
177    /// <p>One or more OAuth 2.0 scope values to include in the JSON Web Token (JWT). Amazon Web Services STS copies the value exactly as you send it into the top-level <code>scope</code> claim of the token. If you don't specify <code>Scope</code>, the token doesn't include a <code>scope</code> claim.</p>
178    /// <p>Separate multiple values with a single space, as defined in <a href="https://www.rfc-editor.org/rfc/rfc6749#section-3.3">RFC 6749, section 3.3</a> on the IETF website. Don't begin or end <code>Scope</code> with a space. Each scope value can contain printable ASCII characters except spaces, double quotation marks (<code>"</code>), commas (<code>,</code>), and backslashes (<code>\</code>).</p>
179    /// <p>You can't repeat a scope value. Scope values are case sensitive. This means that <code>read</code> and <code>READ</code> are separate values.</p>
180    /// <p>You can specify <code>Scope</code> only when <code>SubjectMode</code> is <code>OriginIdentity</code> and you request exactly one audience. To specify <code>Scope</code>, the calling principal must have permission for the <code>sts:SetWebIdentityTokenScope</code> action in addition to <code>sts:GetWebIdentityToken</code>. You can use the multivalued <code>sts:IdentityTokenScope</code> condition key in a policy to control which scope values a principal can request.</p>
181    pub fn get_scope(&self) -> &::std::option::Option<::std::string::String> {
182        self.inner.get_scope()
183    }
184    /// <p>Specifies which identity STS puts in the <code>sub</code> (subject) claim of the JSON Web Token (JWT). Valid values are <code>AWSIdentity</code> and <code>OriginIdentity</code>. If you don't specify a value, Amazon Web Services STS uses <code>AWSIdentity</code>.</p>
185    /// <ul>
186    /// <li>
187    /// <p><code>AWSIdentity</code> – The <code>sub</code> claim contains the ARN of the calling Amazon Web Services principal.</p></li>
188    /// <li>
189    /// <p><code>OriginIdentity</code> – The <code>sub</code> claim contains the value of the <code>aws:OriginIdentity/Subject</code> key in the trusted identity propagation context of the calling session. For example, this can identify the human user or workload on whose behalf the calling session acts. Amazon Web Services STS also adds a <code>subject_mode</code> claim to the token.</p>
190    /// <p>To use <code>OriginIdentity</code>, the trusted identity propagation context of the calling session must contain the <code>aws:OriginIdentity/Subject</code> key and either the <code>aws:OriginIdentity/Issuer</code> key or the <code>aws:OriginIdentity/FederatedProviderArn</code> key. If it doesn't, or if the subject is blank, Amazon Web Services STS rejects the request with a validation error.</p>
191    /// <p>Amazon Web Services STS denies the request if the subject begins with the text <code>arn:</code>, in any combination of uppercase and lowercase letters. Amazon Web Services STS also denies the request if the subject begins or ends with a space, or contains a control, format, or separator character other than a space.</p></li>
192    /// </ul>
193    /// <p>You can use the <code>sts:SubjectMode</code> condition key in a policy to control which subject modes a principal can request.</p>
194    pub fn subject_mode(mut self, input: crate::types::WebIdentityTokenSubjectModeType) -> Self {
195        self.inner = self.inner.subject_mode(input);
196        self
197    }
198    /// <p>Specifies which identity STS puts in the <code>sub</code> (subject) claim of the JSON Web Token (JWT). Valid values are <code>AWSIdentity</code> and <code>OriginIdentity</code>. If you don't specify a value, Amazon Web Services STS uses <code>AWSIdentity</code>.</p>
199    /// <ul>
200    /// <li>
201    /// <p><code>AWSIdentity</code> – The <code>sub</code> claim contains the ARN of the calling Amazon Web Services principal.</p></li>
202    /// <li>
203    /// <p><code>OriginIdentity</code> – The <code>sub</code> claim contains the value of the <code>aws:OriginIdentity/Subject</code> key in the trusted identity propagation context of the calling session. For example, this can identify the human user or workload on whose behalf the calling session acts. Amazon Web Services STS also adds a <code>subject_mode</code> claim to the token.</p>
204    /// <p>To use <code>OriginIdentity</code>, the trusted identity propagation context of the calling session must contain the <code>aws:OriginIdentity/Subject</code> key and either the <code>aws:OriginIdentity/Issuer</code> key or the <code>aws:OriginIdentity/FederatedProviderArn</code> key. If it doesn't, or if the subject is blank, Amazon Web Services STS rejects the request with a validation error.</p>
205    /// <p>Amazon Web Services STS denies the request if the subject begins with the text <code>arn:</code>, in any combination of uppercase and lowercase letters. Amazon Web Services STS also denies the request if the subject begins or ends with a space, or contains a control, format, or separator character other than a space.</p></li>
206    /// </ul>
207    /// <p>You can use the <code>sts:SubjectMode</code> condition key in a policy to control which subject modes a principal can request.</p>
208    pub fn set_subject_mode(mut self, input: ::std::option::Option<crate::types::WebIdentityTokenSubjectModeType>) -> Self {
209        self.inner = self.inner.set_subject_mode(input);
210        self
211    }
212    /// <p>Specifies which identity STS puts in the <code>sub</code> (subject) claim of the JSON Web Token (JWT). Valid values are <code>AWSIdentity</code> and <code>OriginIdentity</code>. If you don't specify a value, Amazon Web Services STS uses <code>AWSIdentity</code>.</p>
213    /// <ul>
214    /// <li>
215    /// <p><code>AWSIdentity</code> – The <code>sub</code> claim contains the ARN of the calling Amazon Web Services principal.</p></li>
216    /// <li>
217    /// <p><code>OriginIdentity</code> – The <code>sub</code> claim contains the value of the <code>aws:OriginIdentity/Subject</code> key in the trusted identity propagation context of the calling session. For example, this can identify the human user or workload on whose behalf the calling session acts. Amazon Web Services STS also adds a <code>subject_mode</code> claim to the token.</p>
218    /// <p>To use <code>OriginIdentity</code>, the trusted identity propagation context of the calling session must contain the <code>aws:OriginIdentity/Subject</code> key and either the <code>aws:OriginIdentity/Issuer</code> key or the <code>aws:OriginIdentity/FederatedProviderArn</code> key. If it doesn't, or if the subject is blank, Amazon Web Services STS rejects the request with a validation error.</p>
219    /// <p>Amazon Web Services STS denies the request if the subject begins with the text <code>arn:</code>, in any combination of uppercase and lowercase letters. Amazon Web Services STS also denies the request if the subject begins or ends with a space, or contains a control, format, or separator character other than a space.</p></li>
220    /// </ul>
221    /// <p>You can use the <code>sts:SubjectMode</code> condition key in a policy to control which subject modes a principal can request.</p>
222    pub fn get_subject_mode(&self) -> &::std::option::Option<crate::types::WebIdentityTokenSubjectModeType> {
223        self.inner.get_subject_mode()
224    }
225    ///
226    /// Appends an item to `Tags`.
227    ///
228    /// To override the contents of this collection use [`set_tags`](Self::set_tags).
229    ///
230    /// <p>An optional list of tags to include in the JSON Web Token (JWT). These tags are added as custom claims to the JWT and can be used by the downstream service for authorization decisions.</p>
231    pub fn tags(mut self, input: crate::types::Tag) -> Self {
232        self.inner = self.inner.tags(input);
233        self
234    }
235    /// <p>An optional list of tags to include in the JSON Web Token (JWT). These tags are added as custom claims to the JWT and can be used by the downstream service for authorization decisions.</p>
236    pub fn set_tags(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::Tag>>) -> Self {
237        self.inner = self.inner.set_tags(input);
238        self
239    }
240    /// <p>An optional list of tags to include in the JSON Web Token (JWT). These tags are added as custom claims to the JWT and can be used by the downstream service for authorization decisions.</p>
241    pub fn get_tags(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::Tag>> {
242        self.inner.get_tags()
243    }
244}