Skip to content

Conversation

@lasley
Copy link

@lasley lasley commented Oct 10, 2017

  • Create a module to allow for the receipt of web hooks in an abstract fashion

Depends:

This is a PoC.

* Create a module that circumvents the JSON-RPC requirement for all requests with application/json
* Create a module to allow for the receipt of web hooks in an abstract fashion
@lasley lasley force-pushed the release/10.0/base_webhook branch from 7a6d879 to 071843b Compare October 11, 2017 18:53

@http.route(
['/base_web_hook/<string:slug>'],
type='json',
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmmm maybe should be an HTTP receiver as well

@lasley lasley force-pushed the release/10.0/base_webhook branch from 2e04110 to c2e781c Compare October 11, 2017 21:10
@lasley
Copy link
Author

lasley commented Oct 11, 2017

Alright this is implemented in a connector, so it's less rough around the edges now. We've still got some testing to do on the connector, and another one to implement, so I would assume there's still work to come here.

This is an implementation example

_name = 'web.hook'
_description = 'Web Hook'

name = fields.Char(
Copy link
Author

@lasley lasley Oct 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add UNIQUE(name)

@lasley lasley force-pushed the release/10.0/base_webhook branch from 435c307 to 854e366 Compare October 16, 2017 19:17
@lasley lasley force-pushed the release/10.0/base_webhook branch from a9ae4a8 to b292801 Compare October 17, 2017 21:16
@lasley lasley force-pushed the release/10.0/base_webhook branch from b292801 to e310be4 Compare October 17, 2017 21:20
@lasley
Copy link
Author

lasley commented Oct 17, 2017

Alright I've now added a Request Bin hook type, which simply catches and saves inbound requests. This is a useful tool for testing web hooks as an administrator, but will also help me test the module in an automated fashion.

@hbrunn
Copy link
Member

hbrunn commented Nov 28, 2017

late to the party, are you aware of https://github.com/OCA/server-tools/tree/10.0/webhook ?
(I do have a couple of things I'd like to change...)

@lasley
Copy link
Author

lasley commented Nov 28, 2017

Not aware at all. How did you conquer the receipt of JSON?

@hbrunn
Copy link
Member

hbrunn commented Nov 28, 2017

I didn't conquer anything there, didn't even use the module. But I read it yesterday and decided I can't use it for what I had in mind.

@hbrunn
Copy link
Member

hbrunn commented Nov 28, 2017

@lasley
Copy link
Author

lasley commented Nov 28, 2017

I'm looking at the module, and it definitely does not work as intended in most cases. The route is using type='json', which means that the hook must be an RPC formatted request. See odoo/odoo#7766

I would propose this module as a direct successor to the other TBH. There are significantly more features here, such as the ability to receive non-JSON requests & session authenticated hooks.

@lasley
Copy link
Author

lasley commented Nov 28, 2017

@moylop260 - your module https://github.com/OCA/server-tools/tree/10.0/webhook has instructions specifically for Github web hooks, but odoo/odoo#7766 alludes to the fact that this does not actual work. Can you confirm OCA/server-tools/webhook does work for any inbound JSON webhook without sitting a proxy in front of the Odoo server?

Copy link

@pntabuye pntabuye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested on Odoo 10e and not conclusive. The non JSON-RPC json does not raise a BadRequest error from werkzeug.

old_init(self, *args)
except BadRequest as e:
try:
args = self.httprequest.args
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AttributeError: 'JsonRequest' object has no attribute 'httprequest'

:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/210/10.0

Bug Tracker

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a usage section on how to use this module

* Security is too lax; public can read too much. Maybe should also add a group for hooks..
* Buffer length should be checked before ``httprequest.get_data`` calls

Bug Tracker

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a usage section on how to use this module

@gurneyalex
Copy link
Member

sale, old odoo running on python 2 -> closing

@gurneyalex gurneyalex closed this Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants