Compare commits

...

7 Commits

Author SHA1 Message Date
Felipe Martin Garcia 84dd2fb30f
Merge pull request #1 from fmartingr/dependabot/pip/urllib3-1.24.2
Bump urllib3 from 1.24.1 to 1.24.2
2021-06-15 10:52:37 +02:00
dependabot[bot] 0c72e8fa8b
Bump urllib3 from 1.24.1 to 1.24.2
Bumps [urllib3](https://github.com/urllib3/urllib3) from 1.24.1 to 1.24.2.
- [Release notes](https://github.com/urllib3/urllib3/releases)
- [Changelog](https://github.com/urllib3/urllib3/blob/master/CHANGES.rst)
- [Commits](https://github.com/urllib3/urllib3/compare/1.24.1...1.24.2)

Signed-off-by: dependabot[bot] <support@github.com>
2019-10-21 17:48:18 +00:00
Felipe Martin cb31a39d4f
Updated requirements, using pipenv 2018-12-03 15:13:18 +01:00
Felipe Martín 25d3a80b07 Prettified README file 2016-10-08 16:15:42 +02:00
Felipe Martín 2abd0b84f8 Version bump 0.2.0 2016-10-08 16:07:24 +02:00
Felipe Martín 2592077134 Updated request library version 2016-10-08 16:06:43 +02:00
Felipe Martin 37cc29fad7 Cleaned some code/gitignore and commented the classes 2013-07-21 16:25:58 +02:00
7 changed files with 98 additions and 14 deletions

3
.gitignore vendored
View File

@ -1,3 +1,6 @@
.c9revisions/
tests.py
*.pyc
build/
dist/
*.egg-info

12
Pipfile Normal file
View File

@ -0,0 +1,12 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
[packages]
requests = "*"
[requires]
python_version = "2.7"

58
Pipfile.lock generated Normal file
View File

@ -0,0 +1,58 @@
{
"_meta": {
"hash": {
"sha256": "9838c8bf3aa442453b393e09e534ba7e1666aab4da1b9b408ecdf3ae58ab273c"
},
"pipfile-spec": 6,
"requires": {
"python_version": "2.7"
},
"sources": [
{
"name": "pypi",
"url": "https://pypi.org/simple",
"verify_ssl": true
}
]
},
"default": {
"certifi": {
"hashes": [
"sha256:e4f3620cfea4f83eedc95b24abd9cd56f3c4b146dd0177e83a21b4eb49e21e50",
"sha256:fd7c7c74727ddcf00e9acd26bba8da604ffec95bf1c2144e67aff7a8b50e6cef"
],
"version": "==2019.9.11"
},
"chardet": {
"hashes": [
"sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae",
"sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691"
],
"version": "==3.0.4"
},
"idna": {
"hashes": [
"sha256:156a6814fb5ac1fc6850fb002e0852d56c0c8d2531923a51032d1b70760e186e",
"sha256:684a38a6f903c1d71d6d5fac066b58d7768af4de2b832e426ec79c30daa94a16"
],
"version": "==2.7"
},
"requests": {
"hashes": [
"sha256:65b3a120e4329e33c9889db89c80976c5272f56ea92d3e74da8a463992e3ff54",
"sha256:ea881206e59f41dbd0bd445437d792e43906703fff75ca8ff43ccdb11f33f263"
],
"index": "pypi",
"version": "==2.20.1"
},
"urllib3": {
"hashes": [
"sha256:4c291ca23bbb55c76518905869ef34bdd5f0e46af7afe6861e8375643ffee1a0",
"sha256:9a247273df709c4fedb38c711e44292304f73f39ab01beda9f6b9fc375669ac3"
],
"index": "pypi",
"version": "==1.24.2"
}
},
"develop": {}
}

View File

@ -13,7 +13,7 @@ pip install python-yubikey
## Register for an API key
```
``` python
from yubikey import Yubikey
yubi = Yubikey()
@ -23,8 +23,8 @@ yubi.register('<EMAIL>', '<INSERT OTP HERE>')
## Check valid OTP
```
yubi = Yubikey(<ID>, <Key>)
``` python
yubi = Yubikey('<ID>', '<Key>')
result = yubi.verify('<INSERT ANOHTER OTP HERE>')
# True / False
# If <key> is provided, requests will be signed and the responses checked.
@ -32,7 +32,7 @@ result = yubi.verify('<INSERT ANOHTER OTP HERE>')
## Optionals
```
``` python
# Using custom API server
# Must be one of YubicoWS._servers
yubi = Yubikey(123, 'dGhpc3JlcG9yb2Nrcw==', server='api2.yubico.com')

View File

@ -1 +0,0 @@
requests==1.2.3

View File

@ -5,7 +5,7 @@ from setuptools import setup
import os
import sys
version = '0.1.0'
version = '0.3.0'
if sys.argv[-1] == 'publish':
os.system("python setup.py sdist upload")
@ -27,7 +27,9 @@ setup(
py_modules=['yubikey'],
include_package_data=True,
zip_safe=False,
install_requires=open('requirements.txt').read().split('\n'),
install_requires=[
"requests==2.20.1",
],
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',

View File

@ -8,6 +8,10 @@ import requests
class YubicoWS(object):
"""
Yubico Web Service class that interacts with the Yubico API
"""
register_ws = 'https://upgrade.yubico.com/getapikey/?format=json'
api_ws = None
@ -152,6 +156,10 @@ class YubicoWS(object):
class Yubikey(object):
"""
Yubikey object wrapper
"""
id = None
key = None
prefix = None
@ -197,7 +205,11 @@ class Yubikey(object):
self.prefix = str.lower(otp[:-32])
###
# Custom exceptions
###
class YubicoWSError(Exception):
"Web service error. Defined by yubico documentation."
def __init__(self, message=None):
self.msg = "Web Service responded with an error: %s" % message
@ -206,17 +218,15 @@ class YubicoWSError(Exception):
class YubicoWSInvalidResponse(Exception):
"Exception if the web service answers without same otp/nonce parameters"
msg = 'Response from the server is invalid'
class WSResponseError(Exception):
def __str__(self):
return repr(self.msg)
class YubicoWSResponseBadSignature(Exception):
"Exception if the web service answers with a invalid signature"
pass
class OTPIncorrectFormat(Exception):
pass
class YubicoWSResponseBadSignature(Exception):
"Exception raised if the OTP provided is incorrect"
pass