Skip to content
Snippets Groups Projects
Verified Commit 56cb9090 authored by Andrej Shadura's avatar Andrej Shadura
Browse files

Add SSO callback to allow existing users log in with an external source

parent 27358dc4
Branches
No related tags found
1 merge request!21OBS SSO implementation
......@@ -6,7 +6,7 @@ class Webui::UserController < Webui::WebuiController
before_filter :require_login, :only => [:edit, :save, :notifications, :update_notifications, :index]
before_filter :require_admin, :only => [:edit, :delete, :lock, :confirm, :admin, :index]
skip_before_action :check_anonymous, only: [:do_login, :login, :register_user, :register, :sso]
skip_before_action :check_anonymous, only: [:do_login, :login, :register_user, :register, :sso, :sso_callback]
def index
@users = User.all_without_nobody
......@@ -275,6 +275,22 @@ class Webui::UserController < Webui::WebuiController
end
end
def sso_callback
@auth_hash = request.env['omniauth.auth']
user = User.find_with_omniauth(@auth_hash)
unless user
redirect_to(user_login_path, error: 'Authentication failed')
return
end
Rails.logger.debug "Authentificated user '#{user.try(:login)}'"
session[:login] = user.login
User.current = user
redirect_to root_path
end
protected
def list_users(prefix = nil, hash = nil)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment