如何在Elixir中为Uberauth添加状态参数

问题描述 投票:0回答:1

在oAuth过程中,最好设置状态参数来授权url以确保安全性。当我检查ÜberauthShopifyhttps://github.com/kodehort/ueberauth_shopify/blob/master/lib/ueberauth/strategy/shopify.ex#L88时,它被发送到shopify。

但是我不明白我需要在我的Phoenix应用程序中设置这个状态参数,Shopify会得到它。有什么建议?

elixir phoenix-framework omniauth ueberauth
1个回答
0
投票

你在传递给Ueberauth的URL中提供state(同样地,scopes也被传递)

根据您的路由器设置,默认为:

pipeline :auth do
  Ueberauth.plug "/auth"
end

scope "/auth" do
  pipe_through [:browser, :auth]

  get "/:provider/callback", AuthController, :callback
end

您通过将用户重定向到指定的身份验证URL来提供scopesstate

/auth/shopify?scopes=read_orders%20read_products&state=yourSuperSecretState

或没有任何范围:

/auth/shopify?state=yourSuperSecretState

© www.soinside.com 2019 - 2024. All rights reserved.