Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
久々にコードを書いてOmniauthでハマった話
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Hiroaki Ninomiya
March 24, 2021
Programming
1.1k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
久々にコードを書いてOmniauthでハマった話
Fukuoka.rb 200回 LT大会 (#202)
https://fukuokarb.connpass.com/event/206956/
Hiroaki Ninomiya
March 24, 2021
More Decks by Hiroaki Ninomiya
See All by Hiroaki Ninomiya
スタートアップとは何か?アジャイル文脈で何が大変なのか? #shibuyagile
treby
0
250
渋谷アジャイルコミュニティへの想い #shibuyagile
treby
0
1.6k
IM@Study活動紹介
treby
1
640
全ての雑用を、生まれる前に消し去りたい
treby
0
630
Webエンジニアからデータエンジニアへ転向している話 #pronama
treby
0
430
Rails 6.0の気になった新機能 #shuuumai
treby
1
790
Shinjuku.rbの移り変わりについて、あるいは大規模カンファレンスの知見を募集したい話 #tqrk13
treby
1
190
EMの悩みにフォーカスする #em_izakaya
treby
0
630
この先生きのこるためのエンジニアキャリア戦略パターン #em_meetup
treby
5
2.7k
Other Decks in Programming
See All in Programming
手動確認はもう限界 〜XCUITestでCustom URL Schemeの遷移を起動種別ごとに自動テストする〜 / Testing Custom URL Schemes with XCUITest
otouto
0
380
ソニーのクラウド共通基盤の変遷とAI時代の開発スタイルに合わせた進化 / The Journey of Sony’s Common Cloud Platform and Its Evolution for AI-Native Development
kenjiyoneyama
0
220
AI時代のコードレビューは人に向けるな、仕組みに向けろ
texmeijin
5
3.3k
UPDATE をやめる — EF Core でマスタをバージョン管理する
panda728
PRO
0
1.1k
[2026-09-26]空論ジェネリックプロセス~テスト資産とAIで紡ぐ、再現可能なパフォーマンスチューニングの話~
tosite
0
250
Security issues being discussed on Web Platforms
petamoriken
0
1.4k
大喜利で理解するLLM as a Judge / Understanding LLM-as-a-Judge through Ogiri
rockname
0
190
難しいけど、読めた。- OSSの入口に立った話。
sts11142
0
130
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Rails World 2026, Austin, Texas
marcoroth
0
150
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
530
速習iPhone Duo対応
yuukiw00w
2
940
APNsからLive Activityを開始する話
yumnumm
0
150
Featured
See All Featured
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
910
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
270
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
58k
We Are The Robots
honzajavorek
0
380
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
The Spectacular Lies of Maps
axbom
PRO
1
1.1k
Tell your own story through comics
letsgokoyo
1
1.1k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.6k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
550
Transcript
OmniauthͰϋϚͬͨ 2021/03/24 Fukuoka.rb 200ճLTେձ @treby006
About Me • treby (ͱΕͼʔ) • @treby006 • Shinjuku.rbͷੈ
About Me • ࣮(?)Ԭग़ • Ԭࢢ౦۠/۠ɺେໂాࢢʹ༝ԑ͕͋Γ·͢
About Me • ಠཱܥϕϯνϟʔΩϟϐλϧۈ • ελʔτΞοϓ͖͕ߴͯ͡ग़ࢿଆʹ • ҎલBtoCBtoBͷελʔτΞοϓͰRailsΤϯδχΞ • Rubyք۾ͩͱʮjoker͞Μ͕͍Δͱ͜ʯͰ௨͡Δ͔Βָ
• ITΛऔΓѻ͏͚ͲɺۀͰίʔυॻ͔ͳ͍
About Me • ಠཱܥϕϯνϟʔΩϟϐλϧۈ • ελʔτΞοϓ͖͕ߴͯ͡ग़ࢿଆʹ • ҎલBtoCBtoBͷελʔτΞοϓͰRailsΤϯδχΞ • Rubyք۾ͩͱʮjoker͞Μ͕͍Δͱ͜ʯͰ௨͡Δ͔Βָ
• ITΛऔΓѻ͏͚ͲɺۀͰίʔυॻ͔ͳ͍ => ͚Ͳॻ͖͍ͨ
ίʔυΛॻ͔ͳ͘ͳͬͯ͠·ͬͨਓ͋Δ͋ΔͷΈ • ࠷৽ͷٕज़ΛΩϟονΞοϓͰ͖ͳ͘ͳΔͷͰͳ͍͔ • ٕज़ྗ͕མͪͯ͠·͏ͷͰͳ͍͔ • ࣍ʹస৬ͨ͠ͱ͖ʹ։ൃऀͱͯ͠৯͍ͬͺ͙ΕΔͷͰͳ͍͔ • ͍͔ͭ͠ΩϟϦΞ͕த్ʹͳͬͯ͠·͏ͷͰͳ͍͔ •
ݱײ͕ͳ͘ͳͬͯ͠·͏ͷͰͳ͍͔
ίʔυΛॻ͔ͳ͘ͳͬͯ͠·ͬͨਓ͋Δ͋ΔͷΈ • ࠷৽ͷٕज़ΛΩϟονΞοϓͰ͖ͳ͘ͳΔͷͰͳ͍͔ • ٕज़ྗ͕མͪͯ͠·͏ͷͰͳ͍͔ • ࣍ʹస৬ͨ͠ͱ͖ʹ։ൃऀͱͯ͠৯͍ͬͺ͙ΕΔͷͰͳ͍͔ • ͍͔ͭ͠ΩϟϦΞ͕த్ʹͳͬͯ͠·͏ͷͰͳ͍͔ •
ݱײ͕ͳ͘ͳͬͯ͠·͏ͷͰͳ͍͔
ݱײ͕ͳ͘ͳΔͱԿ͕ྑ͘ͳ͍ͷ͔ • ۀ্ͷೳྗ͕Լ: ࢿݕ౼ͷࡍͷ։ൃྗݟཱͯ(σϡʔσϦδΣϯε) • ར͖͕Ͱ͖ͳ͘ͳ͍ͬͯ͘ͷͰʁ • ઐՈͱͯ͠ίϝϯτ͢Δ༰্͕Γͯ͠͠·͏ͷͰʁ • ͋Δࣄྫʹ৮Εͨ࣌ʹʮࣗͷݴ༿ʯͰͤͳ͍Ͳ͔͠͞
• ͰɺͲ͏͢Δʁ
ͦ͏ͩɺ։ൃ͠Α͏
αΠυϓϩδΣΫτɺ͡Ί·ͨ͠ • ਓͱझຯϓϩμΫτ࡞Γ / ։ൃΛঠ͢ΔཱͪҐஔ • LINEͷϛχΞϓϦ(ࠓεςϧε) / ۙʑ͓൸࿐Ͱ͖Δͱྑ͍ͳ •
جຊతʹθϩ͔Βͷ্ཱͪ͛(1݄ʙ) • ։ൃج൫࡞ΓνʔϜϏϧσΟϯάͰָ͖͍ͯ͠
γεςϜߏਤ
ٕज़ελοΫ • ϑϩϯτ(LIFFΞϓϦ): Vue CLI (webpackerෆ༻) • Next.js on Vercel
• αʔό: Rails 6.1.3 (Ruby 3.0) on Heroku • omniauth • administrate • ridgepole • crono_trigger
ٕज़ελοΫ • ϑϩϯτ(LIFFΞϓϦ): Vue CLI (webpackerෆ༻) • Next.js on Vercel
• αʔό: Rails 6.1.3 (Ruby 3.0) on Heroku • omniauth • administrate • ridgepole • crono_trigger
omniauth • ϚϧνϓϩόΠμͷೝূΛఏڙ͢Δgem • ʮSNSϩάΠϯʯΛ࣮͢Δͷʹྑ͘ΘΕΔΠϝʔδ • ࣮ʹར༻͍ͨ͠ϓϩόΠμ͚ͷϓϥάΠϯ͕ඞཁ • omniauth-twitteromniauth-githubͳͲ •
ཧը໘ͷ؆қϩάΠϯػೳͷͨΊʹ࠾༻ • LINEͷϛχΞϓϦͳͷͰLINEͱੑ͕ߴ͍ • omniauth-line ͱҰॹʹಋೖͯ͠LINEϩάΠϯ࣮ͩʂ
ಋೖ؆୯ • omniauth gemͱ͍͍ͨϓϩόΠμͷgemΛbundleͯ͠ Gemfile gem 'omniauth' gem 'omniauth-line'
ίʔϧόοΫΛड͚͚ΔΑ͏ʹͯ͠ • SessionsController ͱϧʔςΟϯάͷ४උ config/routes.rb get '/auth/:provider/callback', to: 'sessions#callback' post
'/auth/:provider/callback', to: 'sessions#callback' get '/logout', to: 'sessions#destroy', as: :logout
ϩάΠϯඞཁͳActionʹϦμΠϨΫτΛઃఆ AdminController before_action :authenticate_admin def authenticate_admin if current_admin_challenger.nil? redirect_to '/admin/auth/line'
end end
Callback URLͷϗϫΠτϦετొ(LINE)
Α࣮͠ߦͩ
͏·͍͔͘ͳ͍orz
ఆ֎ͷΤϥʔͩͬͨͷͰ • ϧʔςΟϯά͕ؒҧ͍ͬͯΔͷͰͳ͍͔ • typoͳ͍͔ • omniauth-line ͕ϝϯς͞Ε͍ͯͳ͍ͷͰ • omniauth
ͷgem·ͰΈʹ͍ͬͨ
ḷΓண͍ͨͷ • omniauthͷ༷มߋ • 2019ࠒͷมߋͰͨ͠ɻࣗͷແ͞Α…… • എܠ: ੬ऑੑCVE-2015-9284 ରԠΒ͍͠ •
CSRF͞ΕΔϦεΫ͕͋ΔΑ • GETͰ͍͚Δ͔Βҙਤ͠ͳ͍ϩάΠϯͤ͞ΒΕΔΑͶ(ͱ͍͏ཧղ) • ੬ऑੑ͔ͩΒରԠͨ͠ํ͕ྑ͍ • ͪΐͬͱͤྑ͍ͷͰͳ͘ɺຯʹରԠ͕໘
ྑ͘ͳ͍͚ͲɺΦϓγϣϯΛແޮԽͯ͠ରԠ • ੬ऑੑΔΘ͚Ͱ͕͢ɺҰ୴ྑ͍͔ͳɺͱ͍͏அ • ͜ΕͰಈ͖·ͨ͠ config/initializers/omniauth.rb Rails.application.config.middleware.use OmniAuth::Builder do configure
do |config| config.allowed_request_methods = %i[get post] config.silence_get_warning = true end : end
ͪΌΜͱରԠ͢ΔͳΒ • gemͬΆ͍ͷଘࡏ͍ͯ͠Δ: ೖΕΕྑ͍ͱ͍͏Θ͚Ͱͳ͍? • https://github.com/cookpad/omniauth-railscsrfprotection • ҰճϩάΠϯϘλϯ͕͋Δϖʔδʹඈ͢ײ͡ • ϦμΠϨΫτͰPOSTͤ͞Δͷͬͯ͘͠ͳ͍ʁ
• ৄ͘͠ͳ͍ͷͰڭ͍͑ͯͩ͘͞><
·ͱΊ • αΠυϓϩδΣΫτ͍͍ͧ • ݱײɺഓ͍ͬͯͧ͘ʂ • gemͷߋ৽ʹશવ͍͍͚ͭͯͯͳͯ͘ϫϩλ • खΛಈ͔ͯٔ͠ΕΔ͜ͱେࣄ
એ • ϙουΩϟετΛ͍ͬͯΔͷͰྑ͔ͬͨΒௌ͍ͯͶ • ͯ͘͠Ε͍͍ͯͷΑ
Happy Hacking!!