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

Commit 0837a4c

Browse files
secured by basic auth
1 parent 6536008 commit 0837a4c

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,24 @@ A simple python based proxy to secure github pages via a small cloud-proxy-insta
66

77
:bangbang: **THIS IS WORK IN PROGRESS. PRE-ALPHA** :bangbang:
88

9+
**DEMO**
10+
11+
* Secured Page by Proxy:
12+
* https://my-secure-github-page.comsysto.com/
13+
* user: `bob`
14+
* pass: `5678`
15+
* GitHub Page that is proxied:
16+
* https://comsysto.github.io/github-pages-basic-auth-proxy/086e41eb6ff7a50ad33ad742dbaa2e70b75740c4950fd5bbbdc71981e6fe88e3/
17+
* (normally you would not tell anyone that URL. But just that you see that these pages are identical)
18+
919
### 1.1 Who needs this?
1020

1121
* If you have a GitHub organization account with organization members.
1222
* If you have a private organization github repository.
1323
* If you have a `gh-pages` branch in that repository.
1424
* And if you want to secure the gh-pages page via basic auth, then this proxy is for you.
1525
* Only members of the GitHub organization and users you specify manually will have access
26+
* you can specify additional users with passwords that are not github users
1627

1728
### 1.2 What it will do
1829

cs_proxy/proxy.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import sys, os
2-
from bottle import route, request, response, run, hook, abort, redirect, error, install
2+
from bottle import route, request, response, run, hook, abort, redirect, error, install, auth_basic
33
import simplejson as json
44
import logging
55
import datetime
@@ -13,6 +13,17 @@ def return_json(object, response):
1313
response.set_header('Content-Type', 'application/json')
1414
return json.dumps(object)
1515

16+
def check_pass(username, password):
17+
if username == 'bob' and password == '5678':
18+
return True
19+
return False
20+
21+
def normalize_proxy_url(url):
22+
print ('URL:')
23+
print (url)
24+
if url.endswith('/') or url == '':
25+
return '{0}index.html'.format(url)
26+
return url
1627

1728

1829
#
@@ -38,10 +49,16 @@ def error500(error):
3849
def hello():
3950
return 'ok'
4051

52+
4153
@route('/<url>')
54+
@auth_basic(check_pass)
4255
def proxy_trough(url):
43-
return requests.get('{0}{1}'.format(args.githubPagesUrl, url))
56+
return requests.get('{0}{1}'.format(args.githubPagesUrl, normalize_proxy_url(url)))
4457

58+
@route('/')
59+
@auth_basic(check_pass)
60+
def proxy_trough_root_page():
61+
return requests.get('{0}{1}'.format(args.githubPagesUrl, '/index.html'))
4562

4663

4764
#

0 commit comments

Comments
 (0)