首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何通过saml-omniauth和devise从SAML中使用RelayState指定SP的登录页面?

如何通过saml-omniauth和devise从SAML中使用RelayState指定SP的登录页面?
EN

Stack Overflow用户
提问于 2020-03-02 08:07:11
回答 1查看 249关注 0票数 0

如何使用SAML协议中的RelayState在IdP发起的单点登录中指定SP的登录页?

我已经在IdP和SP之间设置了IdP发起的单点登录进程。它起作用了,但它落在了root_path。我需要这个落地在RelayState网址。

我正在使用devise。在我的控制器下面找到:

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

发布于 2020-03-03 04:23:46

答案是只替换sign_in_and_redirect method by sign_in method。然后通过执行redirect_to params[:RelayState]将用户重定向到RelayState URL。最终的saml方法是:

代码语言:javascript
复制
  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

我希望它能帮助一些人!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60480980

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档