Skip to main content

reqsign_aws_core/
constants.rs

1// Licensed to the Apache Software Foundation (ASF) under one
2// or more contributor license agreements.  See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership.  The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License.  You may obtain a copy of the License at
8//
9//   http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied.  See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18use percent_encoding::AsciiSet;
19use percent_encoding::NON_ALPHANUMERIC;
20
21// Headers used in aws services.
22pub const X_AMZ_CONTENT_SHA_256: &str = "x-amz-content-sha256";
23pub const X_AMZ_DATE: &str = "x-amz-date";
24pub const X_AMZ_SECURITY_TOKEN: &str = "x-amz-security-token";
25pub const X_AMZ_S3_SESSION_TOKEN: &str = "x-amz-s3session-token";
26
27// Env values used in aws services.
28pub const AWS_ACCESS_KEY_ID: &str = "AWS_ACCESS_KEY_ID";
29pub const AWS_SECRET_ACCESS_KEY: &str = "AWS_SECRET_ACCESS_KEY";
30pub const AWS_SESSION_TOKEN: &str = "AWS_SESSION_TOKEN";
31#[cfg(not(target_arch = "wasm32"))]
32pub const AWS_PROFILE: &str = "AWS_PROFILE";
33#[cfg(not(target_arch = "wasm32"))]
34pub const AWS_CONFIG_FILE: &str = "AWS_CONFIG_FILE";
35#[cfg(not(target_arch = "wasm32"))]
36pub const AWS_SHARED_CREDENTIALS_FILE: &str = "AWS_SHARED_CREDENTIALS_FILE";
37
38/// AsciiSet for [AWS UriEncode](https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html)
39///
40/// - URI encode every byte except the unreserved characters: 'A'-'Z', 'a'-'z', '0'-'9', '-', '.', '_', and '~'.
41pub static AWS_URI_ENCODE_SET: AsciiSet = NON_ALPHANUMERIC
42    .remove(b'-')
43    .remove(b'.')
44    .remove(b'_')
45    .remove(b'~');
46
47/// AsciiSet for [AWS UriEncode](https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html)
48///
49/// But used in query.
50pub static AWS_QUERY_ENCODE_SET: AsciiSet = NON_ALPHANUMERIC
51    .remove(b'-')
52    .remove(b'.')
53    .remove(b'_')
54    .remove(b'~');