Skip to content

Commit 0fc9236

Browse files
author
Hubot
committed
Sync changes from upstream repository
1 parent e241cfb commit 0fc9236

9 files changed

Lines changed: 251 additions & 1 deletion

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
title: Preview support for Git signing
3+
author_name: mastahyeti
4+
---
5+
6+
GitHub [recently started verifying GPG signed commits and tags](https://github.com/blog/2144-gpg-signature-verification). We are adding API support for signature verification and user GPG key management as well. You can enable these changes during the preview period by providing a custom [media type][media-type] in the `Accept` header:
7+
8+
application/vnd.github.cryptographer-preview
9+
10+
For example:
11+
12+
``` command-line
13+
curl "https://api.github.com/user/gpg_keys" \
14+
-H 'Authorization: token TOKEN' \
15+
-H "Accept: application/vnd.github.cryptographer-preview" \
16+
```
17+
18+
You can learn more about the new signature verification response objects in the updated [repository commit][repo-commit-doc], [Git commit][git-commit-doc], and [Git tag][git-tag-doc] documentation. There is also new [GPG key management][gpg-keys-doc] documentation.
19+
20+
During the preview period, we may change aspects of these APIs based on developer feedback. We will announce the changes here on the developer blog, but we will not provide advance notice.
21+
22+
If you have any questions or feedback, please [let us know][contact].
23+
24+
[media-type]: /v3/media
25+
[repo-commit-doc]: /v3/repos/commits
26+
[git-commit-doc]: /v3/git/commits
27+
[git-tag-doc]: /v3/git/tags
28+
[gpg-keys-doc]: /v3/users/gpg_keys
29+
[contact]: https://github.com/contact?form%5Bsubject%5D=Squash+API+Preview

content/v3/git/commits.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,28 @@ Name | Type | Description
5959

6060
<%= headers 201, :Location => get_resource(:new_commit)['url'] %>
6161
<%= json :new_commit %>
62+
63+
{% if page.version == 'dotcom' %}
64+
65+
## Commit signature verification
66+
67+
{{#tip}}
68+
69+
Commit response objects including signature verification data are currently available for developers to preview.
70+
During the preview period, the object formats may change without advance notice.
71+
Please see the [blog post](/changes/2016-04-04-git-signing-api-preview) for full details.
72+
73+
To receive signature verification data in commit objects you must provide a custom [media type](/v3/media) in the `Accept` header:
74+
75+
application/vnd.github.cryptographer-preview+sha
76+
77+
{{/tip}}
78+
79+
GET /repos/:owner/:repo/git/commits/:sha
80+
81+
### Response
82+
83+
<%= headers 200 %>
84+
<%= json(:signed_git_commit) %>
85+
86+
{% endif %}

content/v3/git/tags.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,29 @@ Name | Type | Description
6363

6464
<%= headers 201, :Location => get_resource(:gittag)['url'] %>
6565
<%= json :gittag %>
66+
67+
{% if page.version == 'dotcom' %}
68+
69+
## Tag signature verification
70+
71+
{{#tip}}
72+
73+
Tag response objects including signature verification data are currently available for developers to preview.
74+
During the preview period, the object formats may change without advance notice.
75+
Please see the [blog post](/changes/2016-04-04-git-signing-api-preview) for full details.
76+
77+
To receive signature verification data in tag objects you must provide a custom [media type](/v3/media) in the `Accept` header:
78+
79+
application/vnd.github.cryptographer-preview+sha
80+
81+
{{/tip}}
82+
83+
GET /repos/:owner/:repo/git/tags/:sha
84+
85+
### Response
86+
87+
<%= headers 200 %>
88+
<%= json(:signed_gittag) %>
89+
90+
91+
{% endif %}

content/v3/oauth.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ Name | Description
198198
`read:public_key`| List and view details for public keys.
199199
`write:public_key`| Create, list, and view details for public keys.
200200
`admin:public_key`| Fully manage public keys.
201+
{% if page.version == 'dotcom' %}`read:gpg_key`| List and view details for GPG keys.{% endif %}
202+
{% if page.version == 'dotcom' %}`write:gpg_key`| Create, list, and view details for GPG keys.{% endif %}
203+
{% if page.version == 'dotcom' %}`admin:gpg_key`| Fully manage GPG keys.{% endif %}
201204

202205
NOTE: Your application can request the scopes in the initial redirection. You
203206
can specify multiple scopes by separating them with a comma:

content/v3/repos/commits.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,28 @@ Pass the appropriate [media type](/v3/media/#commits-commit-comparison-and-pull-
9595
The response will include a comparison of up to 250 commits. If you are working with a larger commit range, you can use the [Commit List API](/v3/repos/commits/#list-commits-on-a-repository) to enumerate all commits in the range.
9696

9797
For comparisons with extremely large diffs, you may receive an error response indicating that the diff took too long to generate. You can typically resolve this error by using a smaller commit range.
98+
99+
{% if page.version == 'dotcom' %}
100+
101+
## Commit signature verification
102+
103+
{{#tip}}
104+
105+
Commit response objects including signature verification data are currently available for developers to preview.
106+
During the preview period, the object formats may change without advance notice.
107+
Please see the [blog post](/changes/2016-04-04-git-signing-api-preview) for full details.
108+
109+
To receive signature verification data in commit objects you must provide a custom [media type](/v3/media) in the `Accept` header:
110+
111+
application/vnd.github.cryptographer-preview+sha
112+
113+
{{/tip}}
114+
115+
GET /repos/:owner/:repo/commits/:sha
116+
117+
### Response
118+
119+
<%= headers 200 %>
120+
<%= json(:signed_commit) %>
121+
122+
{% endif %}

content/v3/users/gpg_keys.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
title: User GPG Keys
3+
---
4+
5+
{% if page.version == 'dotcom' %}
6+
7+
# GPG Keys
8+
9+
{{#tip}}
10+
11+
<a name="preview-period"></a>
12+
13+
APIs for managing user GPG keys are currently available for developers to preview.
14+
During the preview period, the APIs may change without advance notice.
15+
Please see the [blog post](/changes/2016-04-04-git-signing-api-preview) for full details.
16+
17+
To access the API you must provide a custom [media type](/v3/media) in the `Accept` header:
18+
19+
application/vnd.github.cryptographer-preview+sha
20+
21+
{{/tip}}
22+
23+
{:toc}
24+
25+
## List your GPG keys
26+
27+
GET /user/gpg_keys
28+
29+
Lists the current user's GPG keys. Requires that you are authenticated via
30+
Basic Auth or via OAuth with at least `read:gpg_key`
31+
[scope](/v3/oauth/#scopes).
32+
33+
### Response
34+
35+
<%= headers 200, :pagination => default_pagination_rels %>
36+
<%= json(:gpg_key) { |h| [h] } %>
37+
38+
## Get a single GPG key
39+
40+
View extended details for a single GPG key. Requires that you are
41+
authenticated via Basic Auth or via OAuth with at least `read:gpg_key`
42+
[scope](/v3/oauth/#scopes).
43+
44+
GET /user/gpg_keys/:id
45+
46+
### Response
47+
48+
<%= headers 200 %>
49+
<%= json :gpg_key %>
50+
51+
## Create a GPG key
52+
53+
Creates a GPG key. Requires that you are authenticated via Basic Auth,
54+
or OAuth with at least `write:gpg_key` [scope](/v3/oauth/#scopes).
55+
56+
POST /user/gpg_keys
57+
58+
### Input
59+
60+
<%= json :armored_public_key => "-----BEGIN PGP PUBLIC KEY BLOCK-----\n...\n-----END PGP PUBLIC KEY BLOCK-----" %>
61+
62+
### Response
63+
64+
<%= headers 201, :Location => get_resource(:gpg_key)['url'] %>
65+
<%= json :gpg_key %>
66+
67+
## Delete a GPG key
68+
69+
Removes a GPG key. Requires that you are authenticated via Basic Auth
70+
or via OAuth with at least `admin:gpg_key` [scope](/v3/oauth/#scopes).
71+
72+
DELETE /user/gpg_keys/:id
73+
74+
### Response
75+
76+
<%= headers 204 %>
77+
78+
{% endif %}

layouts/sidebar.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,10 @@ <h3><a href="#" class="js-expand-btn collapsed arrow-btn" data-proofer-ignore></
117117
<ul class="js-guides">
118118
<li><a href="/v3/users/emails/">Emails</a></li>
119119
<li><a href="/v3/users/followers/">Followers</a></li>
120-
<li><a href="/v3/users/keys/">Public Keys</a></li>
120+
<li><a href="/v3/users/keys/">Git SSH Keys</a></li>
121+
<% if !@item[:version].nil? && @item[:version] == 'dotcom' %>
122+
<li><a href="/v3/users/gpg_keys/">GPG Keys</a></li>
123+
<% end %>
121124
<li><a href="/v3/users/administration/">Administration (Enterprise)</a></li>
122125
</ul>
123126
</li>

lib/responses/git.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,14 @@ module Responses
206206
}]
207207
})
208208

209+
SIGNED_COMMIT ||= COMMIT.dup
210+
SIGNED_COMMIT["commit"]["verification"] ||= {
211+
"verified" => true,
212+
"reason" => "valid",
213+
"signature" => "-----BEGIN PGP MESSAGE-----\n...\n-----END PGP MESSAGE-----",
214+
"payload" => "tree 6dcb09b5b57875f334f61aebed695e2e4193db5e\n..."
215+
}
216+
209217
COMMIT_COMMENT ||= {
210218
"html_url" => "https://github.com/octocat/Hello-World/commit/6dcb09b5b57875f334f61aebed695e2e4193db5e#commitcomment-1",
211219
"url" => "https://api.github.com/repos/octocat/Hello-World/comments/1",
@@ -340,6 +348,13 @@ module Responses
340348
]
341349
}
342350

351+
SIGNED_GIT_COMMIT ||= GIT_COMMIT.merge("verification" => {
352+
"verified" => true,
353+
"reason" => "valid",
354+
"signature" => "-----BEGIN PGP MESSAGE-----\n...\n-----END PGP MESSAGE-----",
355+
"payload" => "tree 691272480426f78a0138979dd3ce63b77f706feb\n..."
356+
})
357+
343358
NEW_COMMIT ||= {
344359
"sha" => "7638417db6d59f3c431d3e1f261cc637155684cd",
345360
"url" => "https://api.github.com/repos/octocat/Hello-World/git/commits/7638417db6d59f3c431d3e1f261cc637155684cd",
@@ -383,6 +398,13 @@ module Responses
383398
}
384399
}
385400

401+
SIGNED_GITTAG ||= GITTAG.merge("verification" => {
402+
"verified" => true,
403+
"reason" => "valid",
404+
"signature" => "-----BEGIN PGP MESSAGE-----\n...\n-----END PGP MESSAGE-----",
405+
"payload" => "object c3d0be41ecbe669545ee3e94d31ed9a4bc91ee3c\n..."
406+
})
407+
386408
REF ||= {
387409
"ref" => "refs/heads/featureA",
388410
"url" => "https://api.github.com/repos/octocat/Hello-World/git/refs/heads/featureA",

lib/responses/gpg_keys.rb

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
module GitHub
2+
module Resources
3+
module Responses
4+
GPG_KEY ||= {
5+
"id" => 3,
6+
"primary_key_id" => nil,
7+
"key_id" => "3262EFF25BA0D270",
8+
"public_key" => "xsBNBFayYZ...",
9+
"emails" => [
10+
{
11+
"email" => "mastahyeti@users.noreply.github.com",
12+
"verified" => true
13+
}
14+
],
15+
"subkeys" => [
16+
{
17+
"id" => 4,
18+
"primary_key_id" => 3,
19+
"key_id" => "4A595D4C72EE49C7",
20+
"public_key" => "zsBNBFayYZ...",
21+
"emails" => [],
22+
"subkeys" => [],
23+
"can_sign" => false,
24+
"can_encrypt_comms" => true,
25+
"can_encrypt_storage" => true,
26+
"can_certify" => false,
27+
"created_at" => "2016-03-24T11:31:04-06:00",
28+
"expires_at" => nil
29+
}
30+
],
31+
"can_sign" => true,
32+
"can_encrypt_comms" => false,
33+
"can_encrypt_storage" => false,
34+
"can_certify" => true,
35+
"created_at" => "2016-03-24T11:31:04-06:00",
36+
"expires_at" => nil}
37+
end
38+
end
39+
end

0 commit comments

Comments
 (0)