Skip to content

Commit d505e92

Browse files
authored
Add documentation for V4 Signature Post Policy (#40)
1 parent 424c1dd commit d505e92

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed

storage/v1/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Storage Conformance Tests
2+
3+
Collection of conformance tests to exercise Storage library V4 Signatures support.
4+
5+
# Verify Proto Unmarshable Conformance Tests
6+
7+
Read [validator documentation](../conformance-tests/README.md#validator)
8+
in the parent README.md.
9+
10+
# Conformance Tests Design
11+
12+
Review [tests.proto](proto/google/cloud/conformance/storage/v1/tests.proto)

storage/v1/proto/google/cloud/conformance/storage/v1/tests.proto

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,95 @@ message PolicyConditions {
6060
repeated string startsWith = 2;
6161
}
6262

63+
// Specification documentation is located at:
64+
// https://cloud.google.com/storage/docs/authentication/signatures
65+
6366
message PolicyInput {
67+
// http or https
6468
string scheme = 1;
6569
UrlStyle urlStyle = 2;
6670
string bucketBoundHostname = 3;
6771
string bucket = 4;
6872
string object = 5;
6973
int32 expiration = 6;
7074
google.protobuf.Timestamp timestamp = 7;
75+
/*
76+
fields with strict equivalence which are added into
77+
PolicyOutput.expectedDecodedPolicy to generate the
78+
signature.
79+
80+
Expectations
81+
82+
E.1: Order them in lexigraphical order so it's the
83+
signature can be verified across different language
84+
implementations.
85+
86+
*/
7187
map<string, string> fields = 8;
7288
PolicyConditions conditions = 9;
7389
}
7490

7591
message PolicyOutput {
7692
string url = 1;
7793
map<string, string> fields = 2;
94+
/*
95+
Expectations
96+
97+
E.1: PolicyInput.fields must be prepended to form expectedDecodedPolicy
98+
for consistent result across languages. Ordering doesn't matter to the
99+
service but the decision is made to make it easier to conform implementations
100+
in implementation.
101+
102+
Example:
103+
104+
# Step 1
105+
106+
PolicyInput.fields has:
107+
{
108+
"content-disposition":"attachment; filename=\"~._-%=/é0Aa\"",
109+
"content-encoding":"gzip",
110+
"content-type":"text/plain",
111+
"success_action_redirect":"http://www.google.com/"
112+
}
113+
114+
# Step 2
115+
116+
The expectedDecodedPolicy before prepending the PolicyInput.fields
117+
would look like this:
118+
119+
{
120+
"conditions":[
121+
...prepend here in the same order provided in PolicyInput.fields...
122+
{"bucket":"bucket-name"},
123+
{"key":"test-object"},
124+
{"x-goog-date":"20200123T043530Z"},
125+
{"x-goog-credential":"test-iam-credentials@dummy-project-id.iam.gserviceaccount.com/20200123/auto/storage/goog4_request"},
126+
{"x-goog-algorithm":"GOOG4-RSA-SHA256"}
127+
],
128+
"expiration":"2020-01-23T04:35:40Z"
129+
}
130+
131+
# Step 3
132+
133+
Then expectedDecodedPolicy should prepends PolicyInput.fields in
134+
the same order to PolicyOutput.expectedDecodedPolicy `conditions` key.
135+
136+
{
137+
"conditions":[
138+
{"content-disposition":"attachment; filename=\"~._-%=/é0Aa\""},
139+
{"content-encoding":"gzip"},
140+
{"content-type":"text/plain"},
141+
{"success_action_redirect":"http://www.google.com/"},
142+
{"bucket":"bucket-name"},
143+
{"key":"test-object"},
144+
{"x-goog-date":"20200123T043530Z"},
145+
{"x-goog-credential":"test-iam-credentials@dummy-project-id.iam.gserviceaccount.com/20200123/auto/storage/goog4_request"},
146+
{"x-goog-algorithm":"GOOG4-RSA-SHA256"}
147+
],
148+
"expiration":"2020-01-23T04:35:40Z"
149+
}
150+
*/
151+
78152
string expectedDecodedPolicy = 3;
79153
}
80154

0 commit comments

Comments
 (0)