Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
djmoch committed Jan 15, 2022
0 parents commit fd25cf2
Show file tree
Hide file tree
Showing 18 changed files with 3,258 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.tox/
dist/
17 changes: 17 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ISC License (ISC)

Copyright 2022 Daniel Moch

Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
that the above copyright notice and this permission notice appear
in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA
OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
py9pfactotum
============

py9pfactotum is Python's plan9port Factotum client. It also provides
the following extras:

- Helper functions that mirror plan9port's auth(3) library
- A [Keyring](https://pypi.org/project/keyring/) backend to connect
to your running factotum server.

Usage
-----

In the current (alpha) state of maturity, the implementation is
incomplete. Currently enough is implemented to support the Keyring
backend (i.e., to read passwords from the running server).

When using the FactotumClient directly, arguments are passed as
keyword arguments, which are built into a key template internally:

```
from py9pfactotum import FactotumClient
c = FactotumClient()
c.getpass(server='mail.example.org', user='johndoe')
{ 'user': 'johndoe', 'passwd': 'insecure' }
```

As with the example above, the client provides high-level methods
that supply the correct 'proto' and 'role' attributes to the key
template. See factotum(4) for more information.

When using the auth(3) functions, the function signatures mirror
their plan9port counterparts, except that structures are replaced
with dictionaries.

```
from py9pfactotum import auth_getuserpasswd
c = auth_getuserpasswd(server='mail.example.org')
{ 'user': 'johndoe', 'passwd': 'insecure' }
```

Keyring
-------

The Keyring user interface is transparent, but that library must
be explicitly installed on the system (it is not a hard dependency
of py9pfactotum). Because factotum is not able to persist passwords
(or password deletions), attempts to use the Keyring to do so will
throw an error.
45 changes: 45 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[build-system]
requires = ["flit_core >=3.2,<4"]
build-backend = "flit_core.buildapi"

[project]
name = "py9pfactotum"
authors = [
{name = "Daniel Moch", email = "[email protected]"}
]
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: ISC License (ISCL)",
"License :: OSI Approved :: MIT License",
"Operating System :: POSIX",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
]
readme = "README.md"
requires-python = ">=3.7"
dynamic = ["version", "description"]

[project.urls]
Home = "https://git.danielmoch.com/py9pfactotum"

[project.optional-dependencies]
dev = [
"flake8",
"flit",
"keyring",
"mypy",
]

[project.entry-points."keyring.backends"]
factotum = "py9pfactotum.keyring"

[tool.mypy]
exclude = "/_vendor/"

[[tool.mypy.overrides]]
module = [
"py9pfactotum._vendor.py9p.py9p",
"py9pfactotum._vendor.py9p.utils",
]
follow_imports = "silent"
48 changes: 48 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#
# This file is autogenerated by pip-compile with python 3.9
# To update, run:
#
# pip-compile --extra=dev --output-file=requirements-dev.txt pyproject.toml
#
certifi==2021.10.8
# via requests
charset-normalizer==2.0.10
# via requests
docutils==0.18.1
# via flit
flake8==4.0.1
# via factotum (pyproject.toml)
flit==3.6.0
# via factotum (pyproject.toml)
flit-core==3.6.0
# via flit
idna==3.3
# via requests
importlib-metadata==4.10.0
# via keyring
keyring==23.5.0
# via factotum (pyproject.toml)
mccabe==0.6.1
# via flake8
mypy==0.931
# via factotum (pyproject.toml)
mypy-extensions==0.4.3
# via mypy
pycodestyle==2.8.0
# via flake8
pyflakes==2.4.0
# via flake8
requests==2.27.1
# via flit
tomli==2.0.0
# via
# flit
# mypy
tomli-w==1.0.0
# via flit
typing-extensions==4.0.1
# via mypy
urllib3==1.26.8
# via requests
zipp==3.7.0
# via importlib-metadata
20 changes: 20 additions & 0 deletions src/py9pfactotum/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""
The factotum module implements a plan9port's auth(3) library.
"""
from typing import Dict
from .client import FactotumClient

__version__ = '0.1.0.dev0'


def auth_getuserpasswd(**kwargs: str) -> Dict[str, str]:
"""
Retrieve a password from the factotum server. Kwargs should
contain the desired key template. Returns a dictionary containing
user and passwd keys.
Proto and role may optionally be omitted from the key template;
they are set within auth_getuserpasswd.
"""
c = FactotumClient()
return c.getpass(**kwargs)
21 changes: 21 additions & 0 deletions src/py9pfactotum/_vendor/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Copyright (c) 2008-2011 Tim Newsham, Andrey Mirtchovski
Copyright (c) 2011-2012 Peter V. Saveliev

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Empty file.
22 changes: 22 additions & 0 deletions src/py9pfactotum/_vendor/py9p/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright (c) 2011-2012 Peter V. Saveliev
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

__version__ = "1.0.9"
Loading

0 comments on commit fd25cf2

Please sign in to comment.