Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
frennkie committed Feb 19, 2017
1 parent 07e79bb commit ec78ed3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ or
```
sudo apt-get update
sudo apt-get install -y python2.7 python-pip python-m2crypto python-qrcode python-ldap shred
sudo -H pip install pyotp
sudo -H pip2 install pyotp
```

#### Install on CentOS 7

```
sudo yum install -y python2 python-pip m2crypto python-qrcode srm
sudo -H pip install pyotp
sudo -H pip2 install pyotp
```

### Usage / Config
Expand Down
15 changes: 11 additions & 4 deletions totp_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@
SMTP_FROM="[email protected]"


def insert_newlines(string, every=64):
lines = []
for i in xrange(0, len(string), every):
lines.append(string[i:i+every])
return '\n'.join(lines)


def ldap_search(ldap_uri, base, query):
'''
Perform an LDAP query.
Expand Down Expand Up @@ -124,8 +131,8 @@ def ldap_search(ldap_uri, base, query):

userCertificate_raw = binascii.b2a_base64(userCertificate)
userCertificate = "-----BEGIN CERTIFICATE-----\n"
userCertificate += userCertificate_raw
userCertificate += "-----END CERTIFICATE-----\n"
userCertificate += insert_newlines(userCertificate_raw).rstrip("\n")
userCertificate += "\n-----END CERTIFICATE-----\n"

results.append({"dn": dn,
"mail": mail,
Expand Down Expand Up @@ -263,12 +270,12 @@ def create_and_send_qrcode(user,
try:
os.system("shred -uf {0}".format(QRCODE_FILE))
except Exception as err:
print("Error: {0}".format(err)
print("Error: {0}".format(err))

try:
os.system("srm -f {0}".format(QRCODE_FILE))
except Exception as err:
print("Error: {0}".format(err)
print("Error: {0}".format(err))

return shared_secret, qrcode_text

Expand Down

0 comments on commit ec78ed3

Please sign in to comment.