{ "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": "QMUtilities\n=============\n\nIts a generic Utils library from where you can import various modules. Below are the modules and their installation steps with usage description\n\npypi library link: https://pypi.org/project/QMUtilities/\n\nMODULE:1 Config Based IP security\n=============\n\nThis is a simple security module 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 and it also checks if it has valid okta token, if it meets both the conditions, it passes through firewall to access API otherwise it throws abort error:\n\n```\nHTTPErr: 403 Abort\n```\n\n\nSetup\n=====\n\n```\n1. Create VirtualENV\n2. source VirtualENV\n3. pip install 'QMUtilities==0.0.1'\n4. create a stored secret at secret manager and store below keys and correspoding values of memcache server\n \n aws_elastic_cache_hostname : \n port : \n```\n\n``` python\nfrom flask import Flask\nfrom security.validate import ValidateHeader\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\nsecret_name = \n\nipcheck= ValidateHeader(app, ip_list, secret_name)\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```\n\nMODULE2: Allow access APIs after validating OKTA Tokens\n=======\n\nOkta tokens will be read from the headers and validated before accessing any API", "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": "QMUtilities", "package_url": "https://pypi.org/project/QMUtilities/", "platform": "", "project_url": "https://pypi.org/project/QMUtilities/", "project_urls": null, "release_url": "https://pypi.org/project/QMUtilities/0.0.2/", "requires_dist": null, "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4", "summary": "ip whitelisting security module and okta token validator", "version": "0.0.2" }, "last_serial": 5763722, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "dbf2c35706b037290de99ba054e439b3", "sha256": "228d94e6ad2dd1338e040c3b725ea2691da7659b1ec9e0e7e9d1f510552f88cc" }, "downloads": -1, "filename": "QMUtilities-0.0.1.tar.gz", "has_sig": false, "md5_digest": "dbf2c35706b037290de99ba054e439b3", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4", "size": 5471, "upload_time": "2019-06-27T11:42:22", "url": "https://files.pythonhosted.org/packages/1d/2e/5c5aa6dcc41a4a5c9f8ab380d5b19b5b9ffba1eca54cfc824c8ee56b7708/QMUtilities-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "1420bd373aa0552db05450fd5251873a", "sha256": "0dcde1fde032b70bf05b3803d6b2db32ee198d9c3a0e06df565792246256822c" }, "downloads": -1, "filename": "QMUtilities-0.0.2.tar.gz", "has_sig": false, "md5_digest": "1420bd373aa0552db05450fd5251873a", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4", "size": 6988, "upload_time": "2019-08-31T07:26:42", "url": "https://files.pythonhosted.org/packages/f6/f0/128141483acdc9e6d941707a56a660e9e4d811edc2ae17680fd959df4f80/QMUtilities-0.0.2.tar.gz" } ], "0.0.2.dev0": [ { "comment_text": "", "digests": { "md5": "6aa3c020297cda5bb1333e41280ce297", "sha256": "a3d525b3c5ab09715f5a9e8cd1ded728c9fc64148d9597ad5dab7b9adc376475" }, "downloads": -1, "filename": "QMUtilities-0.0.2.dev0.tar.gz", "has_sig": false, "md5_digest": "6aa3c020297cda5bb1333e41280ce297", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4", "size": 6824, "upload_time": "2019-08-23T19:24:17", "url": "https://files.pythonhosted.org/packages/58/be/af9e2c7fdeeca58c43723c1c346dd1afb3e12ba05e8d090c28a295872e6e/QMUtilities-0.0.2.dev0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1420bd373aa0552db05450fd5251873a", "sha256": "0dcde1fde032b70bf05b3803d6b2db32ee198d9c3a0e06df565792246256822c" }, "downloads": -1, "filename": "QMUtilities-0.0.2.tar.gz", "has_sig": false, "md5_digest": "1420bd373aa0552db05450fd5251873a", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4", "size": 6988, "upload_time": "2019-08-31T07:26:42", "url": "https://files.pythonhosted.org/packages/f6/f0/128141483acdc9e6d941707a56a660e9e4d811edc2ae17680fd959df4f80/QMUtilities-0.0.2.tar.gz" } ] }