impersonation
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):
$ pip install -U impersonation
Example usage
A simple example on how to work with a Flask application:
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:
# ensure tox is installed
$ tox
Run linter only:
$ tox -e lint
Optionally, run coverage as well with:
$ tox -e coverage
License
MIT licensed. See LICENSE.
Metadata
Release files for impersonation 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| impersonation-1.1.0.tar.gz | 3.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| impersonation-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.2 kB
Release files / impersonation-1.1.0.tar.gz
| Download URL | impersonation-1.1.0.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
75f629e1ccff9c34592c1013346c830d70a6b5a7f79a49108e0eee274937b3df
|
|
BLAKE2b-256 checksum How to use checksums |
40402e2064598d1d23015ce7b39952a0719b9c30a0a06538bbf6507788117cb4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.1 CPython/3.9.16 Linux/5.15.0-1034-azure
|
Release files / impersonation-1.1.0-py3-none-any.whl
| Download URL | impersonation-1.1.0-py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8050910e1c5b45bb9094a5033cc82ba828e5d2f88fded3d6c4526642ceb8eedb
|
|
BLAKE2b-256 checksum How to use checksums |
3d3f1278310e11e2773ee89e973de21cddc9a998af01b5acdd8bcddd4f0eaf8f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.1 CPython/3.9.16 Linux/5.15.0-1034-azure
|