Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix missing functions in: google, google_hybrid, google_oauth2, openi…
…d, yahoo
  • Loading branch information
frgomes committed Oct 25, 2013
commit c0fc823518e112825bb11ed30225f3dec6261406
3 changes: 3 additions & 0 deletions velruse/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def register_velruse_store(config, storage):
'github': 'add_github_login_from_settings',
'google': 'add_google_login_from_settings',
'google_oauth2': 'add_google_oauth2_login_from_settings',
'google_hybrid': 'add_google_hybrid_login_from_settings',
'lastfm': 'add_lastfm_login_from_settings',
'linkedin': 'add_linkedin_login_from_settings',
'live': 'add_live_login_from_settings',
Expand All @@ -126,6 +127,8 @@ def register_velruse_store(config, storage):
'taobao': 'add_taobao_login_from_settings',
'twitter': 'add_twitter_login_from_settings',
'weibo': 'add_weibo_login_from_settings',
'openid': 'add_openid_login_from_settings',
'yahoo': 'add_yahoo_login_from_settings',
}


Expand Down
40 changes: 38 additions & 2 deletions velruse/providers/google.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,44 @@
"""This module exists as a bw-compat shim for google_hybrid."""
from .google_hybrid import (
add_google_login,
GoogleAuthenticationComplete,
add_google_hybrid_login,
)

from ..settings import ProviderSettings


def includeme(config):
config.add_directive('add_google_login', add_google_login)
config.add_directive('add_google_login_from_settings',
add_google_login_from_settings)


def add_google_login_from_settings(config, prefix='velruse.google.'):
settings = config.registry.settings
p = ProviderSettings(settings, prefix)
p.update('consumer_key', required=True)
p.update('consumer_secret', required=True)
p.update('login_path')
p.update('callback_path')
config.add_google_login(**p.kwargs)


def add_google_login(config,
attrs=None,
realm=None,
storage=None,
consumer_key=None,
consumer_secret=None,
scope=None,
login_path='/login/google',
callback_path='/login/google/callback',
name='google'):
add_google_hybrid_login(config,
attrs,
realm,
storage,
consumer_key,
consumer_secret,
scope,
login_path,
callback_path,
name)
38 changes: 26 additions & 12 deletions velruse/providers/google_hybrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
OpenIDConsumer,
)

from ..settings import ProviderSettings

log = __import__('logging').getLogger(__name__)

Expand All @@ -38,18 +39,31 @@ def includeme(config):
for the supported options.

"""
config.add_directive('add_google_hybrid_login', add_google_login)

def add_google_login(config,
attrs=None,
realm=None,
storage=None,
consumer_key=None,
consumer_secret=None,
scope=None,
login_path='/login/google',
callback_path='/login/google/callback',
name='google'):
config.add_directive('add_google_hybrid_login', add_google_hybrid_login)
config.add_directive('add_google_hybrid_login_from_settings',
add_google_hybrid_login_from_settings)


def add_google_hybrid_login_from_settings(config, prefix='velruse.google_hybrid.'):
settings = config.registry.settings
p = ProviderSettings(settings, prefix)
p.update('consumer_key', required=True)
p.update('consumer_secret', required=True)
p.update('login_path')
p.update('callback_path')
config.add_google_hybrid_login(**p.kwargs)


def add_google_hybrid_login(config,
attrs=None,
realm=None,
storage=None,
consumer_key=None,
consumer_secret=None,
scope=None,
login_path='/login/google_hybrid',
callback_path='/login/google_hybrid/callback',
name='google_hybrid'):
"""
Add a Google login provider to the application using the OpenID+OAuth
hybrid protocol. This protocol can be configured for purely
Expand Down
23 changes: 13 additions & 10 deletions velruse/providers/google_oauth2.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
class GoogleAuthenticationComplete(AuthenticationComplete):
"""Google OAuth 2.0 auth complete"""


def includeme(config):
"""Activate the ``google_oauth2`` Pyramid plugin via
``config.include('velruse.providers.google_oauth2')``. After included,
Expand All @@ -34,11 +35,12 @@ def includeme(config):
``config.add_google_oauth2_login_from_settings()``

"""
config.add_directive('add_google_oauth2_login', add_google_login)
config.add_directive('add_google_oauth2_login', add_google_oauth2_login)
config.add_directive('add_google_oauth2_login_from_settings',
add_google_login_from_settings)
add_google_oauth2_login_from_settings)


def add_google_login_from_settings(config, prefix='velruse.google.'):
def add_google_oauth2_login_from_settings(config, prefix='velruse.google_oauth2.'):
settings = config.registry.settings
p = ProviderSettings(settings, prefix)
p.update('consumer_key', required=True)
Expand All @@ -48,13 +50,14 @@ def add_google_login_from_settings(config, prefix='velruse.google.'):
p.update('callback_path')
config.add_google_oauth2_login(**p.kwargs)

def add_google_login(config,
consumer_key=None,
consumer_secret=None,
scope=None,
login_path='/login/google',
callback_path='/login/google/callback',
name='google'):

def add_google_oauth2_login(config,
consumer_key=None,
consumer_secret=None,
scope=None,
login_path='/login/google_oauth2',
callback_path='/login/google_oauth2/callback',
name='google_oauth2'):
"""
Add a Google login provider to the application supporting the new
OAuth2 protocol.
Expand Down
12 changes: 12 additions & 0 deletions velruse/providers/openid.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
ThirdPartyFailure,
)

from ..settings import ProviderSettings

log = __import__('logging').getLogger(__name__)

# Setup our attribute objects that we'll be requesting
Expand Down Expand Up @@ -78,6 +80,16 @@ class OpenIDAuthenticationComplete(AuthenticationComplete):

def includeme(config):
config.add_directive('add_openid_login', add_openid_login)
config.add_directive('add_openid_login_from_settings',
add_openid_login_from_settings)


def add_openid_login_from_settings(config, prefix='velruse.openid.'):
settings = config.registry.settings
p = ProviderSettings(settings, prefix)
p.update('login_path')
p.update('callback_path')
config.add_openid_login(**p.kwargs)


def add_openid_login(config,
Expand Down
13 changes: 13 additions & 0 deletions velruse/providers/yahoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
OpenIDConsumer,
)

from ..settings import ProviderSettings

log = __import__('logging').getLogger(__name__)

Expand All @@ -29,6 +30,18 @@ class YahooAuthenticationComplete(OpenIDAuthenticationComplete):

def includeme(config):
config.add_directive('add_yahoo_login', add_yahoo_login)
config.add_directive('add_yahoo_login_from_settings',
add_yahoo_login_from_settings)


def add_yahoo_login_from_settings(config, prefix='velruse.yahoo.'):
settings = config.registry.settings
p = ProviderSettings(settings, prefix)
p.update('consumer_key', required=True)
p.update('consumer_secret', required=True)
p.update('login_path')
p.update('callback_path')
config.add_yahoo_login(**p.kwargs)


def add_yahoo_login(config,
Expand Down