diff --git a/README.md b/README.md index 50e4858..ad6fd5f 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ How-To * Clone the repo. * Add a git remote called ``heroku`` pointing at ``git@heroku.com:insertcreativenamehere.git``. * Create a file called .env and add two values: ``DATABASE_URL=sqlite://localhost/local.db`` and ``DEBUG=True``. +* Create a GitHub app on https://github.com/settings/applications setting both urls to http://localhost:8000/. +* Add ``GITHUB_APP_SECRET`` and ``GITHUB_APP_ID`` to your .env file using the credentials from github. * Run ``make run``. * Open http://localhost:8000 * Hack. diff --git a/settings.py b/settings.py index 7032b42..73cd402 100644 --- a/settings.py +++ b/settings.py @@ -47,6 +47,10 @@ TEMPLATE_CONTEXT_PROCESSORS = [ 'django.core.context_processors.media', 'django.core.context_processors.static', 'django.contrib.messages.context_processors.messages', + 'social_auth.context_processors.social_auth_by_name_backends', + 'social_auth.context_processors.social_auth_backends', + 'social_auth.context_processors.social_auth_by_type_backends', + 'social_auth.context_processors.social_auth_login_redirect', ] ROOT_URLCONF = 'urls' @@ -66,8 +70,24 @@ INSTALLED_APPS = [ 'gunicorn', 'south', 'raven.contrib.django', + 'social_auth', ] +AUTHENTICATION_BACKENDS = [ + 'social_auth.backends.contrib.github.GithubBackend', + 'django.contrib.auth.backends.ModelBackend', +] + +LOGIN_URL = '/login/' +LOGIN_REDIRECT_URL = '/' +LOGIN_ERROR_URL = '/login/failed/' + + +assert 'GITHUB_APP_ID' in os.environ, "Set GITHUB_APP_ID in your .env file!" +assert 'GITHUB_APP_SECRET' in os.environ, "Set GITHUB_APP_SECRET in your .env file!" +GITHUB_APP_ID = os.environ['GITHUB_APP_ID'] +GITHUB_API_SECRET = os.environ['GITHUB_APP_SECRET'] + from memcacheify import memcacheify CACHES = memcacheify() diff --git a/urls.py b/urls.py index 648131c..980230e 100644 --- a/urls.py +++ b/urls.py @@ -9,4 +9,5 @@ admin.autodiscover() urlpatterns = patterns('', url(r'^%s(?P.*)$' % re.escape(settings.STATIC_URL.lstrip('/')), 'django.contrib.staticfiles.views.serve', {'insecure': True}), url(r'^admin/', include(admin.site.urls)), + url(r'', include('social_auth.urls')), )