Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Laravel + Auth0で複数のSNS認証を簡単に実現.pdf
Search
Takayuki
August 07, 2019
Programming
1
360
Laravel + Auth0で複数のSNS認証を簡単に実現.pdf
Laravel + Auth0で複数のSNS認証を簡単に実現
Takayuki
August 07, 2019
Tweet
Share
More Decks by Takayuki
See All by Takayuki
エンジニアのキャリア論
bumptakayuki
0
120
地方カンファレンス主催のススメ
bumptakayuki
1
160
Laravelで敢えて試す脆弱性のある書き方
bumptakayuki
1
790
地方でのPHPエンジニア採用って実際どうなの?
bumptakayuki
0
530
沖縄観光、名物を一挙紹介!
bumptakayuki
2
540
Laravel ShiftでLaravelのバージョンアップしてみた話
bumptakayuki
1
1.8k
flutterでイベントアプリを作ってみた
bumptakayuki
0
110
オフショア開発の辛みと学んだ事
bumptakayuki
0
340
ChatGPTにStripeのサンプルコードを書かせてみた
bumptakayuki
1
170
Other Decks in Programming
See All in Programming
CSC509 Lecture 11
javiergs
PRO
0
180
as(型アサーション)を書く前にできること
marokanatani
10
2.8k
Amazon Qを使ってIaCを触ろう!
maruto
0
420
色々なIaCツールを実際に触って比較してみる
iriikeita
0
340
距離関数を極める! / SESSIONS 2024
gam0022
0
300
Less waste, more joy, and a lot more green: How Quarkus makes Java better
hollycummins
0
100
Hotwire or React? ~アフタートーク・本編に含めなかった話~ / Hotwire or React? after talk
harunatsujita
1
120
Better Code Design in PHP
afilina
PRO
0
130
Djangoの開発環境で工夫したこと - pre-commit / DevContainer
hiroki_yod
1
150
リアーキテクチャxDDD 1年間の取り組みと進化
hsawaji
1
220
Modular Monolith Monorepo ~シンプルさを保ちながらmonorepoのメリットを最大化する~
yuisakamoto
6
440
React CompilerとFine Grained Reactivityと宣言的UIのこれから / The next chapter of declarative UI
ssssota
1
120
Featured
See All Featured
KATA
mclloyd
29
14k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
93
16k
Automating Front-end Workflow
addyosmani
1366
200k
Building an army of robots
kneath
302
43k
Practical Orchestrator
shlominoach
186
10k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.8k
Adopting Sorbet at Scale
ufuk
73
9.1k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Thoughts on Productivity
jonyablonski
67
4.3k
Building Applications with DynamoDB
mza
90
6.1k
A designer walks into a library…
pauljervisheath
204
24k
Transcript
Laravel + Auth0Ͱෳͷ SNSೝূΛ؆୯ʹ࣮ݱ Laravel + Auth0Ͱෳͷ SNSೝূΛ؆୯ʹ࣮ݱ
3 LaravelͰͷ࣮ํ๏ Agenda 2 Auth0ͱ 1 ࣗݾհ 4 Demo
1 ࣗݾհ
4 ࣗݾհ ◆໊લ ླ ೭(Suzuki Takayuki) ◆ࣗݾհ ɾ1990ɺਆಸݝੜ·Εɻ ɾࣾձਓʹͳ͔ͬͯΒɺϓϩάϥϛϯάΛ࢝ΊΔɻ ɾ2015ʹϑϧεϐʔυʹೖࣾ͠ɺ2017ʹϑϦʔϥ
ϯεΛͬͨޙʹ201711݄ʹԭೄͰىۀɻ ◆झຯ ίεϓϨɺԻָϥΠϒɺϚϥιϯେձʹग़Δɺٿ؍ ઓ ◆Twitter @kanbo0605
5 ࣗݾհ 7/13ʹLaravel ΧϯϑΝϨϯε Ͱొஃ͖ͯ͠·ͨ͠ʂ ৄͪ͘͜͠Β https://dev.re-build.company/ entry/2019/07/23/193108
Copyright Re:Build.inc All Rights Reserved. 1.ձࣾհ ◆ձ໊ࣾ גࣜձࣾRe:Build ◆ॅॴ ԭೄݝԭೄࢢதԝ̍ஸ̍̒−̕
◆ࣄۀ༰ ɾࣗࣾWEBαʔϏεͷاըɾ։ൃɻ ɾडୗ։ൃ ◆ࣾһ 6໊ ◆ΤϯδχΞͷಇ͖ํ ϦϞʔτϫʔΫՄೳͳࣗ༝ͳಇ͖ํΛਪͯ͠·͢ʂ
2 Auth0ͱ
8 ͜ͷࢿྉʹ͍ͭͯ https://speakerdeck.com/bumptakayuki/laravel-plus-auth0-plus-stripe-deecsaitowozuo-tutemita Ҏલɺൃදͨ͠༰ʹ ͚Ճ͑ͨͷͰ͢ʂ
9 ରऀ ɾAuth0ͷಋೖΛݕ౼͍ͯ͠Δํ ɾೝূج൫ͷ࣮ʹΜͰ͍Δํ ɾLaravelͰAuth0Λ࣮ͯ͠Έ͍ͨํ
1 0 Auth0ͱ ɾ֓ཁ Auth0WebΞϓϦϞόΠϧɺAPIͳͲ ʹରͯ͠ೝূɾೝՄͷαʔϏεΛΫϥυ Ͱఏڙ͍ͯ͠Δɺ͍ΘΏΔIDaaS (Identity as a
Service)ϕϯμʔͰ͢ɻ ɾΦεεϝͷํ اۀ͕ͭWebΞϓϦέʔγϣϯAPI, Native Mobile AppͳͲͰϢʔβʔೝূ ೝՄɺηΩϡϦςΟΛΈࠐΈ͍͚ͨΕ Ͳ࣮͕͍͠ɻ https://qiita.com/furuth/items/8826b66a3ec2b2b14222
11 ֤ݴޠ͝ͱͰνϡʔ τϦΞϧ͕ॆ࣮ͯ͠ ͓Γɺ؆୯ʹಋೖͰ ͖·͢ɻ ओཁͳSNSͱ΄ͱΜͲ࿈ ܞ͓ͯ͠Γɺ࿈ܞํ๏ ؆୯ͰศརͰ͢ɻ μογϡϘʔυͰͲͷSNS͔ ΒϩάΠϯ͕͋Δ͔֬ೝͰ͖
Δ ؆୯ʹಋೖͰ͖Δ ϢʔβೝূΛҰݩཧͰ ͖Δ ϝϦοτɾಛ ๛ͳ࿈ܞઌ 2 ʙϝϦοτʙ 1 3
1 2 ๛ͳ࿈ܞઌ Auth0ͱ
1 3 ϢʔβΛҰݩཧ Auth0ͱ
1 4 ෳͷσόΠεʹରԠ Auth0ͱ
1 5 ྉۚମܥ https://auth0.com/pricing
3 LaravelͰͷ࣮ํ๏
ΞϓϦέʔγϣϯ ϩάΠϯ͔Βܾࡁ·ͰͷྲྀΕ /index TOPϖʔδ ৄࡉϖʔδભҠ ࣌ʹϩάΠϯ ϩάΠϯޭͨ͠Β ηογϣϯLaravelଆ Ͱཧ ೝূ
ܾࡁ ߪೖ͔Βܾࡁը໘
1 8 ެࣜͷAuth0ͷLaravelνϡʔτϦΞϧ https://auth0.com/docs/quickstart/webapp/laravel/01-login
1 9 खॱ ᶃAuth0ͷཧը໘ͰΞϓϦέʔγϣϯͷઃఆΛߦ͏ɻ ᶄLaravelΛΠϯετʔϧ ᶅcomposer require auth0/login:”~5.0" Λ࣮ߦ ᶆLoginServiceProviderΛઃఆ
ᶇphp artisan vendor:publishΛ࣮ߦ ᶈ.envΛฤू ᶉroutes/api.phpΛฤू ᶊίϯτϩʔϥΛ࡞ ᶋconfig/auth.phpΛฤू ᶌbladeϑΝΠϧΛฤू
2 0 ᶃAuth0ͷཧը໘ͰΞϓϦέʔγϣϯͷઃఆΛߦ͏ɻ
2 1 ᶄLaravelΛΠϯετʔϧ https://readouble.com/laravel/5.5/ja/installation.html
2 2 ᶅcomposer require auth0/login:”~5.0" Λ࣮ߦ Auth0ϓϥάΠϯΛΠϯετʔϧ Πϯετʔϧ͕ྃ͢Δͱɺ2ͭͷϓϥάΠϯ͕Ճ͞ΕΔɻ vendor\auth0\auth0-php vendor\auth0\login
2 3 ᶆLoginServiceProviderΛઃఆ config/app.phpΛฤू ԼهΛՃ
2 4 ᶆLoginServiceProviderΛઃఆ AppServiceProvider .phpΛฤू ԼهΛՃ
2 5 ᶇphp artisan vendor:publishΛ࣮ߦ ྃ͢Δͱɺconfig/laravel-auth0.php͕࡞͞Εɺ σϑΥϧτͷઃఆϑΝΠϧ͕ެ։͞Ε·ͨ͠ɻ
2 6 ᶈ.envΛฤू ઌ΄Ͳ࡞ͨ͠ΞϓϦέʔγϣϯʹهࡌ͞Ε͍ͯΔυϝΠϯ,ID,ύε ϫʔυΛLaravelΞϓϦέʔγϣϯͷ.envʹՃ͠·͢ɻ
2 7 ᶉroutes/api.phpΛฤू
2 8 ᶊίϯτϩʔϥΛ࡞
2 9 ᶋconfig/auth.phpΛฤू ೝূํ๏ΛAuth0ʹมߋ
3 0 ᶌbladeϑΝΠϧΛฤू
3 1 Auth0ͷRuleͱʁ ϧʔϧɺϢʔβʔ͕ΞϓϦέʔγϣϯΛೝূ͢ Δͱ͖ʹ࣮ߦ͞ΕΔJavaScriptؔͰ͢ɻ ͜ΕΒɺೝূϓϩηε͕ྃ͢Δͱ࣮ߦ͞Εɺ Auth0ͷػೳΛΧελϚΠζ͓Αͼ֦ு͢ΔͨΊ ʹ༻Ͱ͖·͢ɻ ηΩϡϦςΟ্ͷཧ༝͔Βɺϧʔϧίʔυɺα ϯυϘοΫεͷଞͷAuth0ςφϯτͷίʔυ͔
Β࣮ͯ͠ߦ͞Ε·͢ɻ https://auth0.com/docs/rules
3 2 Auth0ͷRuleͷྫ ɾෳࡶͳϩδοΫʢJavaScriptͰهड़Ͱ͖Δͷʣʹج͍ͮͯঝೝϧʔϧΛ࡞ ɾϗϫΠτϦετΛ࡞Ͱ͖ɺిࢠϝʔϧͷ༰ʹج͍ͮͯΞΫηεΛڋ൱ ɾϩάΠϯ͕ϦΞϧλΠϜͰൃੜͨ͠߹ɺAPIΛհͯ͠ଞͷγεςϜ(Slack ͳͲ)ʹ௨ ͳͲ https://auth0.com/docs/rules
3 3 RuleͷՃ RuleΛ৽ن࡞
3 4 RuleͷՃ ෳͷύλʔϯͷRule͕ ࣄલʹ༻ҙ͞Ε͍ͯΔ
3 5 RuleͷՃ RuleͰ༻͢Δڥม ઃఆͰ͖Δ
3 6 Ruleͷྫ MFA(ೋஈ֊ೝূ)ͷઃఆ ؆୯ʹͰ͖Δʂ
3 7 Ruleͷྫ Ϣʔβʔ͕αΠϯΞοϓ͢Δ ͨͼʹεϥοΫνϟωϧʹϝο ηʔδΛૹ৴͠·͢ɻ
3 8 Ruleͷྫ ϝʔϧΞυϨεͷυϝΠϯʹ ΑΔ੍ݶ
3 9 Ruleͷྫ ϢʔβใΦϒδΣΫτ͔ Βࡉ͔͘औಘͰ͖Δ https://auth0.com/docs/rules/references/user-object
WWW.SITE2MAX.PRO Free PowerPoint & KeyNote Templates 4 DEMO EC Site
EC Site https://murmuring-tor-53965.herokuapp.com/
4 1 ࣮ࡍʹಈ͔͢
4 2 ࣮ࡍʹಈ͔͢ ࠓճGoogleɺFacebookɺ TwitterɺGithubʹରԠ
4 3 ࣮ࡍʹಈ͔͢
4 4 ࣮ࡍʹಈ͔͢ MFA(ೋஈ֊ೝূ)ͷը໘
4 5 ࣮ࡍʹಈ͔͢
4 6 ࣮ࡍʹಈ͔͢
4 7 ࣮ͯ͠Έͨײ(ओ؍) ɾ࣮͕͘͢͝؆୯ʹͰ͖ͨ(2͘Β͍ͰECαΠτ͕) ɾҰɺ࣮ͯ͠͠·͑ɺSNSͷ࿈ܞઌ૿͢ͷϘλϯΛ ϙνϙν͢Δ͚ͩͰOKʂ ɾηΩϡϦςΟͷ୲อAuth0ଆ͕୲อͯ͘͠ΕΔ ɾΞΫςΟϒϢʔβʹΑͬͯ՝ۚ͞ΕΔͷͰɺ࠷ॳίε τͰ͑ͯٸ֦େ͢ΔΑ͏ͳελʔτΞοϓاۀͩͱ͍͍ͯ Δ͔͠Εͳ͍ɻ
4 8 ࢀߟ https://qiita.com/furuth/items/8826b66a3ec2b2b14222 https://dev.classmethod.jp/cloud/auth0-overview/ https://www.hypertextcandy.com/laravel-tried-auth0
4 9 ࠂ 10/12 PHPΧϯϑΝϨϯεԭೄ։࠵͠·͢ʂ https://phpcon.okinawa.jp