Merge pull request #1 from ojii/feature/github-auth

github authentication
This commit is contained in:
Eryn Wells 2012-08-17 18:06:10 -07:00
commit 692e3e17fd
3 changed files with 23 additions and 0 deletions

View file

@ -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: ``DATABASE_URL=sqlite://localhost/local.db``, ``SECRET_KEY=<some secret key>`` 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.

View file

@ -50,6 +50,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'
@ -69,8 +73,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()

View file

@ -9,4 +9,5 @@ admin.autodiscover()
urlpatterns = patterns('',
url(r'^%s(?P<path>.*)$' % 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')),
)