webserver_auth.py 740 B

1234567891011121314151617181920212223242526272829
  1. #!/opt/mcfi/venv/bin/python
  2. # This script is called by the webserver for users basic authentication when
  3. # they "git push" something
  4. import configparser
  5. import sys
  6. username = sys.stdin.readline().strip()
  7. password = sys.stdin.readline().strip()
  8. # Load list of users
  9. actors = configparser.ConfigParser()
  10. actors.read('/var/lib/gitolite3/.gitolite/forgefed/actors')
  11. if username not in actors:
  12. sys.stderr.write('Username does not exists: {}\n'.format(username))
  13. exit(1)
  14. if actors[username]['type'] != 'Person':
  15. sys.stderr.write('Not a Person: {}\n'.format(username))
  16. exit(2)
  17. if actors[username]['password'] != password:
  18. sys.stderr.write('Password does not match for user {}.\n'.format(username))
  19. exit(3)
  20. # exit 0