Skip to content

Commit

Permalink
redash接入mobifun登陆认证
Browse files Browse the repository at this point in the history
  • Loading branch information
许凯 committed Jun 27, 2018
1 parent 4994e36 commit 479db73
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 2 deletions.
Binary file added client/app/assets/images/mobifun_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 16 additions & 1 deletion client/app/pages/settings/organization.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ <h3>Authentication</h3>
</div>
</p>

<p>
<label>
<input name="input" type="checkbox" ng-model="$ctrl.settings.auth_mobifun_enabled" ng-change="$ctrl.update('auth_mobifun_enabled')"
accesskey="tab" ng-disabled="$ctrl.disablePasswordLoginToggle()"> Mobifun Account Login Enabled
<span uib-popover="Password login can be disabled only if another login method is enabled." popover-trigger="'mouseenter'"
ng-if="$ctrl.disablePasswordLoginToggle()">
<i class="fa fa-question-circle"></i>
</span>
</label>

<div class="callout callout-warning" ng-if="!$ctrl.settings.auth_mobifun_enabled">
Mobifun account based login is currently disabled and users will be able to login only with the enabled.
</div>
</p>

<div ng-if="$ctrl.googleLoginEnabled">
<h4>Google Login</h4>
<label>
Expand Down Expand Up @@ -74,4 +89,4 @@ <h4>SAML</h4>
</p>
</div>
</div>
</settings-screen>
</settings-screen>
2 changes: 1 addition & 1 deletion client/app/pages/settings/organization.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function OrganizationSettingsCtrl($http, toastr, clientConfig, Events) {
this.googleLoginEnabled = clientConfig.googleLoginEnabled;

this.disablePasswordLoginToggle = () =>
(clientConfig.googleLoginEnabled || this.settings.auth_saml_enabled) === false;
(clientConfig.googleLoginEnabled || this.settings.auth_saml_enabled || this.settings.auth_mobifun_enabled) === false;
}

export default function init(ngModule) {
Expand Down
2 changes: 2 additions & 0 deletions redash/handlers/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def render_token_login_page(template, org_slug, token):
show_google_openid=settings.GOOGLE_OAUTH_ENABLED,
google_auth_url=google_auth_url,
show_saml_login=current_org.get_setting('auth_saml_enabled'),
show_mobifun_account=current_org.get_setting('auth_mobifun_enabled'),
show_remote_user_login=settings.REMOTE_USER_LOGIN_ENABLED,
show_ldap_login=settings.LDAP_LOGIN_ENABLED,
org_slug=org_slug,
Expand Down Expand Up @@ -132,6 +133,7 @@ def login(org_slug=None):
next=next_path,
email=request.form.get('email', ''),
show_google_openid=settings.GOOGLE_OAUTH_ENABLED,
show_mobifun_account=current_org.get_setting('auth_mobifun_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'),
Expand Down
2 changes: 2 additions & 0 deletions redash/settings/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@


PASSWORD_LOGIN_ENABLED = parse_boolean(os.environ.get("REDASH_PASSWORD_LOGIN_ENABLED", "true"))
MOBIFUN_LOGIN_ENABLED = parse_boolean(os.environ.get("MOBIFUN_ACCOUNT_LOGIN_ENABLED", "true"))

SAML_METADATA_URL = os.environ.get("REDASH_SAML_METADATA_URL", "")
SAML_ENTITY_ID = os.environ.get("REDASH_SAML_ENTITY_ID", "")
Expand All @@ -18,6 +19,7 @@
DATE_FORMAT = os.environ.get("REDASH_DATE_FORMAT", "DD/MM/YY")

settings = {
"auth_mobifun_enabled": MOBIFUN_LOGIN_ENABLED,
"auth_password_login_enabled": PASSWORD_LOGIN_ENABLED,
"auth_saml_enabled": SAML_LOGIN_ENABLED,
"auth_saml_entity_id": SAML_ENTITY_ID,
Expand Down
2 changes: 2 additions & 0 deletions redash/templates/invite.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@
</a>
{% endif %}

{% if show_mobifun_account %}
<a href="/oauth/redash" class="login-button btn btn-default btn-block">
<img src="/static/images/mobifun_logo.png">
Login with Mobifun Account
</a>
{% endif %}

{% if show_saml_login %}
<a href="{{ url_for('saml_auth.sp_initiated', org_slug=org_slug) }}" class="login-button btn btn-default btn-block">SAML Login</a>
Expand Down
2 changes: 2 additions & 0 deletions redash/templates/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
</a>
{% endif %}

{% if show_mobifun_account %}
<a href="/oauth/redash" class="login-button btn btn-default btn-block">
<img src="/static/images/mobifun_logo.png">
Login with Mobifun Account
</a>
{% endif %}

{% if show_saml_login %}
<a href="{{ url_for('saml_auth.sp_initiated', org_slug=org_slug, next=next) }}" class="login-button btn btn-default btn-block">SAML Login</a>
Expand Down

0 comments on commit 479db73

Please sign in to comment.