We should support APIs to manage webhooks so that 3rd-party sites can use oauth to configure a webhook on behalf of a user. This is a common practice to make it easier for the user.
e.g. /rest/p/test/admin/git/webhooks/repo-push/54db231c04687d300e65db82
.
Authentication:
See API auth docs. Works with both bearer tokens and application flow. However, for HTTP methods such as DELETE you'll need to authorize with headers, rather than through request body parameters. I've added support of this to Allura (see [55c074]). We should add this to API auth docs when it lands.
if you're using application flow you good to go (python oauth lib uses headers already)
if you're using bearer tokens, pass it as header: headers={'Authorization': 'OAuth BearerToken access_token=<your_token>'}
.
Also, for sourceforge deployment apache is not configured to pass auth headers to wsgi app (at least on sandboxes), so you'll need to add WSGIPassAuthorization On to allura-venv.conf. Probably we need to update some docs for installing Allura somewhere?
QA
Apply this change to python-oauth2 to avoid certificate errors on sandbox.
Last edit: Igor Bondarenko 2015-02-23
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
An API response of "status": "ok" and nested "webhook" dict seems weird, particularly when doing a GET. How about un-nesting the webhook details? The 200 or 201 status code is sufficient to represent the status I think.
Oauth parameters can be passed as a URL param so for DELETE You can do ?access_token=foo and don't have to use an Authorization: header.
That said, adding support for header-based oauth bearer tokens is nice. A few things on that:
There actually is a spec for it. So the Authorization: header value should start with just "Bearer " per https://tools.ietf.org/html/rfc6750#section-2.1 I.e. the bearer_token_prefix variable.
You have some log.error lines left in RestController._authenticate_request and OAuthNegotiator._authenticate
This should be a separate ticket or at least update the title of this ticket so we remember to point it out when we make a changelog in the next release.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Closed #731.
ib/7832
Endpoints description (need to add this to API docs wiki page):
GET /rest/p/<project>/admin/<app>/webhooks
/rest/p/test/admin/git/webhooks
GET /rest/p/<project>/admin/<app>/webhooks/<type>/<id>
/rest/p/test/admin/git/webhooks/repo-push/54db231c04687d300e65db82
POST /rest/p/<project>/admin/<app>/webhooks/<type>/
/rest/p/test/admin/git/webhooks/repo-push
url
POST /rest/p/<project>/admin/<app>/webhooks/<type>/<id>
/rest/p/test/admin/git/webhooks/repo-push/54db231c04687d300e65db82
url
,secret
(each can be omitted if don't want to update)DELETE /rest/p/<project>/admin/<app>/webhooks/<type>/<id>
/rest/p/test/admin/git/webhooks/repo-push/54db231c04687d300e65db82
.
Authentication:
See API auth docs. Works with both bearer tokens and application flow. However, for HTTP methods such as
DELETE
you'll need to authorize with headers, rather than through request body parameters. I've added support of this to Allura (see [55c074]). We should add this to API auth docs when it lands.headers={'Authorization': 'OAuth BearerToken access_token=<your_token>'}
.
Also, for sourceforge deployment apache is not configured to pass auth headers to wsgi app (at least on sandboxes), so you'll need to add
WSGIPassAuthorization On
toallura-venv.conf
. Probably we need to update some docs for installing Allura somewhere?QA
Apply this change to python-oauth2 to avoid certificate errors on sandbox.
Last edit: Igor Bondarenko 2015-02-23
An API response of
"status": "ok"
and nested"webhook"
dict seems weird, particularly when doing a GET. How about un-nesting the webhook details? The 200 or 201 status code is sufficient to represent the status I think.Oauth parameters can be passed as a URL param so for DELETE You can do ?access_token=foo and don't have to use an
Authorization:
header.That said, adding support for header-based oauth bearer tokens is nice. A few things on that:
Authorization:
header value should start with just "Bearer " per https://tools.ietf.org/html/rfc6750#section-2.1 I.e. thebearer_token_prefix
variable.log.error
lines left inRestController._authenticate_request
andOAuthNegotiator._authenticate
Good points. Created [#7840] for header auth stuff.
Related
Tickets:
#7840Closed #740. Force-pushed
ib/7832
Also fixes [#7840]
Related
Tickets:
#7840