Skip to content

Commit db735ce

Browse files
author
Inflatablewoman
committed
Transferring blueprint from apiary.io
1 parent d4cc788 commit db735ce

File tree

1 file changed

+61
-1
lines changed

1 file changed

+61
-1
lines changed

apiary.apib

+61-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,61 @@ FORMAT: 1A
33
# Blocker API
44
A block based filesystem microservice written in go
55

6+
# Group API Authentication
7+
All requests must contain an 'Auth Token'.
8+
9+
##Authorization
10+
11+
Authorization is done via a *Authorization* header sent in a request. Anonymous requests are not allowed. To authenticate a request, you must sign the request with the shared key when making the request and pass that signature as part of the request.
12+
13+
Here you can see an example of a Authorization header
14+
```
15+
Authorization=RvPtP0QB7iIun1ehwheD4YUo7+fYfw7/ywl+HsC5Ddk=
16+
```
17+
18+
You construct the signature is built in the following format:
19+
20+
```
21+
authRequestSig = method + "\n" +
22+
Date + "\n" +
23+
resource
24+
```
25+
26+
This would result in the following signature to be signed:
27+
28+
```
29+
COPY\nWed, 28 Jan 2015 10:42:13 UTC\n/api/v1/blocker/6f90d707-3b6a-4321-b32c-3c1d37915c1b
30+
```
31+
32+
Note that you MUST past the same date value in the request. Date should be supplied in UTC using RFC1123 format.
33+
34+
```
35+
x-blocker-date=Wed, 28 Jan 2015 10:42:13 UTC
36+
```
37+
38+
The signature must be exactly in the same order and include the new line character.
39+
40+
Now encode the signature using the [HMAC-SHA256](http://en.wikipedia.org/wiki/Hash-based_message_authentication_code) algorithm using the shared key.
41+
42+
This will result in a key like this:
43+
```
44+
RvPtP0QB7iIun1ehwheD4YUo7+fYfw7/ywl+HsC5Ddk="
45+
```
46+
47+
Example go code to create the signature
48+
49+
```go
50+
date := time.Now().UTC().Format(time.RFC1123) // UTC time
51+
request.Header.Add("x-blocker-date", date)
52+
53+
authRequestKey := fmt.Sprintf("%s\n%s\n%s", method, date, resource)
54+
55+
// See package http://golang.org/pkg/crypto/hmac/ on how golang creates hmacs
56+
hmac := crypto.GetHmac256(authRequestKey, SharedKey)
57+
58+
request.Header.Add("Authorization", hmac)
59+
```
60+
661
# Group Blocker
762
Blocker related resources of the **Blocker API**
863

@@ -14,6 +69,7 @@ This is usually done via a form.
1469
+ Header
1570

1671
Authorization: RvPtP0QB7iIun1ehwheD4YUo7+fYfw7/ywl+HsC5Ddk=
72+
x-blocker-date: Wed, 28 Jan 2015 10:42:13 UTC
1773
Content-type: content-type
1874

1975
+ Body
@@ -31,6 +87,7 @@ Typically a raw upload
3187
+ Header
3288

3389
Authorization: RvPtP0QB7iIun1ehwheD4YUo7+fYfw7/ywl+HsC5Ddk=
90+
x-blocker-date: Wed, 28 Jan 2015 10:42:13 UTC
3491
Content-type: content-type
3592

3693
+ Body
@@ -73,7 +130,8 @@ Get a specific BlockFile.
73130
+ Request
74131
+ Header
75132

76-
Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...
133+
Authorization: RvPtP0QB7iIun1ehwheD4YUo7+fYfw7/ywl+HsC5Ddk=
134+
x-blocker-date: Wed, 28 Jan 2015 10:42:13 UTC
77135

78136
+ Response 200 (application/json)
79137

@@ -86,6 +144,7 @@ Copy a BlockedFile. The returned BlockedFile is the new BlockedFile.
86144
+ Header
87145

88146
Authorization: RvPtP0QB7iIun1ehwheD4YUo7+fYfw7/ywl+HsC5Ddk=
147+
x-blocker-date: Wed, 28 Jan 2015 10:42:13 UTC
89148

90149
+ Response 200 (application/json)
91150

@@ -99,5 +158,6 @@ Delete a BlockedFile.
99158
+ Header
100159

101160
Authorization: RvPtP0QB7iIun1ehwheD4YUo7+fYfw7/ywl+HsC5Ddk=
161+
x-blocker-date: Wed, 28 Jan 2015 10:42:13 UTC
102162

103163
+ Response 204

0 commit comments

Comments
 (0)