Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add callback_url def #1

Merged
merged 1 commit into from
Jun 6, 2018
Merged

Add callback_url def #1

merged 1 commit into from
Jun 6, 2018

Conversation

takose
Copy link
Contributor

@takose takose commented Jun 6, 2018

Why

https://github.com/wantedly/corporate-site-rails/pull/524
callback_url methodはwantedly strategyに実装してなかったけど本当は必要だった,oauth2 のstrategyに実装されていたので動いていたが, omniauth/omniauth-oauth2#28 で消され,corporate siteでエラーになってしまっていた

What

callback_url methodを追加

@@ -27,6 +27,10 @@ class Wantedly < OmniAuth::Strategies::OAuth2
def raw_info
@raw_info ||= access_token.get('/api/auth').parsed
end

def callback_url
full_host + script_name + callback_path
Copy link
Contributor Author

@takose takose Jun 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@takose takose requested a review from luvtechno June 6, 2018 07:35
@takose takose self-assigned this Jun 6, 2018
@luvtechno
Copy link
Contributor

該当の変更がはいった omniauth-oauth2 の PR: omniauth/omniauth-oauth2#70

なおしたかった問題はこれ omniauth/omniauth-oauth2#28

omniauth gem の master には OmniAuth::Strategy#callback_url が存在する。

https://github.com/omniauth/omniauth/blob/8179ba796aae82f857f63b50ae848a3fbe369b4d/lib/omniauth/strategy.rb#L438-L440

これをみると、自分たちのStrategyでoverrideせずに、OmniAuth::Strategy で定義されているやつをそのまま使ったほうがよいような気がしたのですが、 OmniAuth::Strategy#callback_url が使われないのはなんでなんでしょう? omniauth gem が古いのかな?

@takose
Copy link
Contributor Author

takose commented Jun 6, 2018

ほんとだ..
omniauth-wantedlyの依存してるv1.0でも存在するのでおかしいですね
https://github.com/omniauth/omniauth/blob/v1.0.0/lib/omniauth/strategy.rb#L378
もう少しみてみます

@takose
Copy link
Contributor Author

takose commented Jun 6, 2018

omniauth/omniauth-oauth2#100callback_urlがまた実装されてますが,1年半くらいmergeされてないです.
このPRの解決策が正しいわけではないけど,omniauth-oauth2で今後のアップデートがあまり期待できないため,これでmergeしてしまったらよいかなと思いました

@luvtechno luvtechno merged commit 435e27d into master Jun 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants