Example #1
0
 def __init__(self, db):
     self.db = db
     self.hmac_key = Auth.get_or_create_key()
     Auth.__init__(self, self.db, hmac_key=self.hmac_key)
     #self.settings.logout_onlogout = lambda user: remove_session(user)
     #self.settings.register_onaccept = lambda form: add_to_users_group(form)
     self.settings.controller = 'person'
     self.settings.on_failed_authorization = self.url('account', args='not_authorized')
     self.settings.formstyle = 'divs'
     self.settings.label_separator = ''
     self.settings.register_next = self.url('show')
     self.settings.registration_requires_verification = self.db.config.auth.registration_requires_verification
     self.settings.registration_requires_approval = self.db.config.auth.registration_requires_approval
     if 'register' in self.db.request.args and self.db.config.auth.use_recaptcha:
         from gluon.tools import Recaptcha
         recaptcha_options = dict(self.db.config.get_list('auth', 'recaptcha'))
         self.settings.captcha = Recaptcha(self.db.request,
                                 recaptcha_options['public'],
                                 recaptcha_options['private'],
                                 options="theme:'%(theme)s', lang:'%(lang)s'" % recaptcha_options)
     from datamodel.user import User
     user = User(self)
     self.entity = user.entity
     if self.db.config.auth.server == 'default':
         self.settings.mailer = Mailer(self.db)
     else:
         self.settings.mailer.server = self.db.config.auth.server
         self.settings.mailer.sender = self.db.config.auth.sender
         self.settings.mailer.login = self.db.config.auth.login
Example #2
0
    def __init__(self, db):
        self.db = db
        self.hmac_key = Auth.get_or_create_key()
        Auth.__init__(self, self.db, hmac_key=self.hmac_key)
        #self.settings.logout_onlogout = lambda user: self.remove_session(user)
        #self.settings.register_onaccept = lambda form: add_to_users_group(form)
        self.settings.register_onaccept = [lambda form: self.send_welcome_email(form.vars),
                                           lambda form: self.initial_user_permission(form.vars)]
        #self.settings.login_onaccept = [lambda form: self.initial_user_permission(form.vars)]
        #self.settings.profile_onvalidation = []
        self.settings.profile_onaccept = [lambda form: self.remove_facebook_google_alert(form)]  # remove facebook / google alert session
        #self.settings.change_password_onaccept = [] # send alert email
        self.settings.controller = 'person'
        self.settings.allow_basic_login = True
        self.settings.register_verify_password = True
        self.settings.login_url = self.url('account', args='login')
        self.settings.verify_email_next = self.url('account', args='login')
        self.settings.logged_url = self.url('account', args='profile')
        self.settings.login_next = self.db.CURL('person', 'show')
        self.settings.register_next = self.db.CURL('person', 'show')
        self.settings.profile_next = self.db.CURL('person', 'account', args='profile')
        self.settings.retrieve_username_next = self.url('account', args='login')
        self.settings.retrieve_password_next = self.url('account', args='login')
        self.settings.request_reset_password_next = self.url('account', args='login')
        self.settings.reset_password_next = self.url('account', args='login')
        self.settings.change_password_next = self.db.CURL('person', 'show')

        self.messages.verify_email = \
            'Click on the link http://' + self.db.request.env.http_host + \
            self.db.CURL('person', 'account', args=['verify_email']) + \
            '/%(key)s to verify your email'

        self.messages.reset_password = \
            'Click on the link http://' + self.db.request.env.http_host + \
            self.db.CURL('person', 'account', args=['reset_password']) + \
            '/%(key)s to reset your password'

        self.settings.on_failed_authorization = self.url('account', args='not_authorized')
        self.settings.formstyle = 'divs'
        self.settings.label_separator = ''
        self.settings.register_next = self.url('show')
        self.settings.registration_requires_verification = self.db.config.auth.registration_requires_verification
        self.settings.registration_requires_approval = self.db.config.auth.registration_requires_approval
        if 'register' in self.db.request.args and self.db.config.auth.use_recaptcha:
            from gluon.tools import Recaptcha
            recaptcha_options = dict(self.db.config.get_list('auth', 'recaptcha'))
            self.settings.captcha = Recaptcha(self.db.request,
                                    recaptcha_options['public'],
                                    recaptcha_options['private'],
                                    options="theme:'%(theme)s', lang:'%(lang)s'" % recaptcha_options)
        from datamodel.user import User
        user = User(self)
        self.entity = user.entity
        if self.db.config.auth.server == 'default':
            self.settings.mailer = Mailer(self.db)
        else:
            self.settings.mailer.server = self.db.config.auth.server
            self.settings.mailer.sender = self.db.config.auth.sender
            self.settings.mailer.login = self.db.config.auth.login
    def setUp(self):
        global request, session, auth
        request = Request(globals())  # Use a clean Request object
        request.application = 'runestone'
        session = Session()
        auth = Auth(db, hmac_key=Auth.get_or_create_key())
        # bring in the ajax controllers
        exec(compile(open("applications/runestone/controllers/ajax.py").read(), "applications/runestone/controllers/ajax.py", 'exec'), globals())

        # Create a default user and course.
        self.course_name_1 = 'test_course_1'
        self.course_id_1 = self.createCourse(self.course_name_1)
        self.user_name_1 = 'test_user_1'
        self.user_id_1 = self.createUser(self.user_name_1, self.course_id_1)
Example #4
0
    def __init__(self, db):
        self.db = db
        self.hmac_key = Auth.get_or_create_key()
        Auth.__init__(self, self.db, hmac_key=self.hmac_key)
        user = User(self)
        self.entity = user.entity

        # READ AUTH CONFIGURATION FROM CONFIG
        self.settings.formstyle = self.db.config.auth.formstyle
        if self.db.config.auth.server == "default":
            self.settings.mailer = Mailer(self.db.config)
        else:
            self.settings.mailer.server = self.db.config.auth.server
            self.settings.mailer.sender = self.db.config.auth.sender
            self.settings.mailer.login = self.db.config.auth.login
 def setUp(self):
     global request, session, auth
     request = Request(globals()) # Use a clean Request object
     session = Session()
     auth = Auth(db, hmac_key=Auth.get_or_create_key())
     exec(compile(open("applications/runestone/controllers/dashboard.py").read(), "applications/runestone/controllers/dashboard.py", 'exec'), globals())
Example #6
0
    form.vars.old_password=None
  else:
    form.vars.old_password = ns.valid.get_md5_value(form.vars.old_password)
  if form.vars.new_password=="":
    form.vars.new_password=None
  else:
    form.vars.new_password = ns.valid.get_md5_value(form.vars.new_password)

def log_event(description, vars=None, origin='auth'):
  pass

def update_groups():
  pass

from gluon.tools import Auth
auth = Auth(ns.db, hmac_key=Auth.get_or_create_key(), controller='auth_temp')

auth.settings.table_user_name = 'employee'
auth.settings.create_user_groups = False
auth.settings.registration_requires_verification = False
auth.settings.registration_requires_approval = False
auth.settings.reset_password_requires_verification = False
auth.settings.login_onvalidation = login_validation
auth.settings.change_password_onvalidation = change_pw_validation
auth.log_event=log_event
auth.update_groups=update_groups

auth.define_tables(username=True, migrate=False, fake_migrate=False)


def index():
Example #7
0
    def __init__(self, db):
        self.db = db
        self.hmac_key = Auth.get_or_create_key()
        Auth.__init__(self, self.db, hmac_key=self.hmac_key)
        # self.settings.logout_onlogout = lambda user: self.remove_session(user)
        # self.settings.register_onaccept = lambda form: add_to_users_group(form)
        self.settings.register_onaccept = [
            lambda form: self.send_welcome_email(form.vars),
            lambda form: self.initial_user_permission(form.vars),
        ]
        # self.settings.login_onaccept = [lambda form: self.initial_user_permission(form.vars)]
        # self.settings.profile_onvalidation = []
        self.settings.profile_onaccept = [
            lambda form: self.remove_facebook_google_alert(form)
        ]  # remove facebook / google alert session
        # self.settings.change_password_onaccept = [] # send alert email
        self.settings.controller = "person"
        self.settings.allow_basic_login = True
        self.settings.register_verify_password = True
        self.settings.login_url = self.url("account", args="login")
        self.settings.verify_email_next = self.url("account", args="login")
        self.settings.logged_url = self.url("account", args="profile")
        self.settings.login_next = self.db.CURL("person", "show")
        self.settings.register_next = self.db.CURL("person", "show")
        self.settings.profile_next = self.db.CURL("person", "account", args="profile")
        self.settings.retrieve_username_next = self.url("account", args="login")
        self.settings.retrieve_password_next = self.url("account", args="login")
        self.settings.request_reset_password_next = self.url("account", args="login")
        self.settings.reset_password_next = self.url("account", args="login")
        self.settings.change_password_next = self.db.CURL("person", "show")

        self.messages.verify_email = (
            "Click on the link http://"
            + self.db.request.env.http_host
            + self.db.CURL("person", "account", args=["verify_email"])
            + "/%(key)s to verify your email"
        )

        self.messages.reset_password = (
            "Click on the link http://"
            + self.db.request.env.http_host
            + self.db.CURL("person", "account", args=["reset_password"])
            + "/%(key)s to reset your password"
        )

        self.settings.on_failed_authorization = self.url("account", args="not_authorized")
        self.settings.formstyle = "divs"
        self.settings.label_separator = ""
        self.settings.register_next = self.url("show")
        self.settings.registration_requires_verification = self.db.config.auth.registration_requires_verification
        self.settings.registration_requires_approval = self.db.config.auth.registration_requires_approval
        if "register" in self.db.request.args and self.db.config.auth.use_recaptcha:
            from gluon.tools import Recaptcha

            recaptcha_options = dict(self.db.config.get_list("auth", "recaptcha"))
            self.settings.captcha = Recaptcha(
                self.db.request,
                recaptcha_options["public"],
                recaptcha_options["private"],
                options="theme:'%(theme)s', lang:'%(lang)s'" % recaptcha_options,
            )
        from datamodel.user import User

        user = User(self)
        self.entity = user.entity
        if self.db.config.auth.server == "default":
            self.settings.mailer = Mailer(self.db)
        else:
            self.settings.mailer.server = self.db.config.auth.server
            self.settings.mailer.sender = self.db.config.auth.sender
            self.settings.mailer.login = self.db.config.auth.login
Example #8
0
File: db.py Project: jorgeagua/init
## (optional) optimize handling of static files
# response.optimize_css = 'concat,minify,inline'
# response.optimize_js = 'concat,minify,inline'

#########################################################################
## Here is sample code if you need for
## - email capabilities
## - authentication (registration, login, logout, ... )
## - authorization (role based authorization)
## - services (xml, csv, json, xmlrpc, jsonrpc, amf, rss)
## - old style crud actions
## (more options discussed in gluon/tools.py)
#########################################################################

from gluon.tools import Auth, Crud, Service, PluginManager, prettydate, Mail
auth = Auth(globals(),db, hmac_key=Auth.get_or_create_key())
crud, service, plugins = Crud(db), Service(), PluginManager()

## create all tables needed by auth if not custom tables

########################################
db.define_table('auth_user',
    Field('username', type='string',
          label=T('Username')),
    Field('first_name', type='string',
          label=T('First Name')),
    Field('last_name', type='string',
          label=T('Last Name')),
    Field('email', type='string',
          label=T('Email')),
    Field('password', type='password',
Example #9
0
def get_key():
    from gluon.tools import Auth
    return Auth.get_or_create_key()
Example #10
0
# coding: utf8
## create all tables needed by auth if not custom tables

########################################
from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
auth = Auth(db, hmac_key=Auth.get_or_create_key())
crud, service, plugins = Crud(db), Service(), PluginManager()

# If communitysupport is enabled show more fields in profile
if config and config.communitysupport:
    db.define_table('auth_user',
        Field('username', type='string', label=XML('<span class="required">*</span>' + T('Username'))),
        Field('community',
            requires=IS_EMPTY_OR(IS_IN_SET(communities, error_message=T('%(name)s is invalid') % dict(name=T('Community'))))
        ),
        Field('name', type='string',
              label=T('Name')),
        Field('phone', type='string',
              label=T('Phone')),
        Field('location', type='string',
              label=T('Location')),
        Field('note', type='text',
              label=T('Note')),
        Field('homepage',
            requires=IS_EMPTY_OR(
                IS_URL(error_message=T("%(name)s isn't a valid URL") % dict(name=T('Homepage'), len='255'))
            )
        ),
        Field('email', type='string',
              label=T('Email')),
        Field('pubkeys', type='text',
 def setUp(self):
     global request, session, auth
     request = Request(globals()) # Use a clean Request object
     session = Session()
     auth = Auth(db, hmac_key=Auth.get_or_create_key())
     execfile("applications/runestone/controllers/dashboard.py", globals())
Example #12
0
# coding: utf-8

# auth
# mailer
# crypto

from gluon.tools import Auth, Mail, Service

# class MyServiceHandler(Service):
#     def windows_wpf(self, *args, **kwargs):
#         pass

service = Service()

auth = Auth(db, hmac_key=Auth.get_or_create_key(), controller="home")

mail = Mail()
mail.settings.server = "logging"
mail.settings.sender = "*****@*****.**"
mail.settings.login = "******"

auth.settings.mailer = mail
auth.settings.formstyle = "divs"
auth.settings.extra_fields['auth_user'] = [
    Field("cliente_especial", "boolean", default=False),
    Field("bloqueado", "boolean", default=False)
]

# auth.settings.login_next = URL()

auth.define_tables()
Example #13
0
File: db.py Project: d4ncer/GWGGPIB
## (optional) optimize handling of static files
# response.optimize_css = 'concat,minify,inline'
# response.optimize_js = 'concat,minify,inline'

#########################################################################
## Here is sample code if you need for
## - email capabilities
## - authentication (registration, login, logout, ... )
## - authorization (role based authorization)
## - services (xml, csv, json, xmlrpc, jsonrpc, amf, rss)
## - old style crud actions
## (more options discussed in gluon/tools.py)
#########################################################################

from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
auth = Auth(db, hmac_key=Auth.get_or_create_key(), salt=True)
crud, service, plugins = Crud(db), Service(), PluginManager()

## create all tables needed by auth if not custom tables
auth.define_tables()

## configure email
mail=auth.settings.mailer
mail.settings.server = 'logging' or 'smtp.gmail.com:587'
mail.settings.sender = '*****@*****.**'
mail.settings.login = '******'

## configure auth policy
auth.settings.registration_requires_verification = False
auth.settings.registration_requires_approval = True
auth.settings.reset_password_requires_verification = True
Example #14
0
# -------------------------------------------------------------------------
# response.static_version = '0.0.0'

# -------------------------------------------------------------------------
# Here is sample code if you need for
# - email capabilities
# - authentication (registration, login, logout, ... )
# - authorization (role based authorization)
# - services (xml, csv, json, xmlrpc, jsonrpc, amf, rss)
# - old style crud actions
# (more options discussed in gluon/tools.py)
# -------------------------------------------------------------------------

# host names must be a list of allowed host names (glob syntax allowed)
auth = Auth(db,
            hmac_key=Auth.get_or_create_key(),
            controller="default",
            function="user")
auth.settings.login_next = URL('index')

# -------------------------------------------------------------------------
# create all tables needed by auth if not custom tables
# -------------------------------------------------------------------------
auth.define_tables(username=False, signature=False)

# -------------------------------------------------------------------------
# configure email
# -------------------------------------------------------------------------

# -------------------------------------------------------------------------
# configure auth policy
Example #15
0
# coding: utf-8

# auth
# mailer
# crypto

from gluon.tools import Auth, Mail, Service

# class MyServiceHandler(Service):
#     def windows_wpf(self, *args, **kwargs):
#         pass

service = Service()

auth = Auth(db, hmac_key=Auth.get_or_create_key(), controller="home")

mail = Mail()
mail.settings.server = "logging"
mail.settings.sender = "*****@*****.**"
mail.settings.login = "******"

auth.settings.mailer = mail
auth.settings.formstyle = "divs"
auth.settings.extra_fields["auth_user"] = [
    Field("cliente_especial", "boolean", default=False),
    Field("bloqueado", "boolean", default=False),
]

# auth.settings.login_next = URL()

auth.define_tables()
Example #16
0
plugins = PluginManager()       # for configuring plugins
current.db = db                 # to access db from modules

#-------------------------------------------------------------
# get private data from secure file
#-------------------------------------------------------------
keydata = {}
with open('applications/paideia/private/app.keys', 'r') as keyfile:
    for line in keyfile:
        k, v = line.split()
        keydata[k] = v

#-------------------------------------------------------------
#configure authorization
#-------------------------------------------------------------
auth = Auth(db, hmac_key=Auth.get_or_create_key())  # authent/authorization

#-------------------------------------------------------------
# place auth in current so it can be imported by modules
#-------------------------------------------------------------

current.auth = auth

#-------------------------------------------------------------
#misc auth settings
#-------------------------------------------------------------
auth.settings.create_user_groups = False
auth.settings.label_separator = ''

#-------------------------------------------------------------
# Customizing auth tables
Example #17
0
## (optional) optimize handling of static files
# response.optimize_css = 'concat,minify,inline'
# response.optimize_js = 'concat,minify,inline'

#########################################################################
## Here is sample code if you need for
## - email capabilities
## - authentication (registration, login, logout, ... )
## - authorization (role based authorization)
## - services (xml, csv, json, xmlrpc, jsonrpc, amf, rss)
## - old style crud actions
## (more options discussed in gluon/tools.py)
#########################################################################

from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
auth = Auth(db, hmac_key=Auth.get_or_create_key())
crud, service, plugins = Crud(db), Service(), PluginManager()

## create all tables needed by auth if not custom tables
auth.define_tables()

## configure email
mail=auth.settings.mailer
mail.settings.server = 'logging' or 'smtp.gmail.com:587'
mail.settings.sender = '*****@*****.**'
mail.settings.login = '******'

## configure auth policy
auth.settings.registration_requires_verification = False
auth.settings.registration_requires_approval = False
auth.settings.reset_password_requires_verification = True
Example #18
0
#coding: utf-8

# definir objetos da app (Auth, Mail, Service)

from gluon.tools import Auth, Mail, Service

service = Service()

auth = Auth(db, hmac_key=Auth.get_or_create_key(), controller="home", function="user")

#session.connect(request, response, db)

auth.settings.login_next = URL('home', 'index')

# CAPTCHA

# from gluon.tools import Recaptcha
# auth.settings.captcha = Recaptcha(request,
#     'PUBLIC_KEY', 'PRIVATE_KEY')

# auth_user, auth_groups, auth_membership, auth_permission

auth.settings.extra_fields["auth_user"] = [
    Field("picture", "upload"),
    Field("zipcode"),
    Field("address"),
    Field("house_number")
]

# auth.settings.registration_requires_verification = False
# auth.settings.registration_requires_approval = False