def init_security_service(self): self.security_service = Security() self.security_service._state = self.security_service.init_app(self.app) self.user_loader(self._load_auth_token) self.request_loader(self._request_loader) self.login_unauthorized_handler(self._login_unauthorized_handler) self.token_unauthorized_handler(self._token_unauthorized_handler)
csrf.init_app(app) @csrf.error_handler def csrf_error(reason): app.logger.debug("CSRF ERROR: {}".format(reason)) return render_template('csrf_error.json', reason=reason), 400 from security_monkey.datastore import User, Role ### Flask-Security ### from flask_security.core import Security from flask_security.datastore import SQLAlchemyUserDatastore user_datastore = SQLAlchemyUserDatastore(db, User, Role) security = Security(app, user_datastore) @security.send_mail_task def send_email(msg): """ Overrides the Flask-Security/Flask-Mail integration to send emails out via boto and ses. """ common_send_email(subject=msg.subject, recipients=msg.recipients, html=msg.html) from auth.modules import RBAC rbac = RBAC(app=app)