{ "info": { "author": "SOON_", "author_email": "dorks@thisissoon.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Framework :: Flask", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "License :: Public Domain", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Software Development", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Flask-HMAC\n==========\n\n|circle| |downloads| |version| |license|\n\nThis module provides an authentication to Flask routes. The intended use case\nis for use with REST APIs. It's simply designed to check that a client is\nentitled to access a particular route in a Flask application, based on the fact\nthat it must possess a copy of the secret key.\n\n\nUsage\n-----\n\nServer\n~~~~~~\n\n.. sourcecode:: python\n\n app = Flask(__name__)\n app.config['HMAC_KEY'] = 's3cr3tk3y' # define the secret key in an app config\n\n\n @app.route(\"/no_auth_view\")\n def no_auth_view():\n return \"no_auth_view\"\n\n\n @app.route(\"/hmac_auth_view\")\n @hmac.auth() # decorate view\n def hmac_auth_view():\n return \"hmac_auth_view\"\n\n @app.route(\"/hmac_auth_view\")\n @hmac.auth(only=[\"foo\"]) # decorate view, only allows foo client access\n def hmac_auth_view():\n return \"hmac_auth_view\"\n\n\nClient\n~~~~~~\n\n**Call without payload**\n\n\n.. sourcecode:: python\n\n sig = hmac.make_hmac() # generate signature\n response = requests.get(\n '/hmac_auth_view',\n headers={hmac.header: sig}\n )\n\n\nYou can also use multiple keys between different applications. Secret keys are\nstored in ``HMAC_KEYS`` in the app settings as a dictionary:\n\n.. sourcecode:: python\n\n app.config['HMAC_KEYS'] = {\n 'aservice': 'akey',\n 'bservice': 'bkey'\n }\n\n\nThen the secret key has to generated with `make_hmac_for` method.\n\n.. sourcecode:: python\n\n hmac.make_hmac_for('aservice', request_data) # data is optional\n\n # signature validation for multiple keys\n\n hmac.validate_service_signature(request)\n\n\n**Call with payload**\n\nRequest payload has to be used as a data for HMAC generation.\n\n.. sourcecode:: python\n\n data = json.dumps({'foo': 'boo'})\n\n sig = hmac.make_hmac(data) # generate signature\n response = requests.post(\n '/hmac_auth_view',\n data=data,\n headers={hmac.header: sig}\n )\n\n\n----\n\nYou can define custom errors overwriting ``abort`` method:\n\n.. sourcecode:: python\n\n class MyHmac(Hmac):\n\n def abort(self):\n message = {'status': '403', 'message': 'not authorized'}\n response = jsonify(message)\n response.status_code = 403\n return response\n\nFor HMAC auth of all views you can use ``Flask``'s ``before_request``:\n\n.. sourcecode:: python\n\n @app.before_request\n def before_request():\n try:\n hmac.validate_signature(request)\n except HmacException:\n return abort(400)\n\n\nGenerate signature for/from another application:\n\n.. sourcecode:: python\n\n sig = make_hmac(self, data, key=another_app_key)\n\n\n.. |circle| image:: https://img.shields.io/circleci/project/thisissoon/flask-hmac.svg\n :target: https://circleci.com/gh/thisissoon/flask-hmac\n\n.. |downloads| image:: http://img.shields.io/pypi/dm/flaskhmac.svg\n :target: https://pypi.python.org/pypi/flaskhmac\n\n.. |version| image:: http://img.shields.io/pypi/v/flaskhmac.svg\n :target: https://pypi.python.org/pypi/flaskhmac\n\n.. |license| image:: http://img.shields.io/pypi/l/flaskhmac.svg\n :target: https://pypi.python.org/pypi/flaskhmac\n\nChange Log\n----------\n\n1.2.1\n~~~~~\n- New `HMAC_ERROR_CODE` configuration option to allow different HTTP Status code responses on failure\n\n1.2\n~~~~~\n- BREAKING CHANGE: `@hmac.auth` decorator now needs to be called as `@hmac.auth()`\n- New `only` argument for `@hmac.auth()` to only allow specific clients access\n\n1.1.2\n~~~~~\n- Swaps `urlsafe_b64encode` for `b64encode`\n\n1.1.1\n~~~~~\n- Support multiple keys\n\n0.1.1\n~~~~~~~~~\n- Able to change secret key in `make_hmac` method\n- Method `validate_signature` created which can be used outside of `Hmac` class\n- Custom exceptions\n\n0.0.1\n~~~~~~~~~\n- Initial release including the core feature set", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/thisissoon/Flask-HMAC", "keywords": "Flask,HMAC,REST,Views", "license": "Public Domain", "maintainer": null, "maintainer_email": null, "name": "flaskhmac", "package_url": "https://pypi.org/project/flaskhmac/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/flaskhmac/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/thisissoon/Flask-HMAC" }, "release_url": "https://pypi.org/project/flaskhmac/1.2.1/", "requires_dist": null, "requires_python": null, "summary": "Provides easy integration of the HMAC signatures for your REST Flask Applications.", "version": "1.2.1" }, "last_serial": 1770257, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "0b7ff52fc8f31185037809a90c6f75ab", "sha256": "00c96672c7e2509611155d965e699e5f6731437009e2f269258100f7e309e7b5" }, "downloads": -1, "filename": "flaskhmac-0.0.1.tar.gz", "has_sig": false, "md5_digest": "0b7ff52fc8f31185037809a90c6f75ab", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3278, "upload_time": "2015-09-08T11:23:44", "url": "https://files.pythonhosted.org/packages/7b/5d/93745805057d497a4e02561cd0d8f8259779bcba10d71f2a489dec3d120d/flaskhmac-0.0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "e77990acbb8a0352e27835fbec180a36", "sha256": "d787085c5263b59c2240132963a26bff8dd810d30cf1452de9d03c65dcd9e9e1" }, "downloads": -1, "filename": "flaskhmac-0.1.1.tar.gz", "has_sig": false, "md5_digest": "e77990acbb8a0352e27835fbec180a36", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4034, "upload_time": "2015-09-15T09:15:47", "url": "https://files.pythonhosted.org/packages/ea/11/62fb6189643ba006073a1998fbb4ad3ed9935d596c6e0153a3ac14d5642e/flaskhmac-0.1.1.tar.gz" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "1a1ab519854f564ae74586c292512c77", "sha256": "636b4194bfa5010d7fa0f94df92925f3df4c932f0d38340650500937509b6279" }, "downloads": -1, "filename": "flaskhmac-1.1.1.tar.gz", "has_sig": false, "md5_digest": "1a1ab519854f564ae74586c292512c77", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4611, "upload_time": "2015-09-17T12:07:40", "url": "https://files.pythonhosted.org/packages/be/0b/ca47d7fa164de51def91b12a761af4a9d43592c3b74c20f2d77b4fb9af1d/flaskhmac-1.1.1.tar.gz" } ], "1.1.2": [ { "comment_text": "", "digests": { "md5": "4c7f7899fb86ea6bd79f4402d01ab8db", "sha256": "43cd39c81981ff8124e22e9e6808bb87a183a45cfa6432a47fa1bd9f781bbcb1" }, "downloads": -1, "filename": "flaskhmac-1.1.2.tar.gz", "has_sig": false, "md5_digest": "4c7f7899fb86ea6bd79f4402d01ab8db", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4657, "upload_time": "2015-09-17T17:33:27", "url": "https://files.pythonhosted.org/packages/50/68/552671140245c6fd606ddeb7e4d38a379a1781a7d9427a8253f0d4260843/flaskhmac-1.1.2.tar.gz" } ], "1.2": [ { "comment_text": "", "digests": { "md5": "392761c43ca08a1e7a554b862c957bd0", "sha256": "28b8b4c21bc98bc1808ced36b398f255574bdc27606a1bf8ddc22b7f8f935f3b" }, "downloads": -1, "filename": "flaskhmac-1.2.tar.gz", "has_sig": false, "md5_digest": "392761c43ca08a1e7a554b862c957bd0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4975, "upload_time": "2015-10-08T14:58:22", "url": "https://files.pythonhosted.org/packages/ad/71/50754085998d64668bc667ee489fa54acb2600fa2dbd025a419782480a26/flaskhmac-1.2.tar.gz" } ], "1.2.1": [ { "comment_text": "", "digests": { "md5": "796931dad80727e8098ecd74250d786e", "sha256": "3292ccc10b2649dd1fc400d460d16fad6c50c2e49c036634b39c82b30d8d2b22" }, "downloads": -1, "filename": "flaskhmac-1.2.1.tar.gz", "has_sig": false, "md5_digest": "796931dad80727e8098ecd74250d786e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5067, "upload_time": "2015-10-15T15:04:29", "url": "https://files.pythonhosted.org/packages/68/e3/07697177942de0c927ab44482d0aea1b98a987d559751c4bc0f14b0d56ea/flaskhmac-1.2.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "796931dad80727e8098ecd74250d786e", "sha256": "3292ccc10b2649dd1fc400d460d16fad6c50c2e49c036634b39c82b30d8d2b22" }, "downloads": -1, "filename": "flaskhmac-1.2.1.tar.gz", "has_sig": false, "md5_digest": "796931dad80727e8098ecd74250d786e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5067, "upload_time": "2015-10-15T15:04:29", "url": "https://files.pythonhosted.org/packages/68/e3/07697177942de0c927ab44482d0aea1b98a987d559751c4bc0f14b0d56ea/flaskhmac-1.2.1.tar.gz" } ] }