|
1 | 1 | import sys, os |
| 2 | +import argparse |
| 3 | +import colorama |
2 | 4 | from bottle import route, request, response, run, hook, abort, redirect, error, install, auth_basic |
3 | 5 | import simplejson as json |
4 | 6 | import random |
|
10 | 12 | from jose.exceptions import JWSError |
11 | 13 | import datetime |
12 | 14 |
|
| 15 | +def main(): |
| 16 | + # |
| 17 | + # CLI PARAMS |
| 18 | + # |
| 19 | + parser = argparse.ArgumentParser(description='comSysto GitHub Pages Auth Basic Proxy') |
| 20 | + |
| 21 | + parser.add_argument("-e", "--environment", help='Which environment.', choices=['cgi', 'wsgi', 'heroku']) |
| 22 | + parser.add_argument("-gho", "--owner", help='the owner of the repository. Either organizationname or username.') |
| 23 | + parser.add_argument("-ghr", "--repository", help='the repository name.') |
| 24 | + parser.add_argument("-obf", "--obfuscator", help='the subfolder-name in gh-pages branch used as obfuscator') |
| 25 | + parser.add_argument("-p", "--port", help='the port to run proxy e.g. 8881') |
| 26 | + parser.add_argument("-a", "--authType", help='how should users auth.', choices=['allGitHubUsers', 'onlyGitHubOrgUsers'] ) |
| 27 | + |
| 28 | + |
| 29 | + args = parser.parse_args() |
| 30 | + if not args.environment: |
| 31 | + print ('USAGE') |
| 32 | + print (' proxy that allows only members of the organization to access page: (owner must be an GitHub Organization)') |
| 33 | + print (' $> cs-gh-proxy -e wsgi -p 8881 --authType onlyGitHubOrgUsers --owner comsysto --repository github-pages-basic-auth-proxy --obfuscator 086e41eb6ff7a50ad33ad742dbaa2e70b75740c4950fd5bbbdc71981e6fe88e3') |
| 34 | + print ('') |
| 35 | + print (' proxy that allows all GitHub Users to access page: (owner can be GitHub Organization or normal user)') |
| 36 | + print (' $> cs-gh-proxy -e wsgi -p 8881 --authType allGitHubUsers --owner comsysto --repository github-pages-basic-auth-proxy --obfuscator 086e41eb6ff7a50ad33ad742dbaa2e70b75740c4950fd5bbbdc71981e6fe88e3') |
| 37 | + print ('') |
| 38 | + |
| 39 | + sys.exit(1) |
| 40 | + |
| 41 | + run_proxy(args) |
| 42 | + |
13 | 43 | # |
14 | 44 | # global vars |
15 | 45 | # |
@@ -128,6 +158,8 @@ def proxy_trough_root_page(): |
128 | 158 | # |
129 | 159 | if args.environment == 'wsgi': |
130 | 160 | run(host='localhost', port=args.port, debug=True) |
| 161 | + if args.environment == 'heroku': |
| 162 | + run(host="0.0.0.0", port=int(os.environ.get("PORT", 5000))) |
131 | 163 | else: |
132 | 164 | run(server='cgi') |
133 | 165 |
|
0 commit comments