def client_config(): if not current_user.is_api_user() and current_user.is_authenticated: client_config = { 'newVersionAvailable': bool(get_latest_version()), 'version': __version__ } else: client_config = {} if current_user.has_permission('admin') and current_org.get_setting('beacon_consent') is None: client_config['showBeaconConsentMessage'] = True defaults = { 'allowScriptsInUserInput': settings.ALLOW_SCRIPTS_IN_USER_INPUT, 'showPermissionsControl': current_org.get_setting("feature_show_permissions_control"), 'allowCustomJSVisualizations': settings.FEATURE_ALLOW_CUSTOM_JS_VISUALIZATIONS, 'autoPublishNamedQueries': settings.FEATURE_AUTO_PUBLISH_NAMED_QUERIES, 'extendedAlertOptions': settings.FEATURE_EXTENDED_ALERT_OPTIONS, 'mailSettingsMissing': not settings.email_server_is_configured(), 'dashboardRefreshIntervals': settings.DASHBOARD_REFRESH_INTERVALS, 'queryRefreshIntervals': settings.QUERY_REFRESH_INTERVALS, 'googleLoginEnabled': settings.GOOGLE_OAUTH_ENABLED, 'pageSize': settings.PAGE_SIZE, 'pageSizeOptions': settings.PAGE_SIZE_OPTIONS, 'tableCellMaxJSONSize': settings.TABLE_CELL_MAX_JSON_SIZE, } client_config.update(defaults) client_config.update({ 'basePath': base_href() }) client_config.update(date_time_format_config()) client_config.update(number_format_config()) return client_config
def client_config(): if not current_user.is_api_user() and current_user.is_authenticated: client_config = { "newVersionAvailable": bool(get_latest_version()), "version": __version__, } else: client_config = {} if (current_user.has_permission("admin") and current_org.get_setting("beacon_consent") is None): client_config["showBeaconConsentMessage"] = True defaults = { "allowScriptsInUserInput": settings.ALLOW_SCRIPTS_IN_USER_INPUT, "showPermissionsControl": current_org.get_setting("feature_show_permissions_control"), "hidePlotlyModeBar": current_org.get_setting("hide_plotly_mode_bar"), "disablePublicUrls": current_org.get_setting("disable_public_urls"), "disableEmbedUrls": current_org.get_setting("disable_embed_urls"), "allowCustomJSVisualizations": settings.FEATURE_ALLOW_CUSTOM_JS_VISUALIZATIONS, "autoPublishNamedQueries": settings.FEATURE_AUTO_PUBLISH_NAMED_QUERIES, "extendedAlertOptions": settings.FEATURE_EXTENDED_ALERT_OPTIONS, "mailSettingsMissing": not settings.email_server_is_configured(), "dashboardRefreshIntervals": settings.DASHBOARD_REFRESH_INTERVALS, "queryRefreshIntervals": settings.QUERY_REFRESH_INTERVALS, "googleLoginEnabled": settings.GOOGLE_OAUTH_ENABLED, "microsoftLoginEnabled": settings.MICROSOFT_OAUTH_ENABLED, "ldapLoginEnabled": settings.LDAP_LOGIN_ENABLED, "pageSize": settings.PAGE_SIZE, "pageSizeOptions": settings.PAGE_SIZE_OPTIONS, "tableCellMaxJSONSize": settings.TABLE_CELL_MAX_JSON_SIZE, } client_config.update(defaults) client_config.update({"basePath": base_href()}) client_config.update(date_time_format_config()) client_config.update(number_format_config()) return client_config
def date_time_format_config(): date_format = current_org.get_setting("date_format") date_format_list = set(["DD/MM/YY", "MM/DD/YY", "YYYY-MM-DD", settings.DATE_FORMAT]) time_format = current_org.get_setting("time_format") time_format_list = set(["HH:mm", "HH:mm:ss", "HH:mm:ss.SSS", settings.TIME_FORMAT]) return { "dateFormat": date_format, "dateFormatList": list(date_format_list), "timeFormatList": list(time_format_list), "dateTimeFormat": "{0} {1}".format(date_format, time_format), }
def date_time_format_config(): date_format = current_org.get_setting('date_format') date_format_list = set(["DD/MM/YY", "MM/DD/YY", "YYYY-MM-DD", settings.DATE_FORMAT]) time_format = current_org.get_setting('time_format') time_format_list = set(["HH:mm", "MM:mm:ss", "HH:mm:ss.SSS", settings.TIME_FORMAT]) return { 'dateFormat': date_format, 'dateFormatList': list(date_format_list), 'timeFormatList': list(time_format_list), 'dateTimeFormat': "{0} {1}".format(date_format, time_format), }
def login(org_slug=None): # We intentionally use == as otherwise it won't actually use the proxy. So weird :O # noinspection PyComparisonWithNone if current_org == None and not settings.MULTI_ORG: return redirect("/setup") elif current_org == None: return redirect("/") index_url = url_for("redash.index", org_slug=org_slug) unsafe_next_path = request.args.get("next", index_url) next_path = get_next_path(unsafe_next_path) if current_user.is_authenticated: return redirect(next_path) if request.method == "POST" and current_org.get_setting("auth_password_login_enabled"): try: org = current_org._get_current_object() user = models.User.get_by_email_and_org(request.form["email"], org) if ( user and not user.is_disabled and user.verify_password(request.form["password"]) ): remember = "remember" in request.form login_user(user, remember=remember) return redirect(next_path) else: flash("电子邮箱或密码不正确。") except NoResultFound: flash("电子邮箱或密码不正确。") elif request.method == "POST" and not current_org.get_setting("auth_password_login_enabled"): flash("当前组织密码不正确。") google_auth_url = get_google_auth_url(next_path) return render_template( "login.html", org_slug=org_slug, next=next_path, email=request.form.get("email", ""), show_google_openid=settings.GOOGLE_OAUTH_ENABLED, google_auth_url=google_auth_url, show_password_login=current_org.get_setting("auth_password_login_enabled"), show_saml_login=current_org.get_setting("auth_saml_enabled"), show_remote_user_login=settings.REMOTE_USER_LOGIN_ENABLED, show_ldap_login=settings.LDAP_LOGIN_ENABLED, )
def login(org_slug=None): # We intentionally use == as otherwise it won't actually use the proxy. So weird :O # noinspection PyComparisonWithNone if current_org == None and not settings.MULTI_ORG: return redirect('/setup') elif current_org == None: return redirect('/') index_url = url_for('redash.index', org_slug=org_slug) unsafe_next_path = request.args.get('next', index_url) next_path = get_next_path(unsafe_next_path) if current_user.is_authenticated: return redirect(next_path) # support cas auth if settings.CAS_AUTH: org = current_org._get_current_object() remember = ('remember' in request.form) cas_auth(org, remember) return redirect(next_path) if request.method == 'POST': try: org = current_org._get_current_object() user = models.User.get_by_email_and_org(request.form['email'], org) if user and not user.is_disabled and user.verify_password( request.form['password']): remember = ('remember' in request.form) login_user(user, remember=remember) return redirect(next_path) else: flash("Wrong email or password.") except NoResultFound: flash("Wrong email or password.") google_auth_url = get_google_auth_url(next_path) return render_template( "login.html", org_slug=org_slug, next=next_path, email=request.form.get('email', ''), show_google_openid=settings.GOOGLE_OAUTH_ENABLED, google_auth_url=google_auth_url, show_password_login=current_org.get_setting( 'auth_password_login_enabled'), show_saml_login=current_org.get_setting('auth_saml_enabled'), show_remote_user_login=settings.REMOTE_USER_LOGIN_ENABLED, show_ldap_login=settings.LDAP_LOGIN_ENABLED)
def client_config(): if not current_user.is_api_user() and current_user.is_authenticated: client_config = { 'newVersionAvailable': bool(get_latest_version()), 'version': __version__ } else: client_config = {} defaults = { 'allowScriptsInUserInput': settings.ALLOW_SCRIPTS_IN_USER_INPUT, 'showPermissionsControl': current_org.get_setting("feature_show_permissions_control"), 'allowCustomJSVisualizations': settings.FEATURE_ALLOW_CUSTOM_JS_VISUALIZATIONS, 'autoPublishNamedQueries': settings.FEATURE_AUTO_PUBLISH_NAMED_QUERIES, 'mailSettingsMissing': not settings.email_server_is_configured(), 'dashboardRefreshIntervals': settings.DASHBOARD_REFRESH_INTERVALS, 'queryRefreshIntervals': settings.QUERY_REFRESH_INTERVALS, 'googleLoginEnabled': settings.GOOGLE_OAUTH_ENABLED, 'pageSize': settings.PAGE_SIZE, 'pageSizeOptions': settings.PAGE_SIZE_OPTIONS, 'tableCellMaxJSONSize': settings.TABLE_CELL_MAX_JSON_SIZE, } client_config.update(defaults) client_config.update({ 'basePath': base_href() }) client_config.update(date_format_config()) client_config.update(number_format_config()) return client_config
def client_config(): if not current_user.is_api_user() and current_user.is_authenticated: client_config = { 'newVersionAvailable': get_latest_version(), 'version': __version__ } else: client_config = {} date_format = current_org.get_setting('date_format') defaults = { 'allowScriptsInUserInput': settings.ALLOW_SCRIPTS_IN_USER_INPUT, 'showPermissionsControl': settings.FEATURE_SHOW_PERMISSIONS_CONTROL, 'allowCustomJSVisualizations': settings.FEATURE_ALLOW_CUSTOM_JS_VISUALIZATIONS, 'autoPublishNamedQueries': settings.FEATURE_AUTO_PUBLISH_NAMED_QUERIES, 'dateFormat': date_format, 'dateTimeFormat': "{0} HH:mm".format(date_format), 'mailSettingsMissing': settings.MAIL_DEFAULT_SENDER is None, 'dashboardRefreshIntervals': settings.DASHBOARD_REFRESH_INTERVALS, 'queryRefreshIntervals': settings.QUERY_REFRESH_INTERVALS, 'googleLoginEnabled': settings.GOOGLE_OAUTH_ENABLED, } client_config.update(defaults) client_config.update({'basePath': base_href()}) return client_config
def client_config(): if not current_user.is_api_user() and current_user.is_authenticated: client_config = { 'newVersionAvailable': get_latest_version(), 'version': __version__ } else: client_config = {} date_format = current_org.get_setting('date_format') defaults = { 'allowScriptsInUserInput': settings.ALLOW_SCRIPTS_IN_USER_INPUT, 'showPermissionsControl': settings.FEATURE_SHOW_PERMISSIONS_CONTROL, 'allowCustomJSVisualizations': settings.FEATURE_ALLOW_CUSTOM_JS_VISUALIZATIONS, 'autoPublishNamedQueries': settings.FEATURE_AUTO_PUBLISH_NAMED_QUERIES, 'dateFormat': date_format, 'dateTimeFormat': "{0} HH:mm".format(date_format), 'mailSettingsMissing': settings.MAIL_DEFAULT_SENDER is None, 'dashboardRefreshIntervals': settings.DASHBOARD_REFRESH_INTERVALS, 'queryRefreshIntervals': settings.QUERY_REFRESH_INTERVALS, 'googleLoginEnabled': settings.GOOGLE_OAUTH_ENABLED, } client_config.update(defaults) client_config.update({ 'basePath': base_href() }) return client_config
def login(org_slug=None): # We intentionally use == as otherwise it won't actually use the proxy. So weird :O # noinspection PyComparisonWithNone if current_org == None and not settings.MULTI_ORG: return redirect('/setup') elif current_org == None: return redirect('/') index_url = url_for("redash.index", org_slug=org_slug) next_path = request.args.get('next', index_url) if current_user.is_authenticated: return redirect(next_path) if not current_org.get_setting('auth_password_login_enabled'): if settings.REMOTE_USER_LOGIN_ENABLED: return redirect(url_for("remote_user_auth.login", next=next_path)) elif current_org.get_setting('auth_saml_enabled'): # settings.SAML_LOGIN_ENABLED: return redirect(url_for("saml_auth.sp_initiated", next=next_path)) elif settings.LDAP_LOGIN_ENABLED: return redirect(url_for("ldap_auth.login", next=next_path)) else: return redirect(url_for("google_oauth.authorize", next=next_path)) if request.method == 'POST': try: org = current_org._get_current_object() user = models.User.get_by_email_and_org(request.form['email'], org) if user and user.verify_password(request.form['password']): remember = ('remember' in request.form) login_user(user, remember=remember) return redirect(next_path) else: flash("Wrong email or password.") except NoResultFound: flash("Wrong email or password.") google_auth_url = get_google_auth_url(next_path) return render_template("login.html", org_slug=org_slug, next=next_path, email=request.form.get('email', ''), show_google_openid=settings.GOOGLE_OAUTH_ENABLED, google_auth_url=google_auth_url, show_saml_login=current_org.get_setting('auth_saml_enabled'), show_remote_user_login=settings.REMOTE_USER_LOGIN_ENABLED, show_ldap_login=settings.LDAP_LOGIN_ENABLED)
def date_format_config(): date_format = current_org.get_setting('date_format') date_format_list = set(["DD/MM/YY", "MM/DD/YY", "YYYY-MM-DD", settings.DATE_FORMAT]) return { 'dateFormat': date_format, 'dateFormatList': list(date_format_list), 'dateTimeFormat': "{0} HH:mm".format(date_format), }
def date_format_config(): date_format = current_org.get_setting('date_format') date_format_list = set(["DD/MM/YY", "MM/DD/YY", "YYYY-MM-DD", settings.DATE_FORMAT]) return { 'dateFormat': date_format, 'dateFormatList': list(date_format_list), 'dateTimeFormat': "{0} HH:mm".format(date_format), }
def render_token_login_page(template, org_slug, token, invite): try: user_id = validate_token(token) org = current_org._get_current_object() user = models.User.get_by_id_and_org(user_id, org) except NoResultFound: logger.exception("Bad user id in token. Token= , User id= %s, Org=%s", user_id, token, org_slug) return render_template( "error.html", error_message="Invalid invite link. Please ask for a new one." ), 400 except (SignatureExpired, BadSignature): logger.exception("Failed to verify invite token: %s, org=%s", token, org_slug) return render_template( "error.html", error_message= "Your invite link has expired. Please ask for a new one."), 400 if invite and user.details.get('is_invitation_pending') is False: return render_template( "error.html", error_message=("This invitation has already been accepted. " "Please try resetting your password instead.")), 400 status_code = 200 if request.method == 'POST': if 'password' not in request.form: flash('Bad Request') status_code = 400 elif not request.form['password']: flash('Cannot use empty password.') status_code = 400 elif len(request.form['password']) < 6: flash('Password length is too short (<6).') status_code = 400 else: if invite: user.is_invitation_pending = False user.hash_password(request.form['password']) models.db.session.add(user) login_user(user) models.db.session.commit() return redirect(url_for('redash.index', org_slug=org_slug)) google_auth_url = get_google_auth_url( url_for('redash.index', org_slug=org_slug)) return render_template( template, show_google_openid=settings.GOOGLE_OAUTH_ENABLED, google_auth_url=google_auth_url, show_saml_login=current_org.get_setting('auth_saml_enabled'), show_remote_user_login=settings.REMOTE_USER_LOGIN_ENABLED, show_ldap_login=settings.LDAP_LOGIN_ENABLED, org_slug=org_slug, user=user), status_code
def render_token_login_page(template, org_slug, token, invite=True): try: user_id = validate_token(token) org = current_org._get_current_object() user = models.User.get_by_id_and_org(user_id, org) except NoResultFound: logger.exception("Bad user id in token. Token= , User id= %s, Org=%s", user_id, token, org_slug) return render_template("error.html", error_message="Invalid invite link. Please ask for a new one."), 400 except (SignatureExpired, BadSignature): logger.exception("Failed to verify invite token: %s, org=%s", token, org_slug) return render_template("error.html", error_message="Your invite link has expired. Please ask for a new one."), 400 if invite and user.details.get('is_invitation_pending') is False: return render_template("error.html", error_message=("This invitation has already been accepted. " "Please try resetting your password instead.")), 400 status_code = 200 if request.method == 'POST': if 'password' not in request.form: flash('Bad Request') status_code = 400 elif not request.form['password']: flash('Cannot use empty password.') status_code = 400 elif len(request.form['password']) < 6: flash('Password length is too short (<6).') status_code = 400 else: if invite: user.is_invitation_pending = False user.hash_password(request.form['password']) models.db.session.add(user) login_user(user) models.db.session.commit() return redirect(url_for('redash.index', org_slug=org_slug)) google_auth_url = get_google_auth_url(url_for('redash.index', org_slug=org_slug)) return render_template(template, show_google_openid=settings.GOOGLE_OAUTH_ENABLED, google_auth_url=google_auth_url, show_saml_login=current_org.get_setting('auth_saml_enabled'), show_remote_user_login=settings.REMOTE_USER_LOGIN_ENABLED, show_ldap_login=settings.LDAP_LOGIN_ENABLED, org_slug=org_slug, user=user), status_code
def forgot_password(org_slug=None): if not current_org.get_setting('auth_password_login_enabled'): abort(404) submitted = False if request.method == 'POST' and request.form['email']: submitted = True email = request.form['email'] try: org = current_org._get_current_object() user = models.User.get_by_email_and_org(email, org) send_password_reset_email(user) except NoResultFound: logging.error("No user found for forgot password: %s", email) return render_template("forgot.html", submitted=submitted)
def forgot_password(org_slug=None): if not current_org.get_setting('auth_password_login_enabled'): abort(404) submitted = False if request.method == 'POST' and request.form['email']: submitted = True email = request.form['email'] try: org = current_org._get_current_object() user = models.User.get_by_email_and_org(email, org) send_password_reset_email(user) except NoResultFound: logging.error("No user found for forgot password: %s", email) return render_template("forgot.html", submitted=submitted)
def client_config(): if not current_user.is_api_user() and current_user.is_authenticated: client_config = { 'newVersionAvailable': bool(get_latest_version()), 'version': __version__ } else: client_config = {} defaults = { 'allowScriptsInUserInput': settings.ALLOW_SCRIPTS_IN_USER_INPUT, 'showPermissionsControl': current_org.get_setting("feature_show_permissions_control"), 'allowCustomJSVisualizations': settings.FEATURE_ALLOW_CUSTOM_JS_VISUALIZATIONS, 'autoPublishNamedQueries': settings.FEATURE_AUTO_PUBLISH_NAMED_QUERIES, 'mailSettingsMissing': settings.MAIL_DEFAULT_SENDER is None, 'dashboardRefreshIntervals': settings.DASHBOARD_REFRESH_INTERVALS, 'queryRefreshIntervals': settings.QUERY_REFRESH_INTERVALS, 'googleLoginEnabled': settings.GOOGLE_OAUTH_ENABLED, 'pageSize': settings.PAGE_SIZE, 'pageSizeOptions': settings.PAGE_SIZE_OPTIONS, } client_config.update(defaults) client_config.update({'basePath': base_href()}) client_config.update(date_format_config()) client_config.update(number_format_config()) return client_config
def number_format_config(): return { 'integerFormat': current_org.get_setting('integer_format'), 'floatFormat': current_org.get_setting('float_format'), }
def number_format_config(): return { "integerFormat": current_org.get_setting("integer_format"), "floatFormat": current_org.get_setting("float_format"), }
def number_format_config(): return { 'integerFormat': current_org.get_setting('integer_format'), 'floatFormat': current_org.get_setting('float_format'), }