-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #895 from alphagov/sso-feature
Login to moderation portal using SAML SSO
- Loading branch information
Showing
95 changed files
with
989 additions
and
1,972 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
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 |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
float: right; | ||
} | ||
li { | ||
color: $white; | ||
display: inline; | ||
margin-left: $gutter-one-third; | ||
a { | ||
|
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 |
---|---|---|
@@ -1,67 +1,7 @@ | ||
class Admin::AdminUsersController < Admin::AdminController | ||
before_action :require_sysadmin | ||
before_action :find_user, only: %i[edit update destroy] | ||
|
||
rescue_from AdminUser::CannotDeleteCurrentUser do | ||
redirect_to admin_admin_users_url, alert: :user_is_current_user | ||
end | ||
|
||
rescue_from AdminUser::MustBeAtLeastOneAdminUser do | ||
redirect_to admin_admin_users_url, alert: :user_count_is_too_low | ||
end | ||
|
||
rescue_from ActiveRecord::DeleteRestrictionError do | ||
redirect_to admin_admin_users_url, alert: :user_has_moderated_petitions | ||
end | ||
|
||
def index | ||
@users = AdminUser.by_name.paginate(page: params[:page], per_page: 50) | ||
end | ||
|
||
def new | ||
@user = AdminUser.new | ||
end | ||
|
||
def create | ||
@user = AdminUser.new(admin_user_params) | ||
|
||
if @user.save | ||
redirect_to admin_admin_users_url, notice: :user_created | ||
else | ||
render :new | ||
end | ||
end | ||
|
||
def edit | ||
end | ||
|
||
def update | ||
if @user.update(admin_user_params) | ||
redirect_to admin_admin_users_url, notice: :user_updated | ||
else | ||
render :edit | ||
end | ||
end | ||
|
||
def destroy | ||
if @user.destroy(current_user: current_user) | ||
redirect_to admin_admin_users_url, notice: :user_deleted | ||
else | ||
redirect_to admin_admin_users_url, alert: :user_not_deleted | ||
end | ||
end | ||
|
||
protected | ||
|
||
def find_user | ||
@user = AdminUser.find(params[:id]) | ||
end | ||
|
||
def admin_user_params | ||
params. | ||
require(:admin_user). | ||
permit(:password, :password_confirmation, :first_name, | ||
:last_name, :role, :email, :force_password_reset, | ||
:account_disabled) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
class Admin::OmniauthCallbacksController < Devise::OmniauthCallbacksController | ||
skip_before_action :require_admin | ||
skip_before_action :verify_authenticity_token, only: %i[saml] | ||
|
||
rescue_from ActiveRecord::RecordNotFound do | ||
redirect_to admin_login_url, alert: :login_failed | ||
end | ||
|
||
def saml | ||
@user = AdminUser.find_or_create_from!(provider, auth_data) | ||
|
||
if @user.present? | ||
sign_in @user, event: :authentication | ||
|
||
set_flash_message(:notice, :signed_in) | ||
set_refresh_header | ||
|
||
render "admin/admin/index" | ||
else | ||
redirect_to admin_login_url, alert: :invalid_login | ||
end | ||
end | ||
|
||
def failure | ||
redirect_to admin_login_url, alert: :login_failed | ||
end | ||
|
||
private | ||
|
||
def after_omniauth_failure_path_for(scope) | ||
admin_login_url | ||
end | ||
|
||
def auth_data | ||
request.env["omniauth.auth"] | ||
end | ||
|
||
def provider | ||
IdentityProvider.find_by!(name: auth_data.provider) | ||
end | ||
|
||
def set_refresh_header | ||
headers['Refresh'] = "0; url=#{admin_root_url}" | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.