Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data output agent #203

Merged
merged 6 commits into from Apr 13, 2014
Merged

Data output agent #203

merged 6 commits into from Apr 13, 2014

Conversation

cantino
Copy link
Member

@cantino cantino commented Apr 6, 2014

This pull request adds a new DataOutputAgent that returns a RSS or JSON feed of incoming events. In order to do this, the EventHooksController will now accept all HTTP verbs, not just POSTs. (Perhaps the controller should now be renamed to WebRequestsController, or similar, since webhooks are traditionally limited to POST requests?)

This is a solution to the output half of #11. Appreciate feedback @albertsun, @alias1, @Fluffums, and @snicker!

delete("/users/6/webhooks/2/foobar").should route_to("webhooks#handle_request", resulting_params)
end

it "routes with format" do
Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO this example is not very needed as route uses default Rails behavior and it was tested in Rails :D

Copy link
Member Author

Choose a reason for hiding this comment

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

Fair enough-- match goes away in Rails 4, though, so this is somewhat of a paranoid guard.

Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIK it will not be removed completely. In Rails 4, match without :via will be prohibited, so

match "/users/:user_id/webhooks/:agent_id/:secret" => \
  "webhooks#handle_request",
    :as => :webhooks

will be replaced with:

match "/users/:user_id/webhooks/:agent_id/:secret" => \
  "webhooks#handle_request",
    :as => :webhooks,
    :via => :all

@0xdevalias
Copy link
Member

Just had a very brief scan over it all and it looks kinda cool to me. Without getting deep into the guts of it I feel I can't really comment further though.

I'd support changing the name to WebRequestsController. Also, I wonder if the webhooks part of the route is the best name now, given it's expanded uses?

@cantino
Copy link
Member Author

cantino commented Apr 9, 2014

Yup, just did that now!

On Sat, Apr 5, 2014 at 6:43 PM, alias1 notifications@github.com wrote:

Just had a very brief scan over it all and it looks kinda cool to me.
Without getting deep into the guts of it I feel I can't really comment
further though.

I'd support changing the name to WebRequestsController. Also, I wonder if
the webhooks part of the route is the best name now, given it's expanded
uses?

Reply to this email directly or view it on GitHubhttps://github.com//pull/203#issuecomment-39656165
.

@albertsun
Copy link
Contributor

I'd agree about changing the name to WebRequestsController.

For the url, I wonder if instead of having secret as a URL segment it should be passed as a query string parameter instead? Would make it look a bit better for un-protected routes. And in the future the url won't need to change to support oauth style access_key=?&secret_key=? tokens.

@0xdevalias
Copy link
Member

Query string isn't really RESTful though. Under what circumstances would it not be protected? Even if you end up publishing the 'secret' url somewhere public, the design should still be such that it's kept secret (eg. how do you differentiate different endpoints without the varying key?)

For OAUTH, as I understand it, access/secret should only ever be used as part of the url between servers over SSL. I would imagine that most if not all usecases for this would call for something more public/flexible than this, in which case you would be passing the access_token (usually) via Auth header.

Basically just braindumping, so feel free to question/correct me.

@albertsun
Copy link
Contributor

Ah, fair enough point about OAUTH. I don't really fully understand how that part works.

As far as query string being RESTful though... isn't the agent_id enough of an identifier? Whatever secret is in the url won't change the data being delivered, right? It'll always just be all the events that the DataOutputAgent has. The secret feels like secondary information to me.

The most common case I can imagine for using this will be to set up a DataOutputAgent to a WebsiteAgent to make an ersatz RSS feed and then publishing a public URL that anyone can point their RSS feed reader at to subscribe to.

@cantino
Copy link
Member Author

cantino commented Apr 9, 2014

It's true that :secret doesn't really need to be in the path. I guess I could add an alternative route that doesn't require it, and move it to a query param (as per @albertsun's suggestion). That would give Agent's maximum flexibility. My original thought was to include it, forcing Agents to be as secure as possible.

@0xdevalias
Copy link
Member

I'm definitely a fan of secure by design. Given that you can still do all of the 'public' user cases as is, i'd be inclined to keep it in the path.

(But to answer the above, yeah the agent id is sufficient to uniquely identify them, didn't really think about that aspect)

cantino added a commit that referenced this pull request Apr 13, 2014
@cantino cantino merged commit 25b62ae into master Apr 13, 2014
@cantino cantino deleted the data_output_agent branch April 13, 2014 18:04
@0xdevalias 0xdevalias mentioned this pull request Jun 1, 2014
48 tasks
DataMinerUK pushed a commit to DataMinerUK/huginn that referenced this pull request Oct 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants