forked from archiecobbs/s3backer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy paths3b_http_io.h
88 lines (72 loc) · 3.68 KB
/
s3b_http_io.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
* cloudbacker - FUSE-based single file backing store
*
* Copyright 2008-2011 Archie L. Cobbs <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef S3B_HTTP_IO_H
#define S3B_HTTP_IO_H
#include "http_gio.h"
/* S3 base URL / Host */
#define S3_DOMAIN "amazonaws.com" /* S3 URL */
/* Authentication types */
#define AUTH_VERSION_AWS2 "aws2"
#define AUTH_VERSION_AWS4 "aws4"
/* S3 access permission strings */
#define S3_ACCESS_PRIVATE "private"
#define S3_ACCESS_PUBLIC_READ "public-read"
#define S3_ACCESS_PUBLIC_READ_WRITE "public-read-write"
#define S3_ACCESS_AUTHENTICATED_READ "authenticated-read"
/* s3 - Default values for some configuration parameters */
#define S3BACKER_DEFAULT_ACCESS_TYPE S3_ACCESS_PRIVATE
#define S3BACKER_DEFAULT_AUTH_VERSION AUTH_VERSION_AWS4
#define S3BACKER_DEFAULT_REGION "us-east-1"
/* S3-specific HTTP definitions */
#define S3B_FILE_SIZE_HEADER "x-amz-meta-s3backer-filesize"
#define S3B_BLOCK_SIZE_HEADER "x-amz-meta-s3backer-blocksize"
#define S3B_COMPRESSION_LEVEL_HEADER "x-amz-meta-s3backer-compresson-level"
#define S3B_ENCRYPTED_HEADER "x-amz-meta-s3backer-encrypted"
#define S3B_ENCRYPTION_HEADER "x-amz-meta-s3backer-encryption-cipher"
#define S3B_NAME_HASH_HEADER "x-amz-meta-s3backer-namehash"
#define S3B_HMAC_HEADER "x-amz-meta-s3backer-hmac"
#define S3B_ACL_HEADER "x-amz-acl"
#define S3B_CONTENT_SHA256_HEADER "x-amz-content-sha256"
#define S3B_STORAGE_CLASS_HEADER "x-amz-storage-class"
/* AWS 4 `Date' and `x-amz-date' header formats */
#define AWS_DATE_HEADER "x-amz-date"
#define AWS_DATE_BUF_FMT "%Y%m%dT%H%M%SZ"
/* AWS signature */
#define S3B_SIGNATURE_ALGORITHM "AWS4-HMAC-SHA256"
#define S3B_ACCESS_KEY_PREFIX "AWS4"
#define S3B_SERVICE_NAME "s3"
#define S3B_SIGNATURE_TERMINATOR "aws4_request"
#define S3B_SECURITY_TOKEN_HEADER "x-amz-security-token"
/* EC2 IAM info URL */
#define S3B_EC2_IAM_META_DATA_URLBASE "http://169.254.169.254/latest/meta-data/iam/security-credentials/"
#define S3B_EC2_IAM_META_DATA_ACCESSID "AccessKeyId"
#define S3B_EC2_IAM_META_DATA_ACCESSKEY "SecretAccessKey"
#define S3B_EC2_IAM_META_DATA_TOKEN "Token"
/* EC2 IAM thread */
int update_iam_credentials(struct http_io_private *priv);
/* Authentication functions */
int http_io_add_auth2(struct http_io_private *priv, struct http_io *io, time_t now, const void *payload, size_t plen);
int http_io_add_auth4(struct http_io_private *priv, struct http_io *io, time_t now, const void *payload, size_t plen);
/* S3 specific functions */
void set_http_io_s3b_params(struct http_io_conf *config);
void http_io_s3_destroy(struct http_io_private *const priv);
int http_io_s3b_bucket_attributes(struct cloudbacker_store *cb, void *arg);
#endif