示例#1
0
_settings = auth.settings
_settings.lock_keys = False

_settings.password_min_length = 4
_settings.expiration = 28800  # seconds

_settings.facebook = settings.get_auth_facebook()
_settings.google = settings.get_auth_google()

if settings.get_auth_openid():
    # Requires http://pypi.python.org/pypi/python-openid/
    try:
        from gluon.contrib.login_methods.openid_auth import OpenIDAuth
        openid_login_form = OpenIDAuth(auth)
        from gluon.contrib.login_methods.extended_login_form import ExtendedLoginForm
        extended_login_form = ExtendedLoginForm(
            auth, openid_login_form, signals=["oid", "janrain_nonce"])
        auth.settings.login_form = extended_login_form
    except ImportError:
        session.warning = T("Library support not available for OpenID")

# Allow use of LDAP accounts for login
# NB Currently this means that change password should be disabled:
#_settings.actions_disabled.append("change_password")
# (NB These are not automatically added to PR or to Authenticated role since they enter via the login() method not register())
#from gluon.contrib.login_methods.ldap_auth import ldap_auth
# Require even alternate login methods to register users 1st
#_settings.alternate_requires_registration = True
# Active Directory
#_settings.login_methods.append(ldap_auth(mode="ad", server="dc.domain.org", base_dn="ou=Users,dc=domain,dc=org"))
# or if not wanting local users at all (no passwords saved within DB):
#_settings.login_methods = [ldap_auth(mode="ad", server="dc.domain.org", base_dn="ou=Users,dc=domain,dc=org")]
示例#2
0
    #auth.settings.login_form = RPXAccount(request,
    #api_key='4f608d8fa6a0ad46654e51f484fc504334a5ba01',
    #domain='netdecisionmaking',
    #url = "https://testdecisionmaking.appspot.com/%s/default/user/login" % request.application)
elif settings.logon_methods == 'web2pyandjanrain':  # this is now proving useless as no providers really work
    #Dual login sort of working but not fully tested with Janrain - doesnt work with gae
    #from gluon.contrib.login_methods.extended_login_form import ExtendedLoginForm
    #from gluon.contrib.login_methods.rpx_account import RPXAccount
    #other_form = use_janrain(auth, filename='private/janrain.key')
    #auth.settings.login_form = ExtendedLoginForm(auth, other_form, signals=['token'])
    from gluon.contrib.login_methods.extended_login_form import ExtendedLoginForm
    from gluon.contrib.login_methods.rpx_account import RPXAccount
    filename = 'private/janrain.key'
    path = os.path.join(current.request.folder, filename)
    if os.path.exists(path):
        request = current.request
        domain, key = open(path, 'r').read().strip().split(':')
        host = current.request.env.http_host
        url = URL('default', 'user', args='login', scheme=True)
        other_form = RPXAccount(request, api_key=key, domain=domain, url=url)
        auth.settings.login_form = ExtendedLoginForm(auth,
                                                     other_form,
                                                     signals=['token'])

#########################################################################
## Define your tables below (or better in another model file)
##
## >>>setup tables are all defined in db__first.py
## >>>main tables are all defined in db_gdms.py
#########################################################################
示例#3
0
#use_janrain(auth,filename='private/janrain.key')
try:
    from gluon.contrib.login_methods.janrain_account import RPXAccount
except:
    print "Warning you should upgrade to a newer web2py for better janrain support"
    from gluon.contrib.login_methods.rpx_account import RPXAccount
from gluon.contrib.login_methods.extended_login_form import ExtendedLoginForm

janrain_url = 'http://%s/%s/default/user/login' % (request.env.http_host,
                                                   request.application)

janrain_form = RPXAccount(request,
                          api_key=settings.janrain_api_key, # set in 1.py
                          domain=settings.janrain_domain, # set in 1.py
                          url=janrain_url)
auth.settings.login_form = ExtendedLoginForm(auth, janrain_form) # uncomment this to use both Janrain and web2py auth
#auth.settings.login_form = auth # uncomment this to just use web2py integrated authentication

request.janrain_form = janrain_form # save the form so that it can be added to the user/register controller

#########################################################################
## Define your tables below (or better in another model file) for example
##
## >>> db.define_table('mytable',Field('myfield','string'))
##
## Fields can be 'string','text','password','integer','double','boolean'
##       'date','time','datetime','blob','upload', 'reference TABLENAME'
## There is an implicit 'id integer autoincrement' field
## Consult manual for more options, validators, etc.
##
## More API examples for controllers:
示例#4
0
文件: db.py 项目: tennana/2d6equals4
# after defining tables, uncomment below to enable auditing
# -------------------------------------------------------------------------
auth.enable_record_versioning(db)

from gluon.contrib.login_methods.janrain_account import RPXAccount
from gluon.contrib.login_methods.extended_login_form import ExtendedLoginForm

RPXAccount_form = RPXAccount(request,
                             api_key=settings.janrain_secret_key,
                             domain=settings.janrain_app_name,
                             language="ja",
                             url="http://%s/%s/default/user/login" %
                             (request.env.http_host, request.application))

auth.settings.login_form = ExtendedLoginForm(auth,
                                             RPXAccount_form,
                                             signals=['token'])
auth.settings.formstyle = 'table2cols'
auth.settings.registration_requires_verification = False
auth.settings.login_after_registration = False
auth.settings.register_fields = ['first_name', 'email', 'password']
auth.settings.profile_fields = ['first_name', 'email']
auth.settings.update_fields = []

RPXAccount_form.mappings.Twitter = lambda profile:\
    dict(registration_id = profile["identifier"],
         username = profile["preferredUsername"],
         first_name = profile["displayName"],
         last_name = '')

from gluon import current