{"action":"created","comment":{"url":"https://api.github.com/repos/nvie/rq-dashboard/pulls/comments/31890589","id":31890589,"diff_hunk":"@@ -71,17 +86,35 @@ def configure_app(app, options):\n         app.config['REDIS_DB'] = options.redis_database\n     if options.poll_interval:\n         app.config['RQ_POLL_INTERVAL'] = options.poll_interval\n-    if options.url_prefix:\n-        app.config['URL_PREFIX'] = options.url_prefix\n-    app.config['REDIS_URL'] = options.redis_url_connection or None\n \n \n-def run_app(app):\n-    print('RQ Dashboard, version %s' % VERSION)\n-    rq_dashboard.RQDashboard(app, url_prefix=app.config.get('URL_PREFIX', ''))\n-    app.run(host=app.config['BIND_ADDR'], port=app.config['PORT'])\n+def add_basic_auth(blueprint, username, password, realm='RQ Dashboard'):\n+    \"\"\"Add HTTP Basic Auth to the blueprint.\n+\n+    Note this is only for casual use!\n \n+    \"\"\"\n+    @blueprint.before_request\n+    def basic_http_auth(*args, **kwargs):\n+        auth = request.authorization\n+        if (\n+                auth is None\n+                or auth.password != password\n+                or auth.username != username):\n+            return Response(\n+                'Please login',\n+                401,\n+                {'WWW-Authenticate': 'Basic realm=\"{}\"'.format(realm)})\n \n-if __name__ == '__main__':\n-    main()\n \n+def main():\n+    \"\"\"Command line entry point defined in setup.py.\"\"\"\n+    print('RQ Dashboard version {}'.format(get_version()))\n+    blueprint = rq_dashboard.blueprint.blueprint\n+    options = get_options()\n+    if options.username:\n+        add_basic_auth(blueprint, options.username, options.password)","path":"rq_dashboard/scripts/rq_dashboard.py","position":143,"original_position":143,"commit_id":"6b3a871b14d8d3c68f1bfa83257af9523e754261","original_commit_id":"6b3a871b14d8d3c68f1bfa83257af9523e754261","user":{"login":"joostdevries","id":3824616,"avatar_url":"https://avatars.githubusercontent.com/u/3824616?v=3","gravatar_id":"","url":"https://api.github.com/users/joostdevries","html_url":"https://github.com/joostdevries","followers_url":"https://api.github.com/users/joostdevries/followers","following_url":"https://api.github.com/users/joostdevries/following{/other_user}","gists_url":"https://api.github.com/users/joostdevries/gists{/gist_id}","starred_url":"https://api.github.com/users/joostdevries/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joostdevries/subscriptions","organizations_url":"https://api.github.com/users/joostdevries/orgs","repos_url":"https://api.github.com/users/joostdevries/repos","events_url":"https://api.github.com/users/joostdevries/events{/privacy}","received_events_url":"https://api.github.com/users/joostdevries/received_events","type":"User","site_admin":false},"body":"I'd either wait with introducing this feature or add config+ENV support now.","created_at":"2015-06-08T07:09:18Z","updated_at":"2015-06-08T07:09:18Z","html_url":"https://github.com/nvie/rq-dashboard/pull/80#discussion_r31890589","pull_request_url":"https://api.github.com/repos/nvie/rq-dashboard/pulls/80","_links":{"self":{"href":"https://api.github.com/repos/nvie/rq-dashboard/pulls/comments/31890589"},"html":{"href":"https://github.com/nvie/rq-dashboard/pull/80#discussion_r31890589"},"pull_request":{"href":"https://api.github.com/repos/nvie/rq-dashboard/pulls/80"}}},"pull_request":{"url":"https://api.github.com/repos/nvie/rq-dashboard/pulls/80","id":37091701,"html_url":"https://github.com/nvie/rq-dashboard/pull/80","diff_url":"https://github.com/nvie/rq-dashboard/pull/80.diff","patch_url":"https://github.com/nvie/rq-dashboard/pull/80.patch","issue_url":"https://api.github.com/repos/nvie/rq-dashboard/issues/80","number":80,"state":"open","locked":false,"title":"Tidy invocation","user":{"login":"tcorbettclark","id":1202090,"avatar_url":"https://avatars.githubusercontent.com/u/1202090?v=3","gravatar_id":"","url":"https://api.github.com/users/tcorbettclark","html_url":"https://github.com/tcorbettclark","followers_url":"https://api.github.com/users/tcorbettclark/followers","following_url":"https://api.github.com/users/tcorbettclark/following{/other_user}","gists_url":"https://api.github.com/users/tcorbettclark/gists{/gist_id}","starred_url":"https://api.github.com/users/tcorbettclark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tcorbettclark/subscriptions","organizations_url":"https://api.github.com/users/tcorbettclark/orgs","repos_url":"https://api.github.com/users/tcorbettclark/repos","events_url":"https://api.github.com/users/tcorbettclark/events{/privacy}","received_events_url":"https://api.github.com/users/tcorbettclark/received_events","type":"User","site_admin":false},"body":"1. PEP8 coding style\r\n2. Remove use of flask extensions because not appropriate/standard. It was only\r\n    being used to provide a hook for authentication, which would probably be done\r\n    separately by the main Flask app (or by a reverse proxy). Issue #73 requests basic auth which I will\r\n    add in a separate pull request because it is unrelated to this tidy.\r\n3. Removed app.py since it was not used and you would never use it from within a\r\n    Flask app. The scripts/rq_dashboard.py provides an example use.\r\n4. Emptied rq_dashboard/__init__.py for same reason as previous.\r\n5. Moved fundamental dashboard configuration into separate file (one of\r\n   recommended approaches).\r\n6. Separated the command line configuration options (port and bind_addr) from\r\n    the inherent rq dashboard options required for separate Flask hosting\r\n7. Tidied how we set package version at build time and fetch version at run time.\r\n8. Renamed dashboard.py to blueprint.py because we have too many \"rq_dashboard\"s\r\n    and \"dashboard\"s around.","created_at":"2015-06-06T15:10:28Z","updated_at":"2015-06-08T07:09:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"178cf7103da265838329e1e66f5dc12e93ab9734","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/nvie/rq-dashboard/pulls/80/commits","review_comments_url":"https://api.github.com/repos/nvie/rq-dashboard/pulls/80/comments","review_comment_url":"https://api.github.com/repos/nvie/rq-dashboard/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nvie/rq-dashboard/issues/80/comments","statuses_url":"https://api.github.com/repos/nvie/rq-dashboard/statuses/6b3a871b14d8d3c68f1bfa83257af9523e754261","head":{"label":"nvie:tidy-invocation","ref":"tidy-invocation","sha":"6b3a871b14d8d3c68f1bfa83257af9523e754261","user":{"login":"nvie","id":83844,"avatar_url":"https://avatars.githubusercontent.com/u/83844?v=3","gravatar_id":"","url":"https://api.github.com/users/nvie","html_url":"https://github.com/nvie","followers_url":"https://api.github.com/users/nvie/followers","following_url":"https://api.github.com/users/nvie/following{/other_user}","gists_url":"https://api.github.com/users/nvie/gists{/gist_id}","starred_url":"https://api.github.com/users/nvie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nvie/subscriptions","organizations_url":"https://api.github.com/users/nvie/orgs","repos_url":"https://api.github.com/users/nvie/repos","events_url":"https://api.github.com/users/nvie/events{/privacy}","received_events_url":"https://api.github.com/users/nvie/received_events","type":"User","site_admin":false},"repo":{"id":3310740,"name":"rq-dashboard","full_name":"nvie/rq-dashboard","owner":{"login":"nvie","id":83844,"avatar_url":"https://avatars.githubusercontent.com/u/83844?v=3","gravatar_id":"","url":"https://api.github.com/users/nvie","html_url":"https://github.com/nvie","followers_url":"https://api.github.com/users/nvie/followers","following_url":"https://api.github.com/users/nvie/following{/other_user}","gists_url":"https://api.github.com/users/nvie/gists{/gist_id}","starred_url":"https://api.github.com/users/nvie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nvie/subscriptions","organizations_url":"https://api.github.com/users/nvie/orgs","repos_url":"https://api.github.com/users/nvie/repos","events_url":"https://api.github.com/users/nvie/events{/privacy}","received_events_url":"https://api.github.com/users/nvie/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nvie/rq-dashboard","description":"Flask-based web front-end for monitoring RQ queues.","fork":false,"url":"https://api.github.com/repos/nvie/rq-dashboard","forks_url":"https://api.github.com/repos/nvie/rq-dashboard/forks","keys_url":"https://api.github.com/repos/nvie/rq-dashboard/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nvie/rq-dashboard/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nvie/rq-dashboard/teams","hooks_url":"https://api.github.com/repos/nvie/rq-dashboard/hooks","issue_events_url":"https://api.github.com/repos/nvie/rq-dashboard/issues/events{/number}","events_url":"https://api.github.com/repos/nvie/rq-dashboard/events","assignees_url":"https://api.github.com/repos/nvie/rq-dashboard/assignees{/user}","branches_url":"https://api.github.com/repos/nvie/rq-dashboard/branches{/branch}","tags_url":"https://api.github.com/repos/nvie/rq-dashboard/tags","blobs_url":"https://api.github.com/repos/nvie/rq-dashboard/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nvie/rq-dashboard/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nvie/rq-dashboard/git/refs{/sha}","trees_url":"https://api.github.com/repos/nvie/rq-dashboard/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nvie/rq-dashboard/statuses/{sha}","languages_url":"https://api.github.com/repos/nvie/rq-dashboard/languages","stargazers_url":"https://api.github.com/repos/nvie/rq-dashboard/stargazers","contributors_url":"https://api.github.com/repos/nvie/rq-dashboard/contributors","subscribers_url":"https://api.github.com/repos/nvie/rq-dashboard/subscribers","subscription_url":"https://api.github.com/repos/nvie/rq-dashboard/subscription","commits_url":"https://api.github.com/repos/nvie/rq-dashboard/commits{/sha}","git_commits_url":"https://api.github.com/repos/nvie/rq-dashboard/git/commits{/sha}","comments_url":"https://api.github.com/repos/nvie/rq-dashboard/comments{/number}","issue_comment_url":"https://api.github.com/repos/nvie/rq-dashboard/issues/comments{/number}","contents_url":"https://api.github.com/repos/nvie/rq-dashboard/contents/{+path}","compare_url":"https://api.github.com/repos/nvie/rq-dashboard/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nvie/rq-dashboard/merges","archive_url":"https://api.github.com/repos/nvie/rq-dashboard/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nvie/rq-dashboard/downloads","issues_url":"https://api.github.com/repos/nvie/rq-dashboard/issues{/number}","pulls_url":"https://api.github.com/repos/nvie/rq-dashboard/pulls{/number}","milestones_url":"https://api.github.com/repos/nvie/rq-dashboard/milestones{/number}","notifications_url":"https://api.github.com/repos/nvie/rq-dashboard/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nvie/rq-dashboard/labels{/name}","releases_url":"https://api.github.com/repos/nvie/rq-dashboard/releases{/id}","created_at":"2012-01-31T01:14:16Z","updated_at":"2015-06-05T02:58:13Z","pushed_at":"2015-06-06T19:25:11Z","git_url":"git://github.com/nvie/rq-dashboard.git","ssh_url":"git@github.com:nvie/rq-dashboard.git","clone_url":"https://github.com/nvie/rq-dashboard.git","svn_url":"https://github.com/nvie/rq-dashboard","homepage":"http://python-rq.org/","size":736,"stargazers_count":359,"watchers_count":359,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":84,"mirror_url":null,"open_issues_count":7,"forks":84,"open_issues":7,"watchers":359,"default_branch":"master"}},"base":{"label":"nvie:master","ref":"master","sha":"d2fa071fa5b0af1893ed1e616058a0043d2eb75b","user":{"login":"nvie","id":83844,"avatar_url":"https://avatars.githubusercontent.com/u/83844?v=3","gravatar_id":"","url":"https://api.github.com/users/nvie","html_url":"https://github.com/nvie","followers_url":"https://api.github.com/users/nvie/followers","following_url":"https://api.github.com/users/nvie/following{/other_user}","gists_url":"https://api.github.com/users/nvie/gists{/gist_id}","starred_url":"https://api.github.com/users/nvie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nvie/subscriptions","organizations_url":"https://api.github.com/users/nvie/orgs","repos_url":"https://api.github.com/users/nvie/repos","events_url":"https://api.github.com/users/nvie/events{/privacy}","received_events_url":"https://api.github.com/users/nvie/received_events","type":"User","site_admin":false},"repo":{"id":3310740,"name":"rq-dashboard","full_name":"nvie/rq-dashboard","owner":{"login":"nvie","id":83844,"avatar_url":"https://avatars.githubusercontent.com/u/83844?v=3","gravatar_id":"","url":"https://api.github.com/users/nvie","html_url":"https://github.com/nvie","followers_url":"https://api.github.com/users/nvie/followers","following_url":"https://api.github.com/users/nvie/following{/other_user}","gists_url":"https://api.github.com/users/nvie/gists{/gist_id}","starred_url":"https://api.github.com/users/nvie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nvie/subscriptions","organizations_url":"https://api.github.com/users/nvie/orgs","repos_url":"https://api.github.com/users/nvie/repos","events_url":"https://api.github.com/users/nvie/events{/privacy}","received_events_url":"https://api.github.com/users/nvie/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nvie/rq-dashboard","description":"Flask-based web front-end for monitoring RQ queues.","fork":false,"url":"https://api.github.com/repos/nvie/rq-dashboard","forks_url":"https://api.github.com/repos/nvie/rq-dashboard/forks","keys_url":"https://api.github.com/repos/nvie/rq-dashboard/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nvie/rq-dashboard/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nvie/rq-dashboard/teams","hooks_url":"https://api.github.com/repos/nvie/rq-dashboard/hooks","issue_events_url":"https://api.github.com/repos/nvie/rq-dashboard/issues/events{/number}","events_url":"https://api.github.com/repos/nvie/rq-dashboard/events","assignees_url":"https://api.github.com/repos/nvie/rq-dashboard/assignees{/user}","branches_url":"https://api.github.com/repos/nvie/rq-dashboard/branches{/branch}","tags_url":"https://api.github.com/repos/nvie/rq-dashboard/tags","blobs_url":"https://api.github.com/repos/nvie/rq-dashboard/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nvie/rq-dashboard/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nvie/rq-dashboard/git/refs{/sha}","trees_url":"https://api.github.com/repos/nvie/rq-dashboard/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nvie/rq-dashboard/statuses/{sha}","languages_url":"https://api.github.com/repos/nvie/rq-dashboard/languages","stargazers_url":"https://api.github.com/repos/nvie/rq-dashboard/stargazers","contributors_url":"https://api.github.com/repos/nvie/rq-dashboard/contributors","subscribers_url":"https://api.github.com/repos/nvie/rq-dashboard/subscribers","subscription_url":"https://api.github.com/repos/nvie/rq-dashboard/subscription","commits_url":"https://api.github.com/repos/nvie/rq-dashboard/commits{/sha}","git_commits_url":"https://api.github.com/repos/nvie/rq-dashboard/git/commits{/sha}","comments_url":"https://api.github.com/repos/nvie/rq-dashboard/comments{/number}","issue_comment_url":"https://api.github.com/repos/nvie/rq-dashboard/issues/comments{/number}","contents_url":"https://api.github.com/repos/nvie/rq-dashboard/contents/{+path}","compare_url":"https://api.github.com/repos/nvie/rq-dashboard/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nvie/rq-dashboard/merges","archive_url":"https://api.github.com/repos/nvie/rq-dashboard/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nvie/rq-dashboard/downloads","issues_url":"https://api.github.com/repos/nvie/rq-dashboard/issues{/number}","pulls_url":"https://api.github.com/repos/nvie/rq-dashboard/pulls{/number}","milestones_url":"https://api.github.com/repos/nvie/rq-dashboard/milestones{/number}","notifications_url":"https://api.github.com/repos/nvie/rq-dashboard/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nvie/rq-dashboard/labels{/name}","releases_url":"https://api.github.com/repos/nvie/rq-dashboard/releases{/id}","created_at":"2012-01-31T01:14:16Z","updated_at":"2015-06-05T02:58:13Z","pushed_at":"2015-06-06T19:25:11Z","git_url":"git://github.com/nvie/rq-dashboard.git","ssh_url":"git@github.com:nvie/rq-dashboard.git","clone_url":"https://github.com/nvie/rq-dashboard.git","svn_url":"https://github.com/nvie/rq-dashboard","homepage":"http://python-rq.org/","size":736,"stargazers_count":359,"watchers_count":359,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":84,"mirror_url":null,"open_issues_count":7,"forks":84,"open_issues":7,"watchers":359,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nvie/rq-dashboard/pulls/80"},"html":{"href":"https://github.com/nvie/rq-dashboard/pull/80"},"issue":{"href":"https://api.github.com/repos/nvie/rq-dashboard/issues/80"},"comments":{"href":"https://api.github.com/repos/nvie/rq-dashboard/issues/80/comments"},"review_comments":{"href":"https://api.github.com/repos/nvie/rq-dashboard/pulls/80/comments"},"review_comment":{"href":"https://api.github.com/repos/nvie/rq-dashboard/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nvie/rq-dashboard/pulls/80/commits"},"statuses":{"href":"https://api.github.com/repos/nvie/rq-dashboard/statuses/6b3a871b14d8d3c68f1bfa83257af9523e754261"}}}}