{"action":"created","comment":{"url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/pulls/comments/37373367","id":37373367,"diff_hunk":"@@ -0,0 +1,23 @@\n+(ns puppetlabs.trapperkeeper.services.authorization.authorization-service\n+  (:require [puppetlabs.trapperkeeper.core :refer [defservice]]\n+            [puppetlabs.trapperkeeper.authorization.ring-middleware :refer\n+             [wrap-authorization-check]]\n+            [puppetlabs.trapperkeeper.services.authorization.authorization-core :refer :all]))\n+\n+(defprotocol AuthorizationService\n+  (wrap-handler [this handler]))\n+\n+(defservice authorization-service\n+  AuthorizationService\n+  [[:ConfigService get-in-config]]\n+  (init\n+    [this context]\n+    (let [config (get-in-config [:authorization :rules])]\n+      (validate-auth-config! config)\n+      (assoc context :authorization {:rules (transform-config config)})))\n+\n+  (wrap-handler\n+    [this handler]\n+    (let [context (service-context this)","path":"src/puppetlabs/trapperkeeper/services/authorization/authorization_service.clj","position":21,"original_position":21,"commit_id":"e16ea4b649b2163a9cd1fde3d97448fea6be1c18","original_commit_id":"e16ea4b649b2163a9cd1fde3d97448fea6be1c18","user":{"login":"jeffmccune","id":8972,"avatar_url":"https://avatars.githubusercontent.com/u/8972?v=3","gravatar_id":"","url":"https://api.github.com/users/jeffmccune","html_url":"https://github.com/jeffmccune","followers_url":"https://api.github.com/users/jeffmccune/followers","following_url":"https://api.github.com/users/jeffmccune/following{/other_user}","gists_url":"https://api.github.com/users/jeffmccune/gists{/gist_id}","starred_url":"https://api.github.com/users/jeffmccune/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeffmccune/subscriptions","organizations_url":"https://api.github.com/users/jeffmccune/orgs","repos_url":"https://api.github.com/users/jeffmccune/repos","events_url":"https://api.github.com/users/jeffmccune/events{/privacy}","received_events_url":"https://api.github.com/users/jeffmccune/received_events","type":"User","site_admin":false},"body":"Nevermind, a community member filed an issue and there's the answer at https://github.com/puppetlabs/trapperkeeper/issues/166","created_at":"2015-08-19T01:52:34Z","updated_at":"2015-08-19T01:52:34Z","html_url":"https://github.com/puppetlabs/trapperkeeper-authorization/pull/2#discussion_r37373367","pull_request_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/pulls/comments/37373367"},"html":{"href":"https://github.com/puppetlabs/trapperkeeper-authorization/pull/2#discussion_r37373367"},"pull_request":{"href":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/pulls/2","id":42746657,"html_url":"https://github.com/puppetlabs/trapperkeeper-authorization/pull/2","diff_url":"https://github.com/puppetlabs/trapperkeeper-authorization/pull/2.diff","patch_url":"https://github.com/puppetlabs/trapperkeeper-authorization/pull/2.patch","issue_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/issues/2","number":2,"state":"open","locked":false,"title":"[FOR REVIEW] (TK-258) Config checking and transformation functions","user":{"login":"jeffmccune","id":8972,"avatar_url":"https://avatars.githubusercontent.com/u/8972?v=3","gravatar_id":"","url":"https://api.github.com/users/jeffmccune","html_url":"https://github.com/jeffmccune","followers_url":"https://api.github.com/users/jeffmccune/followers","following_url":"https://api.github.com/users/jeffmccune/following{/other_user}","gists_url":"https://api.github.com/users/jeffmccune/gists{/gist_id}","starred_url":"https://api.github.com/users/jeffmccune/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeffmccune/subscriptions","organizations_url":"https://api.github.com/users/jeffmccune/orgs","repos_url":"https://api.github.com/users/jeffmccune/repos","events_url":"https://api.github.com/users/jeffmccune/events{/privacy}","received_events_url":"https://api.github.com/users/jeffmccune/received_events","type":"User","site_admin":false},"body":"NOTE:\n\nThe ticket describes implementing the protocol function to wrap the middleware.\nThis work remains for this ticket and I'm in the process of implementing that\nnow.  I'm getting the PR up for early review, however, in an effort to get this\nin before the sprint ends.\n\n----\n\nThis patch establishes the basic structure of the TK service and implements\ninitialization logic that does the following:\n\n * pull in a \"rules\" vector from the \"authorization\" Trapperkeeper\n   configuration section (:ConfigService get-config)\n * do any initial structural validation that seems appropriate\n * transform that structure into the working\n   puppetlabs.trapperkeeper.authorization.rules.Rules vector that\n   \"trapperkeeper-authorization\" will need to use for its allowed? checks\n   later on\n * store the Rules vector into the service context\n\n(TK-258) Add transform-config-rule-to-acl function\n\nWithout this patch there is no way to transform a rule expressed as\ntrapperkeeper configuration into an Access Control List data structure.\nThis is a problem because we need to feed ACL objects into the\nauthorization library.  This patch addresses the problem by implementing\nthe transformation function.  The implementation starts with an empty acl,\nwhich itself is a sorted set, and then builds up the ACL by adding named\nrules for each allow and deny entry in the TK configuration.","created_at":"2015-08-18T20:47:26Z","updated_at":"2015-08-19T01:52:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d6888f690b52152c3cfdc02e91934d59fcbf9be7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/pulls/2/commits","review_comments_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/pulls/2/comments","review_comment_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/pulls/comments{/number}","comments_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/issues/2/comments","statuses_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/statuses/e16ea4b649b2163a9cd1fde3d97448fea6be1c18","head":{"label":"jeffmccune:task/master/TK-258_tk_authorization_service","ref":"task/master/TK-258_tk_authorization_service","sha":"e16ea4b649b2163a9cd1fde3d97448fea6be1c18","user":{"login":"jeffmccune","id":8972,"avatar_url":"https://avatars.githubusercontent.com/u/8972?v=3","gravatar_id":"","url":"https://api.github.com/users/jeffmccune","html_url":"https://github.com/jeffmccune","followers_url":"https://api.github.com/users/jeffmccune/followers","following_url":"https://api.github.com/users/jeffmccune/following{/other_user}","gists_url":"https://api.github.com/users/jeffmccune/gists{/gist_id}","starred_url":"https://api.github.com/users/jeffmccune/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeffmccune/subscriptions","organizations_url":"https://api.github.com/users/jeffmccune/orgs","repos_url":"https://api.github.com/users/jeffmccune/repos","events_url":"https://api.github.com/users/jeffmccune/events{/privacy}","received_events_url":"https://api.github.com/users/jeffmccune/received_events","type":"User","site_admin":false},"repo":{"id":40381787,"name":"trapperkeeper-authorization","full_name":"jeffmccune/trapperkeeper-authorization","owner":{"login":"jeffmccune","id":8972,"avatar_url":"https://avatars.githubusercontent.com/u/8972?v=3","gravatar_id":"","url":"https://api.github.com/users/jeffmccune","html_url":"https://github.com/jeffmccune","followers_url":"https://api.github.com/users/jeffmccune/followers","following_url":"https://api.github.com/users/jeffmccune/following{/other_user}","gists_url":"https://api.github.com/users/jeffmccune/gists{/gist_id}","starred_url":"https://api.github.com/users/jeffmccune/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeffmccune/subscriptions","organizations_url":"https://api.github.com/users/jeffmccune/orgs","repos_url":"https://api.github.com/users/jeffmccune/repos","events_url":"https://api.github.com/users/jeffmccune/events{/privacy}","received_events_url":"https://api.github.com/users/jeffmccune/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jeffmccune/trapperkeeper-authorization","description":"Fork of masterzen/trapperkeeper-authorization as a TK service","fork":true,"url":"https://api.github.com/repos/jeffmccune/trapperkeeper-authorization","forks_url":"https://api.github.com/repos/jeffmccune/trapperkeeper-authorization/forks","keys_url":"https://api.github.com/repos/jeffmccune/trapperkeeper-authorization/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jeffmccune/trapperkeeper-authorization/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jeffmccune/trapperkeeper-authorization/teams","hooks_url":"https://api.github.com/repos/jeffmccune/trapperkeeper-authorization/hooks","issue_events_url":"https://api.github.com/repos/jeffmccune/trapperkeeper-authorization/issues/events{/number}","events_url":"https://api.github.com/repos/jeffmccune/trapperkeeper-authorization/events","assignees_url":"https://api.github.com/repos/jeffmccune/trapperkeeper-authorization/assignees{/user}","branches_url":"https://api.github.com/repos/jeffmccune/trapperkeeper-authorization/branches{/branch}","tags_url":"https://api.github.com/repos/jeffmccune/trapperkeeper-authorization/tags","blobs_url":"https://api.github.com/repos/jeffmccune/trapperkeeper-authorization/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jeffmccune/trapperkeeper-authorization/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jeffmccune/trapperkeeper-authorization/git/refs{/sha}","trees_url":"https://api.github.com/repos/jeffmccune/trapperkeeper-authorization/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jeffmccune/trapperkeeper-authorization/statuses/{sha}","languages_url":"https://api.github.com/repos/jeffmccune/trapperkeeper-authorization/languages","stargazers_url":"https://api.github.com/repos/jeffmccune/trapperkeeper-authorization/stargazers","contributors_url":"https://api.github.com/repos/jeffmccune/trapperkeeper-authorization/contributors","subscribers_url":"https://api.github.com/repos/jeffmccune/trapperkeeper-authorization/subscribers","subscription_url":"https://api.github.com/repos/jeffmccune/trapperkeeper-authorization/subscription","commits_url":"https://api.github.com/repos/jeffmccune/trapperkeeper-authorization/commits{/sha}","git_commits_url":"https://api.github.com/repos/jeffmccune/trapperkeeper-authorization/git/commits{/sha}","comments_url":"https://api.github.com/repos/jeffmccune/trapperkeeper-authorization/comments{/number}","issue_comment_url":"https://api.github.com/repos/jeffmccune/trapperkeeper-authorization/issues/comments{/number}","contents_url":"https://api.github.com/repos/jeffmccune/trapperkeeper-authorization/contents/{+path}","compare_url":"https://api.github.com/repos/jeffmccune/trapperkeeper-authorization/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jeffmccune/trapperkeeper-authorization/merges","archive_url":"https://api.github.com/repos/jeffmccune/trapperkeeper-authorization/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jeffmccune/trapperkeeper-authorization/downloads","issues_url":"https://api.github.com/repos/jeffmccune/trapperkeeper-authorization/issues{/number}","pulls_url":"https://api.github.com/repos/jeffmccune/trapperkeeper-authorization/pulls{/number}","milestones_url":"https://api.github.com/repos/jeffmccune/trapperkeeper-authorization/milestones{/number}","notifications_url":"https://api.github.com/repos/jeffmccune/trapperkeeper-authorization/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jeffmccune/trapperkeeper-authorization/labels{/name}","releases_url":"https://api.github.com/repos/jeffmccune/trapperkeeper-authorization/releases{/id}","created_at":"2015-08-07T21:34:14Z","updated_at":"2015-08-07T21:34:14Z","pushed_at":"2015-08-19T01:41:42Z","git_url":"git://github.com/jeffmccune/trapperkeeper-authorization.git","ssh_url":"git@github.com:jeffmccune/trapperkeeper-authorization.git","clone_url":"https://github.com/jeffmccune/trapperkeeper-authorization.git","svn_url":"https://github.com/jeffmccune/trapperkeeper-authorization","homepage":null,"size":177,"stargazers_count":0,"watchers_count":0,"language":"Clojure","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"puppetlabs:master","ref":"master","sha":"1ac74458d6ee857f0fdcbf198584f635ed0ed1bd","user":{"login":"puppetlabs","id":234268,"avatar_url":"https://avatars.githubusercontent.com/u/234268?v=3","gravatar_id":"","url":"https://api.github.com/users/puppetlabs","html_url":"https://github.com/puppetlabs","followers_url":"https://api.github.com/users/puppetlabs/followers","following_url":"https://api.github.com/users/puppetlabs/following{/other_user}","gists_url":"https://api.github.com/users/puppetlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/puppetlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/puppetlabs/subscriptions","organizations_url":"https://api.github.com/users/puppetlabs/orgs","repos_url":"https://api.github.com/users/puppetlabs/repos","events_url":"https://api.github.com/users/puppetlabs/events{/privacy}","received_events_url":"https://api.github.com/users/puppetlabs/received_events","type":"Organization","site_admin":false},"repo":{"id":40329341,"name":"trapperkeeper-authorization","full_name":"puppetlabs/trapperkeeper-authorization","owner":{"login":"puppetlabs","id":234268,"avatar_url":"https://avatars.githubusercontent.com/u/234268?v=3","gravatar_id":"","url":"https://api.github.com/users/puppetlabs","html_url":"https://github.com/puppetlabs","followers_url":"https://api.github.com/users/puppetlabs/followers","following_url":"https://api.github.com/users/puppetlabs/following{/other_user}","gists_url":"https://api.github.com/users/puppetlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/puppetlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/puppetlabs/subscriptions","organizations_url":"https://api.github.com/users/puppetlabs/orgs","repos_url":"https://api.github.com/users/puppetlabs/repos","events_url":"https://api.github.com/users/puppetlabs/events{/privacy}","received_events_url":"https://api.github.com/users/puppetlabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/puppetlabs/trapperkeeper-authorization","description":"Fork of masterzen/trapperkeeper-authorization as a TK service","fork":false,"url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization","forks_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/forks","keys_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/keys{/key_id}","collaborators_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/teams","hooks_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/hooks","issue_events_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/issues/events{/number}","events_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/events","assignees_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/assignees{/user}","branches_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/branches{/branch}","tags_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/tags","blobs_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/git/refs{/sha}","trees_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/git/trees{/sha}","statuses_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/statuses/{sha}","languages_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/languages","stargazers_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/stargazers","contributors_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/contributors","subscribers_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/subscribers","subscription_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/subscription","commits_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/commits{/sha}","git_commits_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/git/commits{/sha}","comments_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/comments{/number}","issue_comment_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/issues/comments{/number}","contents_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/contents/{+path}","compare_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/compare/{base}...{head}","merges_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/merges","archive_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/downloads","issues_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/issues{/number}","pulls_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/pulls{/number}","milestones_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/milestones{/number}","notifications_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/labels{/name}","releases_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/releases{/id}","created_at":"2015-08-06T22:16:12Z","updated_at":"2015-08-07T18:32:57Z","pushed_at":"2015-08-19T01:41:42Z","git_url":"git://github.com/puppetlabs/trapperkeeper-authorization.git","ssh_url":"git@github.com:puppetlabs/trapperkeeper-authorization.git","clone_url":"https://github.com/puppetlabs/trapperkeeper-authorization.git","svn_url":"https://github.com/puppetlabs/trapperkeeper-authorization","homepage":null,"size":161,"stargazers_count":1,"watchers_count":1,"language":"Clojure","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":2,"forks":3,"open_issues":2,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/pulls/2"},"html":{"href":"https://github.com/puppetlabs/trapperkeeper-authorization/pull/2"},"issue":{"href":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/issues/2"},"comments":{"href":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/puppetlabs/trapperkeeper-authorization/statuses/e16ea4b649b2163a9cd1fde3d97448fea6be1c18"}}}}