github authentication
note: don't deploy this on the server without setting the necessary config vars on heroku first, thanks.
This commit is contained in:
		
							parent
							
								
									e35acb0cdf
								
							
						
					
					
						commit
						b2d77336d3
					
				
					 3 changed files with 23 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -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.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										20
									
								
								settings.py
									
										
									
									
									
								
							
							
						
						
									
										20
									
								
								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()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										1
									
								
								urls.py
									
										
									
									
									
								
							
							
						
						
									
										1
									
								
								urls.py
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -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')),
 | 
			
		||||
)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue