def init_apis(*args, **kwargs): def _init_model(base): """Creates User class bound to dynamic `db` variable""" global AuthGithubUser, UserModel class AuthGithubUser(base): __tablename__ = 'auth_github_user_t' oauth_id = sqlalchemy.Column(base.STRING_NAME, primary_key=True) user_name = sqlalchemy.Column(base.STRING_NAME, unique=True, nullable=False) uid = sqlalchemy.Column(base.STRING_ID, unique=True) UserModel = AuthGithubUser global cfg, AUTH_METHOD_VISIBLE cfg = pkconfig.init( callback_uri=( None, str, 'Github callback URI (defaults to api_authGithubAuthorized)'), key=pkconfig.Required(str, 'Github key'), method_visible=( True, bool, 'github auth method is visible to users when it is an enabled method', ), secret=pkconfig.Required(str, 'Github secret'), ) AUTH_METHOD_VISIBLE = cfg.method_visible auth_db.init_model(_init_model)
def init_apis(app, *args, **kwargs): global cfg cfg = pkconfig.init( key=pkconfig.Required(str, 'Github key'), secret=pkconfig.Required(str, 'Github secret'), callback_uri=(None, str, 'Github callback URI (defaults to api_authGithubAuthorized)'), ) app.session_interface = _FlaskSessionInterface() auth_db.init_model(app, _init_model)
def init_apis(*args, **kwargs): global cfg cfg = pkconfig.init( key=pkconfig.Required(str, 'Github key'), secret=pkconfig.Required(str, 'Github secret'), callback_uri=( None, str, 'Github callback URI (defaults to api_authGithubAuthorized)'), ) auth_db.init_model(_init_model)
def init_apis(*args, **kwargs): global cfg cfg = pkconfig.init( #TODO(robnagler) validate email from_email=pkconfig.Required(str, 'From email address'), from_name=pkconfig.Required(str, 'From display name'), smtp_password=pkconfig.Required(str, 'SMTP auth password'), smtp_server=pkconfig.Required(str, 'SMTP TLS server'), smtp_user=pkconfig.Required(str, 'SMTP auth user'), ) auth_db.init_model(_init_model)
def init_apis(*args, **kwargs): def _init_model(base): """Creates User class bound to dynamic `db` variable""" global AuthGithubUser, UserModel class AuthGithubUser(base): __tablename__ = 'auth_github_user_t' oauth_id = sqlalchemy.Column(sqlalchemy.String(100), primary_key=True) user_name = sqlalchemy.Column(sqlalchemy.String(100), unique=True, nullable=False) uid = sqlalchemy.Column(sqlalchemy.String(8), unique=True) UserModel = AuthGithubUser global cfg cfg = pkconfig.init( key=pkconfig.Required(str, 'Github key'), secret=pkconfig.Required(str, 'Github secret'), callback_uri=(None, str, 'Github callback URI (defaults to api_authGithubAuthorized)'), ) auth_db.init_model(_init_model)
def init_apis(app, *args, **kwargs): global cfg cfg = pkconfig.init( #TODO(robnagler) validate email from_email=pkconfig.Required(str, 'From email address'), from_name=pkconfig.Required(str, 'From display name'), smtp_password=pkconfig.Required(str, 'SMTP auth password'), smtp_server=pkconfig.Required(str, 'SMTP TLS server'), smtp_user=pkconfig.Required(str, 'SMTP auth user'), ) auth_db.init_model(app, _init_model) if pkconfig.channel_in('dev') and cfg.smtp_server == _DEV_SMTP_SERVER: return app.config.update( MAIL_USE_TLS=True, MAIL_PORT=587, MAIL_SERVER=cfg.smtp_server, MAIL_USERNAME=cfg.smtp_user, MAIL_PASSWORD=cfg.smtp_password, ) global _smtp _smtp = flask_mail.Mail(app)
def init_apis(*args, **kwargs): auth_db.init_model(_init_model)
def _verify_confirm(sim_type, token, need_complete_registration): m = flask.request.method if m == 'GET': raise sirepo.util.Redirect( sirepo.uri.local_route( sim_type, 'loginWithEmailConfirm', PKDict( token=token, needCompleteRegistration=need_complete_registration, ), ), ) assert m == 'POST', 'unexpect http method={}'.format(m) d = http_request.parse_json() if d.get('token') != token: raise sirepo.util.Error( PKDict( error='unable to confirm login', sim_type=sim_type, ), 'Expected token={} in data but got data.token={}', token, d, ) return d.get('displayName') auth_db.init_model(_init_model)