{ "info": { "author": "Suman Kumar", "author_email": "sumkumar@quotient.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Software Development :: Build Tools" ], "description": "Check Whitelisted IP\n=============\n\nThis is a simple security package to check whether client IP is allowed to access the flask`s backend APIs.\n\nBefore every endpoint is served, it will check for the remote IP if it exists in the list of white listed IPs, it it exists, it returns the response otherwise throws abort error:\n\n```\nHTTPErr: 403 Abort\n```\n\n\nSetup\n=====\n``` python\nfrom flask import Flask\nfrom security.check_ip import IPCheck\n\n# Initialize the Flask app\napp = Flask(__name__)\n\n# import IP_list from the config file or declare it here\n\nip_list = <>\n\nipcheck= IPCheck(app, ip_list)\n\n```\n\n\nNginx Routing\n====\n\nBy default headers of the incoming request gets updated with localhost IP when it is passed to the backend Nginx server.\nIn order to get the real IP of the client/LAN, we need to do following configurations in the nginx config:\n\n```\nserver {\n real_ip_recursive on;\n}\n\nlocation / {\n proxy_set_header Host $host;\n proxy_set_header X-Real-IP $remote_addr;\n proxy_set_header X-Forwarded-For $remote_addr;\n proxy_set_header X-Forwarded-Host $remote_addr;\n }\n \n```\n\n**sample incoming request header dict after naking above changes in Nginx**\n```\n{'wsgi.version': (1, 0), 'wsgi.url_scheme': 'http', \n'wsgi.input': '<_io.BufferedReader name=5>', 'wsgi.errors': <_io.TextIOWrapper name='' mode='w' encoding='UTF-8'>,\n'wsgi.multithread': True, \n'wsgi.multiprocess': False, 'wsgi.run_once': False, \n'werkzeug.server.shutdown': .shutdown_server at 0x7fba5d1bd598>, \n'SERVER_SOFTWARE': 'Werkzeug/0.14.1', 'REQUEST_METHOD': 'GET', 'SCRIPT_NAME': '', 'PATH_INFO': '/', 'QUERY_STRING': '', 'REMOTE_ADDR': '127.0.0.1', 'REMOTE_PORT': 39534, 'SERVER_NAME': '127.0.0.1', 'SERVER_PORT': '8002', 'SERVER_PROTOCOL': 'HTTP/1.0', \n'HTTP_HOST': '172.30.1.23', \n'HTTP_X_REAL_IP': '10.21.120.11', \n'HTTP_X_FORWARDED_FOR': '10.21.120.11', \n'HTTP_X_FORWARDED_HOST': '10.21.120.11', \n'HTTP_CONNECTION': 'close', 'HTTP_PRAGMA': 'no-cache', \n'HTTP_CACHE_CONTROL': 'no-cache', 'HTTP_UPGRADE_INSECURE_REQUESTS': '1', \n'HTTP_USER_AGENT': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Safari/537.36', \nHTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3', \n'HTTP_ACCEPT_ENCODING': 'gzip, deflate', 'HTTP_ACCEPT_LANGUAGE': 'en-GB,en-US;q=0.9,en;q=0.8', 'werkzeug.request': }\n\n```", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "quotient-security-check", "package_url": "https://pypi.org/project/quotient-security-check/", "platform": "", "project_url": "https://pypi.org/project/quotient-security-check/", "project_urls": null, "release_url": "https://pypi.org/project/quotient-security-check/0.0.1/", "requires_dist": null, "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4", "summary": "ip whitelisting security package", "version": "0.0.1" }, "last_serial": 5425257, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "6a06a53ff758d4fb02b754f311dc073d", "sha256": "3df6276d03743e3e51c0ecf69bbc78ff32814a3d12b9ed815fe8cf9566e7a4f9" }, "downloads": -1, "filename": "quotient-security-check-0.0.1.tar.gz", "has_sig": false, "md5_digest": "6a06a53ff758d4fb02b754f311dc073d", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4", "size": 5297, "upload_time": "2019-06-20T10:42:35", "url": "https://files.pythonhosted.org/packages/19/df/2e5dbe32669828bab4ddf8ef197be3821fd853d44ea14a84604bcf8712bd/quotient-security-check-0.0.1.tar.gz" } ], "0.0.1.dev0": [ { "comment_text": "", "digests": { "md5": "fbeb21c80e25fca1f36a0cdcc62a08bf", "sha256": "e2cf415a0b3a661196e497e1e35e9ca55d386529123a2d0f7c4df6854be693e0" }, "downloads": -1, "filename": "quotient-security-check-0.0.1.dev0.tar.gz", "has_sig": false, "md5_digest": "fbeb21c80e25fca1f36a0cdcc62a08bf", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4", "size": 3944, "upload_time": "2019-06-20T08:09:33", "url": "https://files.pythonhosted.org/packages/4c/c6/e275e6922f812a98f85a35e0930a3501faaecd34b6d0f23ac3296355bb68/quotient-security-check-0.0.1.dev0.tar.gz" } ], "0.0.1.dev1": [ { "comment_text": "", "digests": { "md5": "deb3bcc789cdb896d51083e1659eb392", "sha256": "0aac1ea03f1eb592655809d4b700fc2b9f251b9bf73d95ab278a15a19f300b8a" }, "downloads": -1, "filename": "quotient-security-check-0.0.1.dev1.tar.gz", "has_sig": false, "md5_digest": "deb3bcc789cdb896d51083e1659eb392", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4", "size": 4247, "upload_time": "2019-06-20T08:22:35", "url": "https://files.pythonhosted.org/packages/a6/ef/331285eed3400f091f44d8505cdf05ede7b11f34f7e6c763f7a4d1a2d38a/quotient-security-check-0.0.1.dev1.tar.gz" } ], "0.0.1.dev2": [ { "comment_text": "", "digests": { "md5": "fafcef3f089c9e677a0c7ded390d099b", "sha256": "29bd1607a4b4e3a179dbd8ddf124471b45786aeef1765e7e5b3a1d5e886f83fd" }, "downloads": -1, "filename": "quotient-security-check-0.0.1.dev2.tar.gz", "has_sig": false, "md5_digest": "fafcef3f089c9e677a0c7ded390d099b", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4", "size": 5211, "upload_time": "2019-06-20T10:27:53", "url": "https://files.pythonhosted.org/packages/71/35/328fab9f4d15083aeaafd388ee2259342f4097ded461486c90bc06c89c37/quotient-security-check-0.0.1.dev2.tar.gz" } ], "0.0.1.dev3": [ { "comment_text": "", "digests": { "md5": "0eb4efd663a8011ff467b7911ab8c1c9", "sha256": "f5d98c40da97effa6778da5db65e08a24e4bcd9865854a35f91fc5db53fc6f33" }, "downloads": -1, "filename": "quotient-security-check-0.0.1.dev3.tar.gz", "has_sig": false, "md5_digest": "0eb4efd663a8011ff467b7911ab8c1c9", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4", "size": 5298, "upload_time": "2019-06-20T10:37:43", "url": "https://files.pythonhosted.org/packages/6f/9a/ff23ad9ceb582d0202326034d336fd938e9d3bfd6e69a9dd7368818ae928/quotient-security-check-0.0.1.dev3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "6a06a53ff758d4fb02b754f311dc073d", "sha256": "3df6276d03743e3e51c0ecf69bbc78ff32814a3d12b9ed815fe8cf9566e7a4f9" }, "downloads": -1, "filename": "quotient-security-check-0.0.1.tar.gz", "has_sig": false, "md5_digest": "6a06a53ff758d4fb02b754f311dc073d", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4", "size": 5297, "upload_time": "2019-06-20T10:42:35", "url": "https://files.pythonhosted.org/packages/19/df/2e5dbe32669828bab4ddf8ef197be3821fd853d44ea14a84604bcf8712bd/quotient-security-check-0.0.1.tar.gz" } ] }