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
社内でしか使わない勤怠管理システムにOAuth2を導入してみた / Kagomoku #19
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
megos
April 20, 2019
Technology
2.2k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
社内でしか使わない勤怠管理システムにOAuth2を導入してみた / Kagomoku #19
megos
April 20, 2019
More Decks by megos
See All by megos
個人開発を続けるということ / Continuing Personal Development
megos
0
290
わたしの開発環境の歴史 / My environment history
megos
0
350
CUIが嫌ならGUIからGitを使えばいいじゃない / kagomoku #17
megos
0
420
Join! かごえん / Join Kagoeng
megos
0
95
GitLab Features
megos
1
360
GitLab Hacks
megos
1
400
Gitlab meets minutes
megos
2
310
2018年まとめ / Summary of 2018
megos
0
320
Dockerで作るLaTeX執筆環境 / Writing LaTeX with Docker
megos
0
1.8k
Other Decks in Technology
See All in Technology
MulticaとPi Coding Agentで、小規模OSSを30本同時運用した流れ
eiei114
0
130
도구에서 동료까지: 10년차 AI 스타트업의 AI 적응기
inureyes
PRO
0
210
35分でわかるEffective Platform Engineering
nwiizo
5
400
同じWAFが、攻撃の“形”は弾く── 正当な“形”の不正は通す
kuroneko13
0
240
Model Studio CLI × Token Plan
maigo999
0
190
AIのためのEthernet技術動向 (SerDes)
markunet
1
220
老害フォレンジッカーはAI羊の夢を見るか?
tadmaddad
0
350
名刺メーカーDevグループ 紹介資料
sansan33
PRO
0
1.2k
自宅NWにISR4331を導入してみた話
okaits
0
110
Head First モブプログラミング / Head First Mobprogramming
takaking22
10
12k
Eight Engineering Unit 紹介資料
sansan33
PRO
3
8.2k
【AG-UI × A2UI × MCP Apps】Generative UIをやさしく解説する
nrinetcom
PRO
1
140
Featured
See All Featured
Site-Speed That Sticks
csswizardry
13
1.4k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
700
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
390
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
250
The #1 spot is gone: here's how to win anyway
tamaranovitovic
3
1.1k
Marketing to machines
jonoalderson
1
5.7k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
390
Why Our Code Smells
bkeepers
PRO
340
58k
What does AI have to do with Human Rights?
axbom
PRO
1
2.3k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
210
Transcript
ࣾͰ͔͠Θͳ͍ ۈଵཧγεςϜʹ OAuth2Λಋೖͯ͠Έͨ megos @ ͔͘͝ #19 γϯάϧαΠϯΦϯ! 2019/04/20
megos Full stuck engineer (not stack) • ͔͑͝ΜཱͯͨͻͱʢJoin Us!!ʣ •
Twitterɿ@tmegos • ϙʔτϑΥϦΦɿmegos.netlify.com
എܠͱత • ExcelͰۈଵཧ͞Ε͍ͯͨ • ໘ʢݸਓʣ • ϓϩδΣΫτͷ࡞ۀ͕࣌ؒΘ͔Γʹ͍͘ʢPMʣ • ࣾһʹͱͬͯศརͳWebۈଵγεςϜΛ࡞Δ •
WebԽ → ೝূ → OAuth2 എܠ త
ͳͥOAuth2? • ଞαʔϏεͱͷ࿈ܞͱ͍͏ߏ • άϧʔϓΣΞɺཧɺ༗څٳՋཧ… • ษڧͷͨΊ • OAuth2ΫϥΠΞϯτΑ͘࡞Δ͚Ͳ… OAuth2αʔόࣗͰ࡞Δ͜ͱͳ͍ΑͶ
ͬͨͷ • όοΫΤϯυ • Spring Boot • Spring Security •
Kotlin • DB • PostgreSQL • ϑϩϯτΤϯυ • Vue.js • Vuetify • axios
ͬͨͷ • όοΫΤϯυ • Spring Boot • Spring Security •
Kotlin • DB • PostgreSQL • ϑϩϯτΤϯυ • Vue.js • Vuetify • axios ࠓճ͜͜ͷ OAuth2ͷ෦͚ͩ հ
https://github.com/megos/ spring-security-oauth2- kotlin આ໌ιʔεͷίϝϯτͰ
# ਖ਼͍͠ΞΫηεใ $ curl -X POST \ -d client_id=client_id \
-d client_secret=client_secret \ -d grant_type=password \ -d username=user \ -d password=password \ http://localhost:8080/oauth/token {"access_token":"[your_access_token]","token_type":"bearer","expires _in":43199,"scope":"read"} curlͰOAuthΛୟ͘
# ΫϥΠΞϯτใͷޡΓ $ curl -X POST \ -d client_id=client_id \
-d client_secret=client_secret2 \ -d grant_type=password \ -d username=user \ -d password=password \ http://localhost:8080/oauth/token {"error":"invalid_client","error_description":"Bad client credentials"} curlͰOAuthΛୟ͘
# ϢʔβใͷޡΓ $ curl -X POST \ -d client_id=client_id \
-d client_secret=client_secret \ -d grant_type=password \ -d username=user \ -d password=password2 \ http://localhost:8080/oauth/token {"error":"invalid_grant","error_description":"Bad credentials"} curlͰOAuthΛୟ͘
# ਖ਼͍͠ΞΫηετʔΫϯ $ curl -H "Authorization: Bearer [your_access_token]" localhost: 8080/hello
Hello! # ΞΫηετʔΫϯͳ͠ $ curl http://localhost:8080 {"error":"unauthorized","error_description":"Full authentication is required to access this resource"} # ແޮͳΞΫηετʔΫϯ $ curl -H "Authorization: Bearer bad_access_token" localhost:8080/ hello {"error":"invalid_token","error_description":"Invalid access token: bad_access_token"} ϦιʔεΛऔಘͯ͠ΈΔ
·ͱΊͱࠓޙͷ՝ • Spring SecurityͰOAuth2αʔόΛ࡞ͬͨ • roleͷదͳઃఆ • read/write • user/subreader/reader/admin…
• scopeͷదͳઃఆ ·ͱΊ ࠓޙͷ՝