def _auth(self): """Create a auth instance. """ auth = Auth(self.environment, self.db) # authentication/authorization auth.settings.hmac_key = self.local_settings.hmac_key auth.define_tables() # creates all needed tables if self.settings_loader: self.settings_loader.import_settings(group='auth', storage=auth.settings) auth.settings.mailer = self.mail auth.settings.verify_email_onaccept = self.verify_email_onaccept host = '' request = self.environment['request'] if 'wsgi' in request.keys(): if 'environ' in request['wsgi'].keys(): host = request['wsgi']['environ']['HTTP_HOST'] elif 'env' in request.keys(): host = request.env.http_post else: LOG.warn("No host for verify_email and reset_password links") auth.messages.verify_email = 'Click on the link http://' + host \ + '/' + request.application \ + '/default/user/verify_email/%(key)s to verify your email' auth.messages.reset_password = '******' + host \ + '/' + request.application \ + '/default/user/reset_password/%(key)s to reset your password' auth.signature = self.db.Table(self.db, 'auth_signature', Field('created_on', 'datetime', default=request.now, writable=False, readable=False), Field('updated_on', 'datetime', default=request.now, update=request.now, writable=False, readable=False)) return auth
def _auth(self): """Create a auth instance. """ auth = Auth(db=self.db, hmac_key=self.local_settings.hmac_key) # This may need to be set to True the first time an app is used. if not self.local_settings.disable_authentication: auth.settings.extra_fields['auth_user'] = [Field('name')] auth.define_tables(username=False, signature=False, migrate=True) if self.settings_loader: self.settings_loader.import_settings(group='auth', storage=auth.settings) auth.settings.mailer = self.mail auth.settings.verify_email_onaccept = self.verify_email_onaccept # Controller tests scripts require login's with same session. if self.get_server_mode() == 'test': # Resetting the session farks with controller test scripts auth.settings.renew_session_onlogin = False auth.settings.renew_session_onlogout = False else: auth.settings.renew_session_onlogin = True auth.settings.renew_session_onlogout = True host = '' request = self.environment['request'] if 'wsgi' in request.keys(): if hasattr(request['wsgi'], 'environ') and \ request['wsgi'].environ and \ 'HTTP_HOST' in request['wsgi'].environ: host = request['wsgi'].environ['HTTP_HOST'] elif 'env' in request.keys(): host = request.env.http_post if host: auth.messages.verify_email = 'Click on the link http://' + host \ + '/' + request.application \ + '/default/user/verify_email/%(key)s to verify your email' auth.messages.reset_password = '******' + host \ + '/' + request.application \ + '/default/user/reset_password/%(key)s to reset your password' # W0108: *Lambda may not be necessary* # pylint: disable=W0108 auth.signature = self.db.Table(self.db, 'auth_signature', Field('created_on', 'datetime', default=request.now, represent=lambda x: str(x), readable=False, writable=False, ), Field('updated_on', 'datetime', default=request.now, update=request.now, represent=lambda x: str(x), readable=False, writable=False, )) return auth
def _auth(self): """Create a auth instance. """ auth = Auth(db=self.db, hmac_key=self.local_settings.hmac_key) self._auth_post_hook(auth) # This may need to be set to True the first time an app is used. if not self.local_settings.disable_authentication: # Create auth_* tables without signature auth.define_tables(username=False, signature=False, migrate=False) if self.settings_loader: self.settings_loader.import_settings( group=['auth', 'settings'], storage=auth.settings, unicode_to_str=True ) auth.settings.mailer = self.mail auth.settings.verify_email_onaccept = self.verify_email_onaccept # Controller tests scripts require login's with same session. if self.get_server_mode() == 'test': # Resetting the session farks with controller test scripts auth.settings.renew_session_onlogin = False auth.settings.renew_session_onlogout = False else: auth.settings.renew_session_onlogin = True auth.settings.renew_session_onlogout = True host = '' request = self.environment['request'] if 'wsgi' in request.keys(): if hasattr(request['wsgi'], 'environ') and \ request['wsgi'].environ and \ 'HTTP_HOST' in request['wsgi'].environ: host = request['wsgi'].environ['HTTP_HOST'] elif 'env' in request.keys(): host = request.env.http_post if host: auth.messages.verify_email = 'Click on the link http://' + host \ + '/' + request.application \ + '/default/user/verify_email/%(key)s to verify your email' auth.messages.reset_password = '******' + host \ + '/' + request.application \ + '/default/user/reset_password/%(key)s to reset your password' # W0108: *Lambda may not be necessary* # pylint: disable=W0108 auth.signature = self.db.Table( self.db, 'auth_signature', Field( 'created_on', 'datetime', default=request.now, represent=lambda x: str(x), readable=False, writable=False, ), Field( 'updated_on', 'datetime', default=request.now, update=request.now, represent=lambda x: str(x), readable=False, writable=False, ) ) return auth