Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Redid the authentication modules, bypassing for now

  • Loading branch information...
commit 9f427d66543bacc36ee4869bc577a7fb700a7292 1 parent 004413e
@thenoviceoof authored
View
2  .gitignore
@@ -2,4 +2,4 @@
*.swp
*.pyc
-config.py
+config.py
View
2  README.md
@@ -54,7 +54,7 @@ INSTALL
* git clone this guy from github
* copy over config.py.template to config.py, configure appropriately
* you'll need to make your own auth endpoint: copy the example of
- WIND_auth.py, which presumes an oauth-like authentication
+ auth.py, which presumes an oauth-like authentication
scheme. If you don't have one, then you can use openid or facebook
* get a google account
* make an appengine app, choose an appropriate subdomain
View
4 app.yaml
@@ -11,8 +11,8 @@ handlers:
- url: /static
static_dir: static
-- url: /callback
- script: WIND_auth.py
+- url: /auth/.*
+ script: auth.py
- url: /_ah/mail/support@.*\.appspotmail\.com
script: handle_support.py
View
24 WIND_auth.py → auth.py
@@ -2,6 +2,7 @@
from google.appengine.ext import webapp
from google.appengine.ext.webapp import template
from google.appengine.ext.webapp.util import run_wsgi_app
+from google.appengine.api.app_identity import get_application_id
from models import Token
from lib import BaseHandler
@@ -10,16 +11,32 @@
from gaesessions import get_current_session
+from config import DEBUG
+
from google.appengine.dist import use_library
use_library('django', '0.96')
-def WINDCallback(BaseHandler):
+class WINDRedirect(BaseHandler):
+ def get(self):
+ if DEBUG:
+ session = get_current_session()
+ token_user = Token.get_or_insert("test")
+ session["user"] = token_user.key().name()
+ self.redirect("/")
+ return
+ callback = "http://%s.appspot.com/auth/callback" % get_application_id()
+ options = urllib.urlencode([("destination", callback)])
+ url = "https://wind.columbia.edu/login?%s" % (options)
+ self.redirect(url)
+
+class WINDCallback(BaseHandler):
def get(self):
token = self.request.get("token")
url = "https://wind.columbia.edu/validate?ticketid={0}".format(token)
r = urllib2.Request(url=url)
lines = urllib2.urlopen(r).split("\n")
if lines[0] == "yes":
+ # ident is unique
ident = lines[1]
# make sure we have a mapping
@@ -34,9 +51,10 @@ def get(self):
self.redirect("/")
application = webapp.WSGIApplication(
- [('/callback', Index),
+ [('/auth/', WINDRedirect),
+ ('/auth/callback', WINDCallback),
],
- debug=True)
+ debug=DEBUG)
def main():
run_wsgi_app(application)
View
2  models.py
@@ -59,7 +59,7 @@ class Job(db.Model):
# maps login tokens (admins) to clubs
class Token2Club(db.Model):
- token = db.ReferenceProperty(Club, required=True, collection_name="clubs")
+ token = db.ReferenceProperty(Token, required=True, collection_name="clubs")
club = db.ReferenceProperty(Club, required=True, collection_name="tokens")
# maps emails to clubs
View
2  templates/index.html
@@ -7,7 +7,7 @@
<p id="notice">Only open to {{ affiliation }}</p>
-<form method="post" action="/pre_auth">
+<form method="get" action="/auth/">
<button id="signin-button">{{ sign_in_button }}</button>
</form>
Please sign in to comment.
Something went wrong with that request. Please try again.