Skip to content
This repository was archived by the owner on Sep 22, 2020. It is now read-only.

Commit 09b7f6e

Browse files
author
Bernhard Grünewaldt
committed
initial version of env vars for heroku
1 parent 8f66ad6 commit 09b7f6e

3 files changed

Lines changed: 36 additions & 4 deletions

File tree

Procfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
web: python heroku.py -e heroku -p $PORT --authType allGitHubUsers --owner comsysto --repository github-pages-basic-auth-proxy --obfuscator 086e41eb6ff7a50ad33ad742dbaa2e70b75740c4950fd5bbbdc71981e6fe88e3
1+
web: python heroku.py -e heroku -p $PORT

app.json

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,24 @@
44
"image": "heroku/python",
55
"repository": "https://github.com/comsysto/github-pages-basic-auth-proxy",
66
"keywords": ["python", "gh-pages" ],
7-
"addons": [ ]
7+
"success_url": "/install-success",
8+
"addons": [ ],
9+
"env": {
10+
"PROXY_AUTH_TYPE": {
11+
"description": "The authType. allGitHubUsers or onlyGitHubOrgUsers.",
12+
"value": "allGitHubUsers"
13+
},
14+
"GITHUB_REPOSITORY_OWNER": {
15+
"description": "The owner of the GitHub repository you want to proxy",
16+
"value": "comsysto"
17+
},
18+
"GITHUB_REPOSITORY_NAME": {
19+
"description": "The name of the GitHub repository you want to proxy",
20+
"value": "github-pages-basic-auth-proxy"
21+
},
22+
"GITHUB_REPOSITORY_OBFUSCATOR": {
23+
"description": "The name of the GitHub repository you want to proxy",
24+
"value": "086e41eb6ff7a50ad33ad742dbaa2e70b75740c4950fd5bbbdc71981e6fe88e3"
25+
}
26+
}
827
}

cs_proxy/proxy.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def main():
2323
parser.add_argument("-ghr", "--repository", help='the repository name.')
2424
parser.add_argument("-obf", "--obfuscator", help='the subfolder-name in gh-pages branch used as obfuscator')
2525
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'] )
26+
parser.add_argument("-a", "--authType", help='how should users auth.', choices=['allGitHubUsers', 'onlyGitHubOrgUsers'], required=False )
2727

2828

2929
args = parser.parse_args()
@@ -38,6 +38,15 @@ def main():
3838

3939
sys.exit(1)
4040

41+
if args.environment == 'heroku':
42+
args = parser.parse_args(['--environment', 'heroku',
43+
'--port', os.environ.get("PORT", 5000),
44+
'--authType', os.environ.get("PROXY_AUTH_TYPE", 'allGitHubUsers'),
45+
'--owner', os.environ.get("GITHUB_REPOSITORY_OWNER", 'comsysto'),
46+
'--repository', os.environ.get("GITHUB_REPOSITORY_NAME", 'github-pages-basic-auth-proxy'),
47+
'--obfuscator', os.environ.get("GITHUB_REPOSITORY_OBFUSCATOR", '086e41eb6ff7a50ad33ad742dbaa2e70b75740c4950fd5bbbdc71981e6fe88e3')
48+
])
49+
4150
run_proxy(args)
4251

4352
#
@@ -136,6 +145,10 @@ def error500(error):
136145
def hello():
137146
return 'ok'
138147

148+
@route('/install-success')
149+
def hello():
150+
return 'The Auth Basic GitHub Pages Proxy was installed successfully.'
151+
139152
#
140153
# make args available in auth callback
141154
#
@@ -159,7 +172,7 @@ def proxy_trough_root_page():
159172
if args.environment == 'wsgi':
160173
run(host='localhost', port=args.port, debug=True)
161174
if args.environment == 'heroku':
162-
run(host="0.0.0.0", port=int(os.environ.get("PORT", 5000)))
175+
run(host="0.0.0.0", port=int(args.port))
163176
else:
164177
run(server='cgi')
165178

0 commit comments

Comments
 (0)