Advertisement
Guest User

Untitled

a guest
Jan 28th, 2019
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. # IMPORTS
  2. import getpass
  3. import aerospike
  4. from argon2 import PasswordHasher
  5. import secrets
  6. import string
  7. import os
  8.  
  9. # connect to cluster and store as G*client
  10. config = {
  11. 'hosts' : [
  12. ( '201.203.200.55', 3000 )
  13. ],
  14. 'policies' : {
  15. 'timeout' : 1000 # milliseconds
  16. }
  17. }
  18. client = aerospike.client(config)
  19. client.connect()
  20.  
  21. # FUNCTIONS
  22. def genSalt():
  23. return ''.join(secrets.choice(string.printable) for i in range(32, 128))
  24.  
  25. def hashPasswd(password, salt):
  26. hasher = PasswordHasher()
  27. return hasher.hash(password + salt)
  28.  
  29. # MAIN
  30. def main():
  31. # get options
  32. username = input("Enter a username to add: ")
  33. password = getpass.getpass()
  34. adminID = input("Admin? 1=yes, 0=no : ")
  35.  
  36. # hash password
  37. salt = genSalt()
  38. hashedPass = hashPasswd(password, salt)
  39.  
  40. # generate AQL record
  41. key = ("minimoira", "users", username)
  42. bins = {
  43. 'uname': username,
  44. 'pass': hashedPass,
  45. 'salt': salt,
  46. 'admin': adminID
  47. }
  48.  
  49. # put record into DB
  50. client.put(key, bins)
  51.  
  52. # TODO: create SSH user on webapp
  53. mask = os.system("commandToGenUser")
  54.  
  55. # TODO: create SSH user on bank2node
  56.  
  57. # ALL CODE GOES ABOVE THIS
  58. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement