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

Commit 85a8a8f

Browse files
Merge pull request #2 from comsysto/heroku-deploy-button
Heroku deploy button with env vars
2 parents 33f1940 + 09b7f6e commit 85a8a8f

4 files changed

Lines changed: 44 additions & 41 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

README.md

Lines changed: 8 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
#### GitHub Pages Basic Auth Proxy by comSysto
44

5+
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy)
6+
7+
58
A simple python based proxy to secure github pages with basic auth via a small cloud-proxy-instance.
69
Basic Auth checks against GitHub API. This little piece of software is brought to you by comSysto.
710
*comSysto is not a representative of GitHub. GitHub and the GitHub logos are Trademarks of GitHub inc.*
@@ -65,45 +68,13 @@ Basic Auth checks against GitHub API. This little piece of software is brought t
6568

6669
## 2. Installation on Heroku
6770

68-
[![](./doc/heroku-logo.png)](https://dashboard.heroku.com/)
69-
70-
Create a heroku app and clone the git repo. ([Toolbelt is installed](https://toolbelt.heroku.com/) and you are logged in)
71-
72-
```
73-
$> cd ~/
74-
$> heroku create
75-
# Creating app... done, stack is cedar-14
76-
# https://protected-foo-21086.herokuapp.com/ | https://git.heroku.com/protected-foo-21086.git
77-
$> git clone https://git.heroku.com/protected-foo-21086.git heroku-gh-proxy
78-
```
79-
80-
You now have a folder `heroku-gh-proxy` in your homedir that contains the deployed app (currently empty).
81-
Next we clone the GitHub Pages Proxy and extract the latest snapshot into `heroku-gh-proxy` (absolute path needed)
82-
83-
```
84-
$> cd ~/
85-
$> git clone https://github.com/comsysto/github-pages-basic-auth-proxy.git
86-
$> cd github-pages-basic-auth-proxy
87-
$> git checkout-index -a -f --prefix=/Users/bg/heroku-gh-proxy/ # absolute path with trailing slash!
88-
```
89-
90-
Now change the `Procfile` to your repository and obfuscator settings and push.
91-
92-
```
93-
$> cd ~/heroku-gh-proxy
94-
vim Procfile # change your settings
95-
git add . -A
96-
git commit -m "init"
97-
git push
98-
```
99-
100-
Now your app should be up and running.
71+
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy)
10172

102-
* You can access the health check `https://protected-foo-21086.herokuapp.com/health`
103-
* Or directly use the proxy and enter credentials `https://protected-foo-21086.herokuapp.com/`
104-
* A successfully deployed app log should look like this:
105-
* ![](./doc/heroku-logs.png)
73+
You can automatically setup the heroku instance of the proxy by clicking the button above and configure it via `env` vars.
74+
You need to specify `authType`, `owner`, `repository` and `obfuscator`.
10675

76+
IFrame Test:
77+
<iframe width="560" height="315" src="https://comsysto.com" frameborder="0" allowfullscreen></iframe>
10778

10879

10980
## 3. Installation on AWS

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)