ldap first pass

This commit is contained in:
Matthew Scragg 2015-10-14 17:36:22 -05:00
parent 3c2f4a0445
commit 2eaf09dc78
13 changed files with 148 additions and 25 deletions

View file

@ -8,25 +8,31 @@ oauth = OAuth()
class OAuthUser(BaseUser):
# OAuth remote app
app = None
remote_app = None
class TwitterUser(OAuthUser):
app = oauth.remote_app(
'twitter',
base_url='https://api.twitter.com/1/',
request_token_url='https://api.twitter.com/oauth/request_token',
access_token_url='https://api.twitter.com/oauth/access_token',
authorize_url='https://api.twitter.com/oauth/authenticate',
consumer_key=config.TWITTER_KEY,
consumer_secret=config.TWITTER_SECRET)
def __init__(self, id_, username, email=None):
self.id = id_
self.username = username
self.email = email
@classmethod
def app(cls):
if cls.remote_app:
return cls.remote_app
cls.remote_app = oauth.remote_app(
'twitter',
base_url='https://api.twitter.com/1/',
request_token_url='https://api.twitter.com/oauth/request_token',
access_token_url='https://api.twitter.com/oauth/access_token',
authorize_url='https://api.twitter.com/oauth/authenticate',
consumer_key=config.OAUTH['twitter']['key'],
consumer_secret=config.OAUTH['twitter']['secret'])
return cls.remote_app
@staticmethod
def load_user(*args, **kwargs):
return TwitterUser(args[0])