如何使用SAML协议中的RelayState在IdP发起的单点登录中指定SP的登录页?
我已经在IdP和SP之间设置了IdP发起的单点登录进程。它起作用了,但它落在了root_path。我需要这个落地在RelayState网址。
我正在使用devise。在我的控制器下面找到:
def saml
student = Student.where(email: request.env["omniauth.auth"]['uid'].to_s).first
if student
sign_in_and_redirect student, event: :authentication
else
flash[:error] = t 'flash_msg.access_1'
redirect_to root_path
end
end发布于 2020-03-03 04:23:46
答案是只替换sign_in_and_redirect method by sign_in method。然后通过执行redirect_to params[:RelayState]将用户重定向到RelayState URL。最终的saml方法是:
def saml
student = Student.where(email: request.env["omniauth.auth"]['uid'].to_s).first
if student
sign_in student, event: :authentication
redirect_to params[:RelayState]
else
flash[:error] = t 'flash_msg.access_1'
redirect_to root_path
end
end我希望它能帮助一些人!
https://stackoverflow.com/questions/60480980
复制相似问题