{"action":"created","comment":{"url":"https://api.github.com/repos/tl-its-umich-edu/canvas/pulls/comments/25713988","id":25713988,"diff_hunk":"@@ -0,0 +1,171 @@\n+package edu.umich.ctools.sectionsUtilityTool;\n+\n+import java.io.IOException;\n+import java.util.Hashtable;\n+import java.util.Properties;\n+\n+import javax.naming.Context;\n+import javax.naming.NamingEnumeration;\n+import javax.naming.NamingException;\n+import javax.naming.directory.Attribute;\n+import javax.naming.directory.DirContext;\n+import javax.naming.directory.InitialDirContext;\n+import javax.naming.directory.SearchControls;\n+import javax.naming.directory.SearchResult;\n+import javax.servlet.Filter;\n+import javax.servlet.FilterChain;\n+import javax.servlet.FilterConfig;\n+import javax.servlet.ServletException;\n+import javax.servlet.ServletRequest;\n+import javax.servlet.ServletResponse;\n+import javax.servlet.http.HttpServletRequest;\n+import javax.servlet.http.HttpServletResponse;\n+\n+import org.apache.commons.logging.Log;\n+import org.apache.commons.logging.LogFactory;\n+\n+import edu.umich.its.lti.utils.PropertiesUtilities;\n+\n+\n+\n+public class SectionUtilityToolFilter implements Filter {\n+\tprivate static final String OU_GROUPS = \"ou=Groups\";\n+\tprivate static final String PROVIDER_URL = \"ldap://ldap.itd.umich.edu:389/dc=umich,dc=edu\";\n+\tprivate static final String LDAP_CTX_FACTORY = \"com.sun.jndi.ldap.LdapCtxFactory\";\n+\tprivate static final String ASSETS_PATH = \"/assets\";\n+\tprivate static Log M_log = LogFactory.getLog(SectionUtilityToolFilter.class);\n+\tprotected static final String SYSTEM_PROPERTY_FILE_PATH = \"sectionsToolPropsPath\";\n+\tprotected static final String PROPERTY_CANVAS_ADMIN = \"canvas.admin.token\";\n+\tprotected static final String PROPERTY_CANVAS_URL = \"canvas.url\";\n+\tprotected static final String PROPERTY_TEST_URL = \"test.url\";\n+\tprivate static final String AUTH_GROUP = \"its-canvas-sections\";\n+\tprivate static final String TEST_USER = \"testUser\";\n+\tprotected static Properties canvasProperties = null;\n+\tprivate boolean isTestUrlEnabled=false;\n+\n+\t@Override\n+\tpublic void init(FilterConfig filterConfig) throws ServletException {\n+\t\tM_log.debug(\"Filter Init(): Called\");\n+\t\tgetCanvasCredentials();\n+\t\t\n+\t}\n+\n+\t@Override\n+\tpublic void doFilter(ServletRequest request, ServletResponse response,\n+\t\t\tFilterChain chain) throws IOException, ServletException {\n+\t\tM_log.debug(\"doFilter: Called\");\n+\t\tHttpServletRequest useRequest = (HttpServletRequest) request;\n+\t\tHttpServletResponse useResponse=(HttpServletResponse)response;\n+\t\tif(!checkForAuthorization(useRequest)) {\n+\t\t      useResponse.sendError(403);\n+\t\t\treturn;\n+\t\t}\n+\t\tchain.doFilter(useRequest, response);\n+\t}\n+\n+\t@Override\n+\tpublic void destroy() {\n+\t\tM_log.debug(\"detroy: Called\");\n+\t}\n+\tprotected void getCanvasCredentials() {\n+\t\tM_log.debug(\"getCanvasCredentials(): called\");\n+\t\tString propertiesFilePath = System.getProperty(SYSTEM_PROPERTY_FILE_PATH);\n+\t\tif (!isEmpty(propertiesFilePath)) {\n+\t\tcanvasProperties=PropertiesUtilities.getPropertiesObjectFromURL(propertiesFilePath);\n+\t\t}else {\n+\t\t\tM_log.error(\"File path for (sectionsToolProps.properties) is not provided\");\n+\t\t}\n+\t\t\n+\t\t\n+\t}\n+\t private boolean isEmpty(String value) {\n+\t\treturn (value == null) || (value.trim().equals(\"\"));\n+\t}\n+\t\n+\t/*\n+\t * User is authenicated using cosign  authorized using Ldap. For local development we are enabling\n+\t * \"testUser\" parameter. \"testUser\" also go through the Ldap authorization process. \n+\t * we have test.url configured in the properties file in order to disable usage of \"testUser\" parameter in PROD.\n+\t * \"/assets\" folder is where all the js/css resources. I am not making those folder go through authorization process for\n+\t * 2 reasons 1) If the request of /index.html page fails we return the error page and that needs .css file for doing styling.\n+\t * 2) if /index.html is 200 ok, the next request that follows are /assets. so it kind of redundant to go through ldap check.","path":"sectionsUtilityTool/src/main/java/edu/umich/ctools/sectionsUtilityTool/SectionUtilityToolFilter.java","position":91,"original_position":91,"commit_id":"5fc37dc34c7d7f598b337c8421d682365e5cbc74","original_commit_id":"29eb5b936dec0e6f52a0113ec79fa667ef8c53c1","user":{"login":"pushyamig","id":8579775,"avatar_url":"https://avatars.githubusercontent.com/u/8579775?v=3","gravatar_id":"","url":"https://api.github.com/users/pushyamig","html_url":"https://github.com/pushyamig","followers_url":"https://api.github.com/users/pushyamig/followers","following_url":"https://api.github.com/users/pushyamig/following{/other_user}","gists_url":"https://api.github.com/users/pushyamig/gists{/gist_id}","starred_url":"https://api.github.com/users/pushyamig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pushyamig/subscriptions","organizations_url":"https://api.github.com/users/pushyamig/orgs","repos_url":"https://api.github.com/users/pushyamig/repos","events_url":"https://api.github.com/users/pushyamig/events{/privacy}","received_events_url":"https://api.github.com/users/pushyamig/received_events","type":"User","site_admin":false},"body":"I am letting /assets folder go through the authorization check now. For Error page request which need some css framework file  grabbed it  from CDN","created_at":"2015-03-03T18:46:10Z","updated_at":"2015-03-03T18:46:10Z","html_url":"https://github.com/tl-its-umich-edu/canvas/pull/16#discussion_r25713988","pull_request_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/pulls/16","_links":{"self":{"href":"https://api.github.com/repos/tl-its-umich-edu/canvas/pulls/comments/25713988"},"html":{"href":"https://github.com/tl-its-umich-edu/canvas/pull/16#discussion_r25713988"},"pull_request":{"href":"https://api.github.com/repos/tl-its-umich-edu/canvas/pulls/16"}}},"pull_request":{"url":"https://api.github.com/repos/tl-its-umich-edu/canvas/pulls/16","id":30287901,"html_url":"https://github.com/tl-its-umich-edu/canvas/pull/16","diff_url":"https://github.com/tl-its-umich-edu/canvas/pull/16.diff","patch_url":"https://github.com/tl-its-umich-edu/canvas/pull/16.patch","issue_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/issues/16","number":16,"state":"open","locked":false,"title":"Tlunizin 337","user":{"login":"pushyamig","id":8579775,"avatar_url":"https://avatars.githubusercontent.com/u/8579775?v=3","gravatar_id":"","url":"https://api.github.com/users/pushyamig","html_url":"https://github.com/pushyamig","followers_url":"https://api.github.com/users/pushyamig/followers","following_url":"https://api.github.com/users/pushyamig/following{/other_user}","gists_url":"https://api.github.com/users/pushyamig/gists{/gist_id}","starred_url":"https://api.github.com/users/pushyamig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pushyamig/subscriptions","organizations_url":"https://api.github.com/users/pushyamig/orgs","repos_url":"https://api.github.com/users/pushyamig/repos","events_url":"https://api.github.com/users/pushyamig/events{/privacy}","received_events_url":"https://api.github.com/users/pushyamig/received_events","type":"User","site_admin":false},"body":" Sections Utility tool is a service Desk application and should only have access to a particular Mcommunity group. I  have the Authorization check implemented in filter.  All the request go through the filter.","created_at":"2015-03-02T14:40:20Z","updated_at":"2015-03-03T18:46:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2e4f1a30debd3db022cde1a4e2749dbd84f8fd2b","assignee":{"login":"dlhaines","id":74063,"avatar_url":"https://avatars.githubusercontent.com/u/74063?v=3","gravatar_id":"","url":"https://api.github.com/users/dlhaines","html_url":"https://github.com/dlhaines","followers_url":"https://api.github.com/users/dlhaines/followers","following_url":"https://api.github.com/users/dlhaines/following{/other_user}","gists_url":"https://api.github.com/users/dlhaines/gists{/gist_id}","starred_url":"https://api.github.com/users/dlhaines/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dlhaines/subscriptions","organizations_url":"https://api.github.com/users/dlhaines/orgs","repos_url":"https://api.github.com/users/dlhaines/repos","events_url":"https://api.github.com/users/dlhaines/events{/privacy}","received_events_url":"https://api.github.com/users/dlhaines/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/pulls/16/commits","review_comments_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/pulls/16/comments","review_comment_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/issues/16/comments","statuses_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/statuses/5fc37dc34c7d7f598b337c8421d682365e5cbc74","head":{"label":"tl-its-umich-edu:TLUNIZIN-337","ref":"TLUNIZIN-337","sha":"5fc37dc34c7d7f598b337c8421d682365e5cbc74","user":{"login":"tl-its-umich-edu","id":8292960,"avatar_url":"https://avatars.githubusercontent.com/u/8292960?v=3","gravatar_id":"","url":"https://api.github.com/users/tl-its-umich-edu","html_url":"https://github.com/tl-its-umich-edu","followers_url":"https://api.github.com/users/tl-its-umich-edu/followers","following_url":"https://api.github.com/users/tl-its-umich-edu/following{/other_user}","gists_url":"https://api.github.com/users/tl-its-umich-edu/gists{/gist_id}","starred_url":"https://api.github.com/users/tl-its-umich-edu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tl-its-umich-edu/subscriptions","organizations_url":"https://api.github.com/users/tl-its-umich-edu/orgs","repos_url":"https://api.github.com/users/tl-its-umich-edu/repos","events_url":"https://api.github.com/users/tl-its-umich-edu/events{/privacy}","received_events_url":"https://api.github.com/users/tl-its-umich-edu/received_events","type":"Organization","site_admin":false},"repo":{"id":22355901,"name":"canvas","full_name":"tl-its-umich-edu/canvas","owner":{"login":"tl-its-umich-edu","id":8292960,"avatar_url":"https://avatars.githubusercontent.com/u/8292960?v=3","gravatar_id":"","url":"https://api.github.com/users/tl-its-umich-edu","html_url":"https://github.com/tl-its-umich-edu","followers_url":"https://api.github.com/users/tl-its-umich-edu/followers","following_url":"https://api.github.com/users/tl-its-umich-edu/following{/other_user}","gists_url":"https://api.github.com/users/tl-its-umich-edu/gists{/gist_id}","starred_url":"https://api.github.com/users/tl-its-umich-edu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tl-its-umich-edu/subscriptions","organizations_url":"https://api.github.com/users/tl-its-umich-edu/orgs","repos_url":"https://api.github.com/users/tl-its-umich-edu/repos","events_url":"https://api.github.com/users/tl-its-umich-edu/events{/privacy}","received_events_url":"https://api.github.com/users/tl-its-umich-edu/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tl-its-umich-edu/canvas","description":"Integration code between ITS TL and Instructure Canvas, as well as fill gaps in Canvas functionality","fork":false,"url":"https://api.github.com/repos/tl-its-umich-edu/canvas","forks_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/forks","keys_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/teams","hooks_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/hooks","issue_events_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/issues/events{/number}","events_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/events","assignees_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/assignees{/user}","branches_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/branches{/branch}","tags_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/tags","blobs_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/git/refs{/sha}","trees_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/statuses/{sha}","languages_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/languages","stargazers_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/stargazers","contributors_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/contributors","subscribers_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/subscribers","subscription_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/subscription","commits_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/commits{/sha}","git_commits_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/git/commits{/sha}","comments_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/comments{/number}","issue_comment_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/issues/comments{/number}","contents_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/contents/{+path}","compare_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/merges","archive_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/downloads","issues_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/issues{/number}","pulls_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/pulls{/number}","milestones_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/milestones{/number}","notifications_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/labels{/name}","releases_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/releases{/id}","created_at":"2014-07-28T19:59:20Z","updated_at":"2015-03-01T04:09:10Z","pushed_at":"2015-03-03T17:38:46Z","git_url":"git://github.com/tl-its-umich-edu/canvas.git","ssh_url":"git@github.com:tl-its-umich-edu/canvas.git","clone_url":"https://github.com/tl-its-umich-edu/canvas.git","svn_url":"https://github.com/tl-its-umich-edu/canvas","homepage":"","size":1381,"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":5,"forks":1,"open_issues":5,"watchers":0,"default_branch":"master"}},"base":{"label":"tl-its-umich-edu:master","ref":"master","sha":"aa7567e79609ab209b16aaa6f426a4ca28d41493","user":{"login":"tl-its-umich-edu","id":8292960,"avatar_url":"https://avatars.githubusercontent.com/u/8292960?v=3","gravatar_id":"","url":"https://api.github.com/users/tl-its-umich-edu","html_url":"https://github.com/tl-its-umich-edu","followers_url":"https://api.github.com/users/tl-its-umich-edu/followers","following_url":"https://api.github.com/users/tl-its-umich-edu/following{/other_user}","gists_url":"https://api.github.com/users/tl-its-umich-edu/gists{/gist_id}","starred_url":"https://api.github.com/users/tl-its-umich-edu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tl-its-umich-edu/subscriptions","organizations_url":"https://api.github.com/users/tl-its-umich-edu/orgs","repos_url":"https://api.github.com/users/tl-its-umich-edu/repos","events_url":"https://api.github.com/users/tl-its-umich-edu/events{/privacy}","received_events_url":"https://api.github.com/users/tl-its-umich-edu/received_events","type":"Organization","site_admin":false},"repo":{"id":22355901,"name":"canvas","full_name":"tl-its-umich-edu/canvas","owner":{"login":"tl-its-umich-edu","id":8292960,"avatar_url":"https://avatars.githubusercontent.com/u/8292960?v=3","gravatar_id":"","url":"https://api.github.com/users/tl-its-umich-edu","html_url":"https://github.com/tl-its-umich-edu","followers_url":"https://api.github.com/users/tl-its-umich-edu/followers","following_url":"https://api.github.com/users/tl-its-umich-edu/following{/other_user}","gists_url":"https://api.github.com/users/tl-its-umich-edu/gists{/gist_id}","starred_url":"https://api.github.com/users/tl-its-umich-edu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tl-its-umich-edu/subscriptions","organizations_url":"https://api.github.com/users/tl-its-umich-edu/orgs","repos_url":"https://api.github.com/users/tl-its-umich-edu/repos","events_url":"https://api.github.com/users/tl-its-umich-edu/events{/privacy}","received_events_url":"https://api.github.com/users/tl-its-umich-edu/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tl-its-umich-edu/canvas","description":"Integration code between ITS TL and Instructure Canvas, as well as fill gaps in Canvas functionality","fork":false,"url":"https://api.github.com/repos/tl-its-umich-edu/canvas","forks_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/forks","keys_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/teams","hooks_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/hooks","issue_events_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/issues/events{/number}","events_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/events","assignees_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/assignees{/user}","branches_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/branches{/branch}","tags_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/tags","blobs_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/git/refs{/sha}","trees_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/statuses/{sha}","languages_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/languages","stargazers_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/stargazers","contributors_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/contributors","subscribers_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/subscribers","subscription_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/subscription","commits_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/commits{/sha}","git_commits_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/git/commits{/sha}","comments_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/comments{/number}","issue_comment_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/issues/comments{/number}","contents_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/contents/{+path}","compare_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/merges","archive_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/downloads","issues_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/issues{/number}","pulls_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/pulls{/number}","milestones_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/milestones{/number}","notifications_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/labels{/name}","releases_url":"https://api.github.com/repos/tl-its-umich-edu/canvas/releases{/id}","created_at":"2014-07-28T19:59:20Z","updated_at":"2015-03-01T04:09:10Z","pushed_at":"2015-03-03T17:38:46Z","git_url":"git://github.com/tl-its-umich-edu/canvas.git","ssh_url":"git@github.com:tl-its-umich-edu/canvas.git","clone_url":"https://github.com/tl-its-umich-edu/canvas.git","svn_url":"https://github.com/tl-its-umich-edu/canvas","homepage":"","size":1381,"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":5,"forks":1,"open_issues":5,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tl-its-umich-edu/canvas/pulls/16"},"html":{"href":"https://github.com/tl-its-umich-edu/canvas/pull/16"},"issue":{"href":"https://api.github.com/repos/tl-its-umich-edu/canvas/issues/16"},"comments":{"href":"https://api.github.com/repos/tl-its-umich-edu/canvas/issues/16/comments"},"review_comments":{"href":"https://api.github.com/repos/tl-its-umich-edu/canvas/pulls/16/comments"},"review_comment":{"href":"https://api.github.com/repos/tl-its-umich-edu/canvas/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tl-its-umich-edu/canvas/pulls/16/commits"},"statuses":{"href":"https://api.github.com/repos/tl-its-umich-edu/canvas/statuses/5fc37dc34c7d7f598b337c8421d682365e5cbc74"}}}}