This repository has been archived by the owner on Dec 21, 2023. It is now read-only.
forked from mastodon/mastodon
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to skip sign-in token authentication for specific users (m…
…astodon#16427) Remove "active within last two weeks" exception for sign in token requirement Change admin reset password to lock access until the password is reset
- Loading branch information
Showing
14 changed files
with
160 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
app/controllers/admin/sign_in_token_authentications_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
module Admin | ||
class SignInTokenAuthenticationsController < BaseController | ||
before_action :set_target_user | ||
|
||
def create | ||
authorize @user, :enable_sign_in_token_auth? | ||
@user.update(skip_sign_in_token: false) | ||
log_action :enable_sign_in_token_auth, @user | ||
redirect_to admin_account_path(@user.account_id) | ||
end | ||
|
||
def destroy | ||
authorize @user, :disable_sign_in_token_auth? | ||
@user.update(skip_sign_in_token: true) | ||
log_action :disable_sign_in_token_auth, @user | ||
redirect_to admin_account_path(@user.account_id) | ||
end | ||
|
||
private | ||
|
||
def set_target_user | ||
@user = User.find(params[:user_id]) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,6 +129,27 @@ | |
- else | ||
= t('admin.accounts.confirming') | ||
%td= table_link_to 'refresh', t('admin.accounts.resend_confirmation.send'), resend_admin_account_confirmation_path(@account.id), method: :post if can?(:confirm, @account.user) | ||
%tr | ||
%th{ rowspan: can?(:reset_password, @account.user) ? 2 : 1 }= t('admin.accounts.security') | ||
%td{ rowspan: can?(:reset_password, @account.user) ? 2 : 1 } | ||
- if @account.user&.two_factor_enabled? | ||
= t 'admin.accounts.security_measures.password_and_2fa' | ||
- elsif @account.user&.skip_sign_in_token? | ||
= t 'admin.accounts.security_measures.only_password' | ||
- else | ||
= t 'admin.accounts.security_measures.password_and_sign_in_token' | ||
%td | ||
- if @account.user&.two_factor_enabled? | ||
= table_link_to 'unlock', t('admin.accounts.disable_two_factor_authentication'), admin_user_two_factor_authentication_path(@account.user.id), method: :delete if can?(:disable_2fa, @account.user) | ||
- elsif @account.user&.skip_sign_in_token? | ||
= table_link_to 'lock', t('admin.accounts.enable_sign_in_token_auth'), admin_user_sign_in_token_authentication_path(@account.user.id), method: :post if can?(:enable_sign_in_token_auth, @account.user) | ||
- else | ||
= table_link_to 'unlock', t('admin.accounts.disable_sign_in_token_auth'), admin_user_sign_in_token_authentication_path(@account.user.id), method: :delete if can?(:disable_sign_in_token_auth, @account.user) | ||
|
||
- if can?(:reset_password, @account.user) | ||
%tr | ||
%td | ||
= table_link_to 'key', t('admin.accounts.reset_password'), admin_account_reset_path(@account.id), method: :create, data: { confirm: t('admin.accounts.are_you_sure') } | ||
|
||
%tr | ||
%th= t('simple_form.labels.defaults.locale') | ||
|
@@ -221,9 +242,6 @@ | |
|
||
%div | ||
- if @account.local? | ||
= link_to t('admin.accounts.reset_password'), admin_account_reset_path(@account.id), method: :create, class: 'button' if can?(:reset_password, @account.user) | ||
- if @account.user&.otp_required_for_login? | ||
= link_to t('admin.accounts.disable_two_factor_authentication'), admin_user_two_factor_authentication_path(@account.user.id), method: :delete, class: 'button' if can?(:disable_2fa, @account.user) | ||
- if [email protected]? && @account.user_approved? | ||
= link_to t('admin.accounts.memorialize'), memorialize_admin_account_path(@account.id), method: :post, data: { confirm: t('admin.accounts.are_you_sure') }, class: 'button button--destructive' if can?(:memorialize, @account) | ||
- else | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddSkipSignInTokenToUsers < ActiveRecord::Migration[6.1] | ||
def change | ||
add_column :users, :skip_sign_in_token, :boolean | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.