{"action":"created","comment":{"url":"https://api.github.com/repos/ausaccessfed/saml-service/pulls/comments/34206965","id":34206965,"diff_hunk":"@@ -0,0 +1,59 @@\n+module MetadataQueryCaching\n+  extend ActiveSupport::Concern\n+\n+  def generate_known_entities_etag(known_entities)\n+    timestamps = known_entities.map(&:updated_at).map(&:to_i).join('.')\n+    Digest::MD5.hexdigest(\"samlmetadata/#{timestamps}\")\n+  end\n+\n+  def generate_descriptor_etag(desc)\n+    Digest::MD5.hexdigest(\"samlmetadata/#{desc.id}-#{desc.updated_at}\")\n+  end\n+\n+  def known_entities_unmodified(known_entities, etag)\n+    if valid_etag(etag) || unmodified(known_entities.sort_by(&:updated_at).last)\n+      return true\n+    end\n+\n+    false\n+  end\n+\n+  def known_entity_unmodified(known_entity, etag)\n+    return true if valid_etag(etag) || unmodified(known_entity)\n+    false\n+  end\n+\n+  def valid_etag(etag)\n+    return false unless request.headers['If-None-Match']\n+    request.headers['If-None-Match'] == etag\n+  end\n+\n+  def unmodified(obj)\n+    return false unless request.headers['If-Modified-Since']\n+    obj.updated_at <= request.headers['If-Modified-Since']\n+  end","path":"app/controllers/concerns/metadata_query_caching.rb","position":34,"original_position":34,"commit_id":"1dac3ee4f6c0cb8bb0ac8ed22bcd0b610fb1c718","original_commit_id":"1dac3ee4f6c0cb8bb0ac8ed22bcd0b610fb1c718","user":{"login":"smangelsdorf","id":6358,"avatar_url":"https://avatars.githubusercontent.com/u/6358?v=3","gravatar_id":"","url":"https://api.github.com/users/smangelsdorf","html_url":"https://github.com/smangelsdorf","followers_url":"https://api.github.com/users/smangelsdorf/followers","following_url":"https://api.github.com/users/smangelsdorf/following{/other_user}","gists_url":"https://api.github.com/users/smangelsdorf/gists{/gist_id}","starred_url":"https://api.github.com/users/smangelsdorf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smangelsdorf/subscriptions","organizations_url":"https://api.github.com/users/smangelsdorf/orgs","repos_url":"https://api.github.com/users/smangelsdorf/repos","events_url":"https://api.github.com/users/smangelsdorf/events{/privacy}","received_events_url":"https://api.github.com/users/smangelsdorf/received_events","type":"User","site_admin":false},"body":"`valid_etag` and `unmodified` should be predicate methods.","created_at":"2015-07-08T22:38:19Z","updated_at":"2015-07-08T22:38:19Z","html_url":"https://github.com/ausaccessfed/saml-service/pull/34#discussion_r34206965","pull_request_url":"https://api.github.com/repos/ausaccessfed/saml-service/pulls/34","_links":{"self":{"href":"https://api.github.com/repos/ausaccessfed/saml-service/pulls/comments/34206965"},"html":{"href":"https://github.com/ausaccessfed/saml-service/pull/34#discussion_r34206965"},"pull_request":{"href":"https://api.github.com/repos/ausaccessfed/saml-service/pulls/34"}}},"pull_request":{"url":"https://api.github.com/repos/ausaccessfed/saml-service/pulls/34","id":39446017,"html_url":"https://github.com/ausaccessfed/saml-service/pull/34","diff_url":"https://github.com/ausaccessfed/saml-service/pull/34.diff","patch_url":"https://github.com/ausaccessfed/saml-service/pull/34.patch","issue_url":"https://api.github.com/repos/ausaccessfed/saml-service/issues/34","number":34,"state":"open","locked":false,"title":"Feature/metadata query protocol","user":{"login":"bradleybeddoes","id":86558,"avatar_url":"https://avatars.githubusercontent.com/u/86558?v=3","gravatar_id":"","url":"https://api.github.com/users/bradleybeddoes","html_url":"https://github.com/bradleybeddoes","followers_url":"https://api.github.com/users/bradleybeddoes/followers","following_url":"https://api.github.com/users/bradleybeddoes/following{/other_user}","gists_url":"https://api.github.com/users/bradleybeddoes/gists{/gist_id}","starred_url":"https://api.github.com/users/bradleybeddoes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bradleybeddoes/subscriptions","organizations_url":"https://api.github.com/users/bradleybeddoes/orgs","repos_url":"https://api.github.com/users/bradleybeddoes/repos","events_url":"https://api.github.com/users/bradleybeddoes/events{/privacy}","received_events_url":"https://api.github.com/users/bradleybeddoes/received_events","type":"User","site_admin":false},"body":"**MDQP** defines a simple protocol for retrieving metadata about named entities, or named collections of entities.  The goal of the protocol is to profile various aspects of HTTP to allow requesters to\r\nrely on certain, rigorously defined, behaviour.\r\n\r\nThe code contained within this PR implements:\r\n\r\n1. https://github.com/iay/md-query/blob/master/draft-young-md-query.txt (draft-young-md-query-05)\r\n1. https://github.com/iay/md-query/blob/master/draft-young-md-query-saml.txt (draft-young-md-query-saml-05)\r\n\r\nDue to the requirements of MDQP and the state of saml-service implementation prior implementing MDQP the PR also addresses changes with DB structure and signature generation. In addition RawEntityDescriptor has much greater internal support including the ability to act as a single, signed, root node in response to metadata queries.\r\n\r\nI believe all parts of these specs are covered in this PR, so anything which is 'missing' should be highlighted for correction prior to merge except for the following in md-query:\r\n\r\n* 2.2 which can't be identified within the Rails stack (as best as my research indicates)\r\n* 4.3\r\n* 6.2/6.3\r\n\r\nAll of the above will be handled by the implementing Apache HTTPD instance.","created_at":"2015-07-08T06:41:59Z","updated_at":"2015-07-08T22:38:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6706ac7f0a48276632a99e88c2bf32aa703b77a5","assignee":{"login":"smangelsdorf","id":6358,"avatar_url":"https://avatars.githubusercontent.com/u/6358?v=3","gravatar_id":"","url":"https://api.github.com/users/smangelsdorf","html_url":"https://github.com/smangelsdorf","followers_url":"https://api.github.com/users/smangelsdorf/followers","following_url":"https://api.github.com/users/smangelsdorf/following{/other_user}","gists_url":"https://api.github.com/users/smangelsdorf/gists{/gist_id}","starred_url":"https://api.github.com/users/smangelsdorf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smangelsdorf/subscriptions","organizations_url":"https://api.github.com/users/smangelsdorf/orgs","repos_url":"https://api.github.com/users/smangelsdorf/repos","events_url":"https://api.github.com/users/smangelsdorf/events{/privacy}","received_events_url":"https://api.github.com/users/smangelsdorf/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/ausaccessfed/saml-service/pulls/34/commits","review_comments_url":"https://api.github.com/repos/ausaccessfed/saml-service/pulls/34/comments","review_comment_url":"https://api.github.com/repos/ausaccessfed/saml-service/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ausaccessfed/saml-service/issues/34/comments","statuses_url":"https://api.github.com/repos/ausaccessfed/saml-service/statuses/1dac3ee4f6c0cb8bb0ac8ed22bcd0b610fb1c718","head":{"label":"ausaccessfed:feature/metadata-query-protocol","ref":"feature/metadata-query-protocol","sha":"1dac3ee4f6c0cb8bb0ac8ed22bcd0b610fb1c718","user":{"login":"ausaccessfed","id":149044,"avatar_url":"https://avatars.githubusercontent.com/u/149044?v=3","gravatar_id":"","url":"https://api.github.com/users/ausaccessfed","html_url":"https://github.com/ausaccessfed","followers_url":"https://api.github.com/users/ausaccessfed/followers","following_url":"https://api.github.com/users/ausaccessfed/following{/other_user}","gists_url":"https://api.github.com/users/ausaccessfed/gists{/gist_id}","starred_url":"https://api.github.com/users/ausaccessfed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ausaccessfed/subscriptions","organizations_url":"https://api.github.com/users/ausaccessfed/orgs","repos_url":"https://api.github.com/users/ausaccessfed/repos","events_url":"https://api.github.com/users/ausaccessfed/events{/privacy}","received_events_url":"https://api.github.com/users/ausaccessfed/received_events","type":"Organization","site_admin":false},"repo":{"id":23208847,"name":"saml-service","full_name":"ausaccessfed/saml-service","owner":{"login":"ausaccessfed","id":149044,"avatar_url":"https://avatars.githubusercontent.com/u/149044?v=3","gravatar_id":"","url":"https://api.github.com/users/ausaccessfed","html_url":"https://github.com/ausaccessfed","followers_url":"https://api.github.com/users/ausaccessfed/followers","following_url":"https://api.github.com/users/ausaccessfed/following{/other_user}","gists_url":"https://api.github.com/users/ausaccessfed/gists{/gist_id}","starred_url":"https://api.github.com/users/ausaccessfed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ausaccessfed/subscriptions","organizations_url":"https://api.github.com/users/ausaccessfed/orgs","repos_url":"https://api.github.com/users/ausaccessfed/repos","events_url":"https://api.github.com/users/ausaccessfed/events{/privacy}","received_events_url":"https://api.github.com/users/ausaccessfed/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ausaccessfed/saml-service","description":"AAF service responsible for SAML data storage, metadata generation and inter-federation (eduGAIN) metadata processing.","fork":false,"url":"https://api.github.com/repos/ausaccessfed/saml-service","forks_url":"https://api.github.com/repos/ausaccessfed/saml-service/forks","keys_url":"https://api.github.com/repos/ausaccessfed/saml-service/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ausaccessfed/saml-service/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ausaccessfed/saml-service/teams","hooks_url":"https://api.github.com/repos/ausaccessfed/saml-service/hooks","issue_events_url":"https://api.github.com/repos/ausaccessfed/saml-service/issues/events{/number}","events_url":"https://api.github.com/repos/ausaccessfed/saml-service/events","assignees_url":"https://api.github.com/repos/ausaccessfed/saml-service/assignees{/user}","branches_url":"https://api.github.com/repos/ausaccessfed/saml-service/branches{/branch}","tags_url":"https://api.github.com/repos/ausaccessfed/saml-service/tags","blobs_url":"https://api.github.com/repos/ausaccessfed/saml-service/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ausaccessfed/saml-service/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ausaccessfed/saml-service/git/refs{/sha}","trees_url":"https://api.github.com/repos/ausaccessfed/saml-service/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ausaccessfed/saml-service/statuses/{sha}","languages_url":"https://api.github.com/repos/ausaccessfed/saml-service/languages","stargazers_url":"https://api.github.com/repos/ausaccessfed/saml-service/stargazers","contributors_url":"https://api.github.com/repos/ausaccessfed/saml-service/contributors","subscribers_url":"https://api.github.com/repos/ausaccessfed/saml-service/subscribers","subscription_url":"https://api.github.com/repos/ausaccessfed/saml-service/subscription","commits_url":"https://api.github.com/repos/ausaccessfed/saml-service/commits{/sha}","git_commits_url":"https://api.github.com/repos/ausaccessfed/saml-service/git/commits{/sha}","comments_url":"https://api.github.com/repos/ausaccessfed/saml-service/comments{/number}","issue_comment_url":"https://api.github.com/repos/ausaccessfed/saml-service/issues/comments{/number}","contents_url":"https://api.github.com/repos/ausaccessfed/saml-service/contents/{+path}","compare_url":"https://api.github.com/repos/ausaccessfed/saml-service/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ausaccessfed/saml-service/merges","archive_url":"https://api.github.com/repos/ausaccessfed/saml-service/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ausaccessfed/saml-service/downloads","issues_url":"https://api.github.com/repos/ausaccessfed/saml-service/issues{/number}","pulls_url":"https://api.github.com/repos/ausaccessfed/saml-service/pulls{/number}","milestones_url":"https://api.github.com/repos/ausaccessfed/saml-service/milestones{/number}","notifications_url":"https://api.github.com/repos/ausaccessfed/saml-service/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ausaccessfed/saml-service/labels{/name}","releases_url":"https://api.github.com/repos/ausaccessfed/saml-service/releases{/id}","created_at":"2014-08-22T01:30:23Z","updated_at":"2015-03-16T04:27:05Z","pushed_at":"2015-07-08T06:41:59Z","git_url":"git://github.com/ausaccessfed/saml-service.git","ssh_url":"git@github.com:ausaccessfed/saml-service.git","clone_url":"https://github.com/ausaccessfed/saml-service.git","svn_url":"https://github.com/ausaccessfed/saml-service","homepage":"","size":1040,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":4,"forks":1,"open_issues":4,"watchers":0,"default_branch":"develop"}},"base":{"label":"ausaccessfed:develop","ref":"develop","sha":"70a0483a8d22ca07600207a77a76a4ff1a3963bc","user":{"login":"ausaccessfed","id":149044,"avatar_url":"https://avatars.githubusercontent.com/u/149044?v=3","gravatar_id":"","url":"https://api.github.com/users/ausaccessfed","html_url":"https://github.com/ausaccessfed","followers_url":"https://api.github.com/users/ausaccessfed/followers","following_url":"https://api.github.com/users/ausaccessfed/following{/other_user}","gists_url":"https://api.github.com/users/ausaccessfed/gists{/gist_id}","starred_url":"https://api.github.com/users/ausaccessfed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ausaccessfed/subscriptions","organizations_url":"https://api.github.com/users/ausaccessfed/orgs","repos_url":"https://api.github.com/users/ausaccessfed/repos","events_url":"https://api.github.com/users/ausaccessfed/events{/privacy}","received_events_url":"https://api.github.com/users/ausaccessfed/received_events","type":"Organization","site_admin":false},"repo":{"id":23208847,"name":"saml-service","full_name":"ausaccessfed/saml-service","owner":{"login":"ausaccessfed","id":149044,"avatar_url":"https://avatars.githubusercontent.com/u/149044?v=3","gravatar_id":"","url":"https://api.github.com/users/ausaccessfed","html_url":"https://github.com/ausaccessfed","followers_url":"https://api.github.com/users/ausaccessfed/followers","following_url":"https://api.github.com/users/ausaccessfed/following{/other_user}","gists_url":"https://api.github.com/users/ausaccessfed/gists{/gist_id}","starred_url":"https://api.github.com/users/ausaccessfed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ausaccessfed/subscriptions","organizations_url":"https://api.github.com/users/ausaccessfed/orgs","repos_url":"https://api.github.com/users/ausaccessfed/repos","events_url":"https://api.github.com/users/ausaccessfed/events{/privacy}","received_events_url":"https://api.github.com/users/ausaccessfed/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ausaccessfed/saml-service","description":"AAF service responsible for SAML data storage, metadata generation and inter-federation (eduGAIN) metadata processing.","fork":false,"url":"https://api.github.com/repos/ausaccessfed/saml-service","forks_url":"https://api.github.com/repos/ausaccessfed/saml-service/forks","keys_url":"https://api.github.com/repos/ausaccessfed/saml-service/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ausaccessfed/saml-service/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ausaccessfed/saml-service/teams","hooks_url":"https://api.github.com/repos/ausaccessfed/saml-service/hooks","issue_events_url":"https://api.github.com/repos/ausaccessfed/saml-service/issues/events{/number}","events_url":"https://api.github.com/repos/ausaccessfed/saml-service/events","assignees_url":"https://api.github.com/repos/ausaccessfed/saml-service/assignees{/user}","branches_url":"https://api.github.com/repos/ausaccessfed/saml-service/branches{/branch}","tags_url":"https://api.github.com/repos/ausaccessfed/saml-service/tags","blobs_url":"https://api.github.com/repos/ausaccessfed/saml-service/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ausaccessfed/saml-service/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ausaccessfed/saml-service/git/refs{/sha}","trees_url":"https://api.github.com/repos/ausaccessfed/saml-service/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ausaccessfed/saml-service/statuses/{sha}","languages_url":"https://api.github.com/repos/ausaccessfed/saml-service/languages","stargazers_url":"https://api.github.com/repos/ausaccessfed/saml-service/stargazers","contributors_url":"https://api.github.com/repos/ausaccessfed/saml-service/contributors","subscribers_url":"https://api.github.com/repos/ausaccessfed/saml-service/subscribers","subscription_url":"https://api.github.com/repos/ausaccessfed/saml-service/subscription","commits_url":"https://api.github.com/repos/ausaccessfed/saml-service/commits{/sha}","git_commits_url":"https://api.github.com/repos/ausaccessfed/saml-service/git/commits{/sha}","comments_url":"https://api.github.com/repos/ausaccessfed/saml-service/comments{/number}","issue_comment_url":"https://api.github.com/repos/ausaccessfed/saml-service/issues/comments{/number}","contents_url":"https://api.github.com/repos/ausaccessfed/saml-service/contents/{+path}","compare_url":"https://api.github.com/repos/ausaccessfed/saml-service/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ausaccessfed/saml-service/merges","archive_url":"https://api.github.com/repos/ausaccessfed/saml-service/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ausaccessfed/saml-service/downloads","issues_url":"https://api.github.com/repos/ausaccessfed/saml-service/issues{/number}","pulls_url":"https://api.github.com/repos/ausaccessfed/saml-service/pulls{/number}","milestones_url":"https://api.github.com/repos/ausaccessfed/saml-service/milestones{/number}","notifications_url":"https://api.github.com/repos/ausaccessfed/saml-service/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ausaccessfed/saml-service/labels{/name}","releases_url":"https://api.github.com/repos/ausaccessfed/saml-service/releases{/id}","created_at":"2014-08-22T01:30:23Z","updated_at":"2015-03-16T04:27:05Z","pushed_at":"2015-07-08T06:41:59Z","git_url":"git://github.com/ausaccessfed/saml-service.git","ssh_url":"git@github.com:ausaccessfed/saml-service.git","clone_url":"https://github.com/ausaccessfed/saml-service.git","svn_url":"https://github.com/ausaccessfed/saml-service","homepage":"","size":1040,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":4,"forks":1,"open_issues":4,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/ausaccessfed/saml-service/pulls/34"},"html":{"href":"https://github.com/ausaccessfed/saml-service/pull/34"},"issue":{"href":"https://api.github.com/repos/ausaccessfed/saml-service/issues/34"},"comments":{"href":"https://api.github.com/repos/ausaccessfed/saml-service/issues/34/comments"},"review_comments":{"href":"https://api.github.com/repos/ausaccessfed/saml-service/pulls/34/comments"},"review_comment":{"href":"https://api.github.com/repos/ausaccessfed/saml-service/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ausaccessfed/saml-service/pulls/34/commits"},"statuses":{"href":"https://api.github.com/repos/ausaccessfed/saml-service/statuses/1dac3ee4f6c0cb8bb0ac8ed22bcd0b610fb1c718"}}}}