fixed @//// in wiki and pep8 spacing
This commit is contained in:
@@ -263,3 +263,4 @@ if __name__=='__main__':
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -243,3 +243,4 @@ if __name__=='__main__':
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -5,3 +5,4 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -501,3 +501,4 @@ aes_Rcon = array('B',
|
||||
'61c29f254a943366cc831d3a74e8cb'.decode('hex')
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ def oembed(url):
|
||||
for k,v in EMBED_MAPS:
|
||||
if k.match(url):
|
||||
oembed = v+'?format=json&url='+cgi.escape(url)
|
||||
try:
|
||||
try:
|
||||
data = urllib.urlopen(oembed).read()
|
||||
print data
|
||||
return loads(data) # json!
|
||||
@@ -152,7 +152,7 @@ def expand_one(url,cdict):
|
||||
r = cdict[url]
|
||||
else:
|
||||
r = oembed(url)
|
||||
if isinstance(cdict,dict):
|
||||
if isinstance(cdict,dict):
|
||||
cdict[url] = r
|
||||
# if oembed service
|
||||
if 'html' in r:
|
||||
@@ -204,3 +204,4 @@ if __name__=="__main__":
|
||||
else:
|
||||
print test()
|
||||
|
||||
|
||||
|
||||
@@ -194,3 +194,4 @@ if __name__ == "__main__":
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -3910,3 +3910,4 @@ def parse(url_file_stream_or_string, etag=None, modified=None, agent=None, refer
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -55,3 +55,4 @@ class MemcacheClient(Client):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -90,3 +90,4 @@ def autoretry_datastore_timeouts(attempts=5.0, interval=0.1, exponent=2.0):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -67,3 +67,4 @@ def pdf_from_html(html):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -19,3 +19,4 @@ def button(merchant_id="123456789012345",
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -9,3 +9,4 @@ from gluon.dal import DAL, Field, Table, Query, Set, Expression, Row, Rows, driv
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -58,3 +58,4 @@ def THUMB(image, nx=120, ny=120, gae=False, name='thumb'):
|
||||
else:
|
||||
return image
|
||||
|
||||
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -23,3 +23,4 @@ def basic_auth(server="http://127.0.0.1"):
|
||||
return False
|
||||
return basic_login_aux
|
||||
|
||||
|
||||
|
||||
@@ -6,18 +6,18 @@
|
||||
developed by Madhukar R Pai (Copyright 2012)
|
||||
Email <madspai@gmail.com>
|
||||
License : LGPL
|
||||
|
||||
|
||||
thanks and credits to the web2py community
|
||||
|
||||
|
||||
This custom authenticator allows web2py to authenticate using browserid (https://browserid.org/)
|
||||
BrowserID is a project by Mozilla Labs (http://mozillalabs.com/)
|
||||
to Know how browserid works please visit http://identity.mozilla.com/post/7616727542/introducing-browserid-a-better-way-to-sign-in
|
||||
|
||||
|
||||
bottom line BrowserID provides a free, secure, de-centralized, easy to use(for users and developers) login solution.
|
||||
You can use any email id as your login id. Browserid just verifys the email id and lets you login with that id.
|
||||
|
||||
|
||||
credits for the doPost jquery function - itsadok (http://stackoverflow.com/users/7581/itsadok)
|
||||
|
||||
|
||||
"""
|
||||
import time
|
||||
from gluon import *
|
||||
@@ -32,7 +32,7 @@ class BrowserID(object):
|
||||
audience = "http://127.0.0.1:8000"
|
||||
assertion_post_url = "http://127.0.0.1:8000/%s/default/user/login" % request.application)
|
||||
"""
|
||||
|
||||
|
||||
def __init__(self,
|
||||
request,
|
||||
audience = "",
|
||||
@@ -45,7 +45,7 @@ class BrowserID(object):
|
||||
crypto_js = "https://crypto-js.googlecode.com/files/2.2.0-crypto-md5.js",
|
||||
on_login_failure = None,
|
||||
):
|
||||
|
||||
|
||||
self.request = request
|
||||
self.audience = audience
|
||||
self.assertion_post_url = assertion_post_url
|
||||
@@ -64,13 +64,13 @@ class BrowserID(object):
|
||||
|
||||
def get_user(self):
|
||||
request = self.request
|
||||
if request.vars.assertion:
|
||||
if request.vars.assertion:
|
||||
audience = self.audience
|
||||
issuer = self.issuer
|
||||
assertion = XML(request.vars.assertion,sanitize=True)
|
||||
verify_data = {'assertion':assertion,'audience':audience}
|
||||
auth_info_json = fetch(self.verify_url,data=verify_data)
|
||||
j = json.loads(auth_info_json)
|
||||
j = json.loads(auth_info_json)
|
||||
epoch_time = int(time.time()*1000) # we need 13 digit epoch time
|
||||
if j["status"] == "okay" and j["audience"] == audience and j['issuer'] == issuer and j['expires'] >= epoch_time:
|
||||
return dict(email = j['email'])
|
||||
@@ -88,3 +88,4 @@ class BrowserID(object):
|
||||
A(IMG(_src=self.browserid_button,_alt=self.prompt),_href="#",_onclick=onclick,_class="browserid",_title="Login With BrowserID"),
|
||||
SCRIPT(self.asertion_js))
|
||||
return form
|
||||
|
||||
|
||||
@@ -136,3 +136,4 @@ class CasAuth( object ):
|
||||
import urllib
|
||||
redirect("%s?service=%s" % (self.cas_logout_url,self.cas_my_url))
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
import os
|
||||
import re
|
||||
import urllib
|
||||
from dropbox import client, rest, session
|
||||
from dropbox import client, rest, session
|
||||
from gluon import *
|
||||
from gluon.tools import fetch
|
||||
from gluon.storage import Storage
|
||||
@@ -50,15 +50,15 @@ class DropboxAccount(object):
|
||||
self.sess = session.DropboxSession(
|
||||
self.key,self.secret,self.access_type)
|
||||
|
||||
|
||||
|
||||
def get_user(self):
|
||||
request = self.request
|
||||
token = current.session.dropbox_token
|
||||
try:
|
||||
access_token = self.sess.obtain_access_token(token)
|
||||
access_token = self.sess.obtain_access_token(token)
|
||||
except:
|
||||
access_token = None
|
||||
if access_token:
|
||||
if access_token:
|
||||
user = Storage()
|
||||
self.client = client.DropboxClient(self.sess)
|
||||
data = self.client.account_info()
|
||||
@@ -68,7 +68,7 @@ class DropboxAccount(object):
|
||||
last_name = display_name[-1],
|
||||
registration_id = data.get('uid',None))
|
||||
if not user['registration_id'] and self.on_login_failure:
|
||||
redirect(self.on_login_failure)
|
||||
redirect(self.on_login_failure)
|
||||
return user
|
||||
return None
|
||||
|
||||
@@ -107,3 +107,4 @@ def use_dropbox(auth,filename='private/dropbox.key',**kwargs):
|
||||
auth.settings.login_form = DropboxAccount(
|
||||
request,key=key,secret=secret,access_type=access_type,
|
||||
login_url = login_url,**kwargs)
|
||||
|
||||
|
||||
@@ -43,3 +43,4 @@ def email_auth(server="smtp.gmail.com:587",
|
||||
pass
|
||||
return False
|
||||
return email_auth_aux
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ class ExtendedLoginForm(object):
|
||||
Otherwise it will render the normal login form combined with
|
||||
alt_login_form.login_form.
|
||||
"""
|
||||
|
||||
|
||||
request = current.request
|
||||
args = request.args
|
||||
|
||||
@@ -102,3 +102,4 @@ class ExtendedLoginForm(object):
|
||||
form.components.append(self.alt_login_form.login_form())
|
||||
return form
|
||||
|
||||
|
||||
|
||||
@@ -36,3 +36,4 @@ class GaeGoogleAccount(object):
|
||||
return dict(nickname=user.nickname(), email=user.email(),
|
||||
user_id=user.user_id(), source="google account")
|
||||
|
||||
|
||||
|
||||
@@ -634,3 +634,4 @@ def ldap_auth(server='ldap', port=None,
|
||||
if filterstr[0] == '(' and filterstr[-1] == ')': # rfc4515 syntax
|
||||
filterstr = filterstr[1:-1] # parens added again where used
|
||||
return ldap_auth_aux
|
||||
|
||||
|
||||
@@ -49,3 +49,4 @@ class LinkedInAccount(object):
|
||||
username = profile.id)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -110,3 +110,4 @@ class Loginza(object):
|
||||
SCRIPT(_src="https://s3-eu-west-1.amazonaws.com/s1.loginza.ru/js/widget.js", _type="text/javascript"))
|
||||
return form
|
||||
|
||||
|
||||
|
||||
@@ -6,24 +6,24 @@ from gluon.dal import DAL
|
||||
|
||||
def motp_auth(db=DAL('sqlite://storage.sqlite'),
|
||||
time_offset=60):
|
||||
|
||||
|
||||
"""
|
||||
motp allows you to login with a one time password(OTP) generated on a motp client,
|
||||
motp allows you to login with a one time password(OTP) generated on a motp client,
|
||||
motp clients are available for practically all platforms.
|
||||
to know more about OTP visit http://en.wikipedia.org/wiki/One-time_password
|
||||
to know more visit http://motp.sourceforge.net
|
||||
|
||||
|
||||
|
||||
|
||||
Written by Madhukar R Pai (madspai@gmail.com)
|
||||
License : MIT or GPL v2
|
||||
|
||||
|
||||
thanks and credits to the web2py community
|
||||
|
||||
|
||||
to use motp_auth:
|
||||
motp_auth.py has to be located in gluon/contrib/login_methods/ folder
|
||||
first auth_user has to have 2 extra fields - motp_secret and motp_pin
|
||||
for that define auth like shown below:
|
||||
|
||||
|
||||
## after auth = Auth(db)
|
||||
db.define_table(
|
||||
auth.settings.table_user_name,
|
||||
@@ -42,7 +42,7 @@ def motp_auth(db=DAL('sqlite://storage.sqlite'),
|
||||
writable=False, readable=False, default=''),
|
||||
Field('registration_id', length=512, # required
|
||||
writable=False, readable=False, default=''))
|
||||
|
||||
|
||||
##validators
|
||||
custom_auth_table = db[auth.settings.table_user_name] # get the custom_auth_table
|
||||
custom_auth_table.first_name.requires = \
|
||||
@@ -53,22 +53,22 @@ def motp_auth(db=DAL('sqlite://storage.sqlite'),
|
||||
custom_auth_table.email.requires = [
|
||||
IS_EMAIL(error_message=auth.messages.invalid_email),
|
||||
IS_NOT_IN_DB(db, custom_auth_table.email)]
|
||||
|
||||
|
||||
auth.settings.table_user = custom_auth_table # tell auth to use custom_auth_table
|
||||
## before auth.define_tables()
|
||||
|
||||
##after that:
|
||||
|
||||
|
||||
##after that:
|
||||
|
||||
from gluon.contrib.login_methods.motp_auth import motp_auth
|
||||
auth.settings.login_methods.append(motp_auth(db=db))
|
||||
|
||||
|
||||
##Instructions for using MOTP
|
||||
- after configuring motp for web2py, Install a MOTP client on your phone (android,IOS, java, windows phone, etc)
|
||||
- initialize the motp client (to reset a motp secret type in #**#),
|
||||
- initialize the motp client (to reset a motp secret type in #**#),
|
||||
During user creation enter the secret generated during initialization into the motp_secret field in auth_user and
|
||||
similarly enter a pre-decided pin into the motp_pin
|
||||
- done.. to login, just generate a fresh OTP by typing in the pin and use the OTP as password
|
||||
|
||||
|
||||
###To Dos###
|
||||
- both motp_secret and pin are stored in plain text! need to have some way of encrypting
|
||||
- web2py stores the password in db on successful login (should not happen)
|
||||
@@ -85,7 +85,7 @@ def motp_auth(db=DAL('sqlite://storage.sqlite'),
|
||||
hash = md5(to_hash).hexdigest()[:6]
|
||||
if otp == hash: return True
|
||||
return False
|
||||
|
||||
|
||||
def motp_auth_aux(email,
|
||||
password,
|
||||
db=db,
|
||||
@@ -102,3 +102,4 @@ def motp_auth(db=DAL('sqlite://storage.sqlite'),
|
||||
else: return False
|
||||
return False
|
||||
return motp_auth_aux
|
||||
|
||||
|
||||
@@ -188,3 +188,4 @@ class OAuthAccount(object):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ class OAuthAccount(object):
|
||||
|
||||
if not self.accessToken():
|
||||
return None
|
||||
|
||||
|
||||
if not self.graph:
|
||||
self.graph = GraphAPI((self.accessToken()))
|
||||
|
||||
@@ -117,7 +117,7 @@ server for requests. It can be used for the optional"scope" parameters for Face
|
||||
"""
|
||||
Build the url opener for managing HTTP Basic Athentication
|
||||
"""
|
||||
# Create an OpenerDirector with support
|
||||
# Create an OpenerDirector with support
|
||||
# for Basic HTTP Authentication...
|
||||
|
||||
auth_handler = urllib2.HTTPBasicAuthHandler()
|
||||
@@ -172,7 +172,7 @@ server for requests. It can be used for the optional"scope" parameters for Face
|
||||
if current.session.token.has_key('expires_in'):
|
||||
exps = 'expires_in'
|
||||
elif current.session.token.has_key('expires'):
|
||||
exps = 'expires'
|
||||
exps = 'expires'
|
||||
else:
|
||||
exps = None
|
||||
current.session.token['expires'] = exps and \
|
||||
@@ -185,7 +185,7 @@ server for requests. It can be used for the optional"scope" parameters for Face
|
||||
current.session.token = None
|
||||
return None
|
||||
|
||||
def __init__(self, g=None,
|
||||
def __init__(self, g=None,
|
||||
client_id=None, client_secret=None,
|
||||
auth_url=None, token_url=None, **args):
|
||||
"""
|
||||
@@ -215,7 +215,7 @@ server for requests. It can be used for the optional"scope" parameters for Face
|
||||
def get_user(self):
|
||||
"""
|
||||
Override this method by sublcassing the class.
|
||||
|
||||
|
||||
"""
|
||||
if not current.session.token: return None
|
||||
return dict(first_name = 'Pinco',
|
||||
@@ -274,3 +274,4 @@ server for requests. It can be used for the optional"scope" parameters for Face
|
||||
return current.session.code
|
||||
return None
|
||||
|
||||
|
||||
|
||||
@@ -630,3 +630,4 @@ class Web2pyStore(OpenIDStore):
|
||||
return self.cleanupNonces(), self.cleanupAssociations()
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -20,3 +20,4 @@ def pam_auth():
|
||||
|
||||
return pam_auth_aux
|
||||
|
||||
|
||||
|
||||
@@ -53,12 +53,12 @@ class RPXAccount(object):
|
||||
self.prompt = prompt
|
||||
self.on_login_failure = on_login_failure
|
||||
self.mappings = Storage()
|
||||
|
||||
|
||||
dn = {'givenName':'','familyName':''}
|
||||
self.mappings.Facebook = lambda profile, dn=dn:\
|
||||
dict(registration_id = profile.get("identifier",""),
|
||||
username = profile.get("preferredUsername",""),
|
||||
email = profile.get("email",""),
|
||||
email = profile.get("email",""),
|
||||
first_name = profile.get("name",dn).get("givenName",""),
|
||||
last_name = profile.get("name",dn).get("familyName",""))
|
||||
self.mappings.Google = lambda profile, dn=dn:\
|
||||
@@ -125,3 +125,4 @@ def use_janrain(auth,filename='private/janrain.key',**kwargs):
|
||||
['register','change_password','request_reset_password']
|
||||
auth.settings.login_form = RPXAccount(
|
||||
request, api_key=key,domain=domain, url = url,**kwargs)
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ class X509Auth(object):
|
||||
# cn = self.subject.cn
|
||||
self.subject = Storage(filter(None,
|
||||
map(lambda x:
|
||||
(x,map(lambda y:
|
||||
(x,map(lambda y:
|
||||
y.get_data().as_text(),
|
||||
subject.get_entries_by_nid(subject.nid[x]))),
|
||||
subject.nid.keys())))
|
||||
@@ -63,7 +63,7 @@ class X509Auth(object):
|
||||
def login_form(self, **args):
|
||||
raise HTTP(403,'Login not allowed. No valid x509 crentials')
|
||||
|
||||
|
||||
|
||||
|
||||
def login_url(self, next="/"):
|
||||
raise HTTP(403,'Login not allowed. No valid x509 crentials')
|
||||
@@ -102,3 +102,4 @@ class X509Auth(object):
|
||||
return profile
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -801,7 +801,7 @@ def render(text,
|
||||
# this is experimental @{function/args}
|
||||
# turns into a digitally signed URL
|
||||
def u1(match,URL=URL):
|
||||
a,c,f,args = match.group('a','c','f','args')
|
||||
a,c,f,args = match.group('a','c','f','args')
|
||||
return URL(a=a or None,c=c or None,f = f or None,
|
||||
args=args.split('/'), scheme=True, host=True)
|
||||
text = regex_URL.sub(u1,text)
|
||||
|
||||
@@ -911,3 +911,4 @@ if __name__ == '__main__':
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -127,3 +127,4 @@ if __name__ == "__main__":
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -129,3 +129,4 @@ def test():
|
||||
if __name__ == '__main__':
|
||||
test()
|
||||
|
||||
|
||||
|
||||
@@ -171,3 +171,4 @@ if __name__ == '__main__':
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -9,3 +9,4 @@ from fpdf import *
|
||||
|
||||
# import warnings
|
||||
# warnings.warn("pyfpdf package name is deprecated, please use fpdf instead")
|
||||
|
||||
|
||||
@@ -964,3 +964,4 @@ if __name__ == '__main__':
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -167,3 +167,4 @@ class RedisClient(object):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -592,3 +592,4 @@ if __name__ == '__main__':
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -270,3 +270,4 @@ if __name__=='__main__':
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -151,3 +151,4 @@ if __name__ == "__main__":
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -116,3 +116,4 @@ def sms_email(number,provider):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -879,3 +879,4 @@ if __name__ == '__main__':
|
||||
print s['c'].computed_value
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -66,3 +66,4 @@ if __name__=='__main__':
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -247,3 +247,4 @@ class TaskBarIcon:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -95,3 +95,4 @@ if __name__=='__main__':
|
||||
print(t.getReportText(orderByCost=False))
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -520,3 +520,4 @@ class mobilize(object):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user