*************
impersonation
*************
.. image:: https://img.shields.io/pypi/v/impersonation
:target: https://pypi.org/project/impersonation
:alt: PyPI version
.. image:: https://github.com/codectl/impersonation/actions/workflows/ci.yaml/badge.svg
:target: https://github.com/codectl/impersonation/actions/workflows/ci.yaml
:alt: CI
.. image:: https://codecov.io/gh/codectl/impersonation/branch/master/graph/badge.svg
:target: https://app.codecov.io/gh/codectl/impersonation/branch/master
:alt: codecov
.. image:: https://img.shields.io/pypi/pyversions/impersonation
:target: https://pypi.org/project/impersonation
:alt: Python compatibility
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/psf/black
:alt: code style: black
.. image:: https://img.shields.io/badge/License-MIT-yellow.svg
:target: https://opensource.org/licenses/MIT
:alt: license: MIT
A utility that allows a certain routine to run under a given user. To achieve this, a
process will run under the ``uid`` and ``gid`` of the intended user. For that
reason, it is a requirement that the running process has ``SETUID`` and
``SETGID`` capabilities.
Features
========
* decorator for instance methods
* decorator for ``classmethod`` and ``staticmethod``
* decorator for classes
Installation
============
Install the package directly from ``PyPI`` (recommended):
.. code-block:: bash
$ pip install -U impersonation
Example usage
=============
A simple example on how to work with a ``Flask`` application:
.. code-block:: python
from impersonation import impersonate
# it works on functions
@impersonate("username")
def printer(string):
print(string)
# ... and classes
@impersonate("username")
class Printer:
def __init__(self, prefix=""):
self.prefix = prefix
def printer1(self, string):
print(f"{self.prefix}{string}")
@staticmethod
def printer2(string):
print(string)
Tests & linting 🚥
==================
Run tests with ``tox``:
.. code-block:: bash
# ensure tox is installed
$ tox
Run linter only:
.. code-block:: bash
$ tox -e lint
Optionally, run coverage as well with:
.. code-block:: bash
$ tox -e coverage
License
=======
MIT licensed. See `LICENSE <LICENSE>`__.
Raw data
{
"_id": null,
"home_page": "https://github.com/codectl/impersonation",
"name": "impersonation",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8,<4.0",
"maintainer_email": "",
"keywords": "process,multiprocessing,impersonate,python,python3",
"author": "Renato Damas",
"author_email": "rena2damas@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/40/40/2e2064598d1d23015ce7b39952a0719b9c30a0a06538bbf6507788117cb4/impersonation-1.1.0.tar.gz",
"platform": null,
"description": "*************\nimpersonation\n*************\n\n.. image:: https://img.shields.io/pypi/v/impersonation\n :target: https://pypi.org/project/impersonation\n :alt: PyPI version\n.. image:: https://github.com/codectl/impersonation/actions/workflows/ci.yaml/badge.svg\n :target: https://github.com/codectl/impersonation/actions/workflows/ci.yaml\n :alt: CI\n.. image:: https://codecov.io/gh/codectl/impersonation/branch/master/graph/badge.svg\n :target: https://app.codecov.io/gh/codectl/impersonation/branch/master\n :alt: codecov\n.. image:: https://img.shields.io/pypi/pyversions/impersonation\n :target: https://pypi.org/project/impersonation\n :alt: Python compatibility\n.. image:: https://img.shields.io/badge/code%20style-black-000000.svg\n :target: https://github.com/psf/black\n :alt: code style: black\n.. image:: https://img.shields.io/badge/License-MIT-yellow.svg\n :target: https://opensource.org/licenses/MIT\n :alt: license: MIT\n\nA utility that allows a certain routine to run under a given user. To achieve this, a\nprocess will run under the ``uid`` and ``gid`` of the intended user. For that\nreason, it is a requirement that the running process has ``SETUID`` and\n``SETGID`` capabilities.\n\nFeatures\n========\n* decorator for instance methods\n* decorator for ``classmethod`` and ``staticmethod``\n* decorator for classes\n\nInstallation\n============\nInstall the package directly from ``PyPI`` (recommended):\n\n.. code-block:: bash\n\n $ pip install -U impersonation\n\nExample usage\n=============\nA simple example on how to work with a ``Flask`` application:\n\n.. code-block:: python\n\n from impersonation import impersonate\n\n\n # it works on functions\n @impersonate(\"username\")\n def printer(string):\n print(string)\n\n\n # ... and classes\n @impersonate(\"username\")\n class Printer:\n def __init__(self, prefix=\"\"):\n self.prefix = prefix\n\n def printer1(self, string):\n print(f\"{self.prefix}{string}\")\n\n @staticmethod\n def printer2(string):\n print(string)\n\nTests & linting \ud83d\udea5\n==================\nRun tests with ``tox``:\n\n.. code-block:: bash\n\n # ensure tox is installed\n $ tox\n\nRun linter only:\n\n.. code-block:: bash\n\n $ tox -e lint\n\nOptionally, run coverage as well with:\n\n.. code-block:: bash\n\n $ tox -e coverage\n\nLicense\n=======\nMIT licensed. See `LICENSE <LICENSE>`__.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Utility for user impersonation by running instructions under given user",
"version": "1.1.0",
"split_keywords": [
"process",
"multiprocessing",
"impersonate",
"python",
"python3"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3d3f1278310e11e2773ee89e973de21cddc9a998af01b5acdd8bcddd4f0eaf8f",
"md5": "ff817cad232ac1c8027accc8e76c5ce9",
"sha256": "8050910e1c5b45bb9094a5033cc82ba828e5d2f88fded3d6c4526642ceb8eedb"
},
"downloads": -1,
"filename": "impersonation-1.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ff817cad232ac1c8027accc8e76c5ce9",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8,<4.0",
"size": 4498,
"upload_time": "2023-03-31T18:35:09",
"upload_time_iso_8601": "2023-03-31T18:35:09.185425Z",
"url": "https://files.pythonhosted.org/packages/3d/3f/1278310e11e2773ee89e973de21cddc9a998af01b5acdd8bcddd4f0eaf8f/impersonation-1.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "40402e2064598d1d23015ce7b39952a0719b9c30a0a06538bbf6507788117cb4",
"md5": "7c14da2425b50726710c9f1006b06e69",
"sha256": "75f629e1ccff9c34592c1013346c830d70a6b5a7f79a49108e0eee274937b3df"
},
"downloads": -1,
"filename": "impersonation-1.1.0.tar.gz",
"has_sig": false,
"md5_digest": "7c14da2425b50726710c9f1006b06e69",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8,<4.0",
"size": 3748,
"upload_time": "2023-03-31T18:35:10",
"upload_time_iso_8601": "2023-03-31T18:35:10.859011Z",
"url": "https://files.pythonhosted.org/packages/40/40/2e2064598d1d23015ce7b39952a0719b9c30a0a06538bbf6507788117cb4/impersonation-1.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-03-31 18:35:10",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "codectl",
"github_project": "impersonation",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "impersonation"
}