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
PerlでつくるフルスクラッチWebAuthn/パスキー認証 / Demonstration ...
Search
mackee
February 10, 2024
7.1k
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
PerlでつくるフルスクラッチWebAuthn/パスキー認証 / Demonstration of full-scratch WebAuthn/Passkey Authentication written in Perl
YAPC::Hiroshima 2024
mackee
February 10, 2024
More Decks by mackee
See All by mackee
Go1.27で導入されるジェネリクスメソッドでできること
mackee
0
580
perlをWebAssembly上で動かすと何が嬉しいの??? / Where does Perl-on-Wasm actually make sense?
mackee
0
1.1k
Agentに至る道 〜なぜLLMは自動でコードを書けるようになったのか〜
mackee
6
6.1k
今!ソフトウェアエンジニアがハードウェアに手を出すには
mackee
14
7.3k
ワンバイナリWebサービスのススメ
mackee
10
9k
tanukistack ライブコーディング / tanukistack live-coding
mackee
0
760
range over funcの使い道と非同期N+1リゾルバーの夢 / about a range over func
mackee
0
1.2k
perl for shell, awk and sed programmers
mackee
3
2.9k
今更GoのWebフレームワークを作ろうとしているワケ / Why am I trying to create a Go web framework now?
mackee
1
1.1k
Featured
See All Featured
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.1k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
210
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.9k
HDC tutorial
michielstock
2
790
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
119
120k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
510
New Earth Scene 8
popppiees
3
2.5k
Code Review Best Practice
trishagee
74
20k
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
160
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
930
Transcript
PerlͰͭ͘ΔϑϧεΫϥον WebAuthn/ύεΩʔೝূ YAPC::Hiroshima 2024 ݫౡ 15:00ʙ @mackee_w a.k.a macopy
͜ΜʹͪϚίϐʔͰ͢ʂ
εϐʔΧʔհ • X: @macopy • GitHub: @mackee • ໘ന๏ਓΧϠοΫ •
Tonamel αʔόʔαΠυ ΤϯδχΞ • ౡۀେֶग़
ຊͷ”օ༷”ͷඪ WebAuthnͷΈ͕Θ͔ͬͨؾʹͳΔ
ͱΓ͋͑ͣͬͯΈΔʹ օ͞Μͷ͓੮ͷޙΖʹ͋Δ`Perlbatross`ͰWebAuthn͕ΘΕ͍ͯ·͢
Θ͔ͬͨؾʹͳΔͨΊʹࢲ͕Δ͜ͱ • WebAuthnͷ࣮ࡍͷΈʹ͍ͭͯαʔόʔ࣮Λॻ͖ͳ͕Βઆ໌ • ͜ͷτʔΫϥΠϒίʔσΟϯάओମͰ͢ • ϋϓχϯά͕͋ͬͨΒԠԉ͍ͯͩ͘͠͞ • ͜ͷτʔΫͰॻ࣮͘৭ʑলུ͍ͯ͠·͢ •
(Option)ؼͬͨΒ͋ͳͨॻ͍ͯΈ·͠ΐ͏ • (ͲΜͳʹ͍͍ͯ͘ͷͰ)ϒϩάͰײ͕͋Εࢲ͔ͳΓتͼ·͢
ຊͷνϟʔτ • ࣗݾհͳͲ 15:00 ʙ 15:05 <= ΠϚίί • WebAuthnͱPasskeyͷ֓ཁ
15:05 ʙ 15:10 • Registration࣮ 15:10ʙ15:25 • Login࣮ 15:25ʙ15:35 • ·ͱΊ(όοϑΝ) 15:35ʙ15:40
ຊͷνϟʔτ • ࣗݾհͳͲ 15:00 ʙ 15:05 • WebAuthnͱPasskeyͷ֓ཁ 15:05 ʙ
15:10 • Registration࣮ 15:10ʙ15:25 • Login࣮ 15:25ʙ15:35 • ·ͱΊ(όοϑΝ) 15:35ʙ15:40
WebAuthnͱ • ύεϫʔυϨεೝূΛ࣮ݱ͢ΔͨΊͷඪ४Web API • ެ։伴҉߸Λͬͯిࢠॺ໊Ͱߦ͏ೝূํࣜ ύεϫʔυ
WebAuthnͷϑϩʔ Ϣʔβʔ ϒϥβ ೝূث ൿີ伴 αʔόʔ ެ։伴 ΩʔϖΞ
WebAuthnͷϑϩʔ Ϣʔβʔ ϒϥβ ೝূث ൿີ伴 αʔόʔ ެ։伴 ϩάΠϯ͍ͨ͠
WebAuthnͷϑϩʔ Ϣʔβʔ ϒϥβ ೝূث ൿີ伴 αʔόʔ ެ։伴 challengeʹ ॺ໊ͯ͠
WebAuthnͷϑϩʔ Ϣʔβʔ ϒϥβ ೝূث ൿີ伴 αʔόʔ ެ։伴 challengeʹ ॺ໊ͯ͠
WebAuthnͷϑϩʔ Ϣʔβʔ ϒϥβ ೝূث ൿີ伴 αʔόʔ ެ։伴 ॺ໊ͨ͠Α
WebAuthnͷϑϩʔ Ϣʔβʔ ϒϥβ ೝূث ൿີ伴 αʔόʔ ެ։伴 ॺ໊ͨ͠Α
WebAuthnͷϑϩʔ Ϣʔβʔ ϒϥβ ೝূث ൿີ伴 αʔόʔ ެ։伴 ͋ͬͯͦ͏ʂOK ݕূ
WebAuthnͷσϝϦοτ • ൿີ伴͕σόΠεʹด͍ͯ͡Δ • σόΠεΛ·͍ͨͩೝূΛͲ͏͢Δ͔ • CTAP2ͱ͍͏ൿີ伴͕ೖͬͨσόΠεͱBLEͳͲͰܨ͍Ͱೝূ͢ Δํࣜఆٛ͞Ε͍ͯΔ • ฆࣦͨ͠ΒͲ͏͢Δ͔
• => ༻్ͱͯ͠2FAͷ1͔ͭͭɺ͜Ε͚ͩͩͱ৺ڐͳ͍
Passkeyͱ • ݫີͳఆٛ: Discoverable CredentialΛ༻͍ΔWebAuthn • 伴ʹϢʔβʔ໊ͳͲΛηοτͰอଘ͢Δ • RP(αΠτ)ʹରͯ͠༻ՄೳͳIDͱެ։伴ͷϖΞΛྻڍͰ͖Δ •
ΫϥυಉظPasskey Auto fi llɺੜମೝূΛհͨ͠MFAͳͲɺ WebAuthnΛศརʹ͢ΔUXɺϢʔβʔʹWebAuthn͕͑ΔϩάΠ ϯํࣜͰ͋Δ͜ͱΛ͢͞ݴ༿ͱͯ͠ΘΕΔ
ຊͷνϟʔτ • ࣗݾհͳͲ 15:00 ʙ 15:05 • WebAuthnͱPasskeyͷ֓ཁ 15:05 ʙ
15:10 • Registration࣮ 15:10ʙ15:25 • Login࣮ 15:25ʙ15:35 • ·ͱΊ(όοϑΝ) 15:35ʙ15:40
Registrationͷϑϩʔ Ϣʔβʔ ϒϥβ ೝূث αʔόʔ ᶅొʹඞཁͳ ύϥϝʔλͩΑ ηογϣϯ challenge ᶃొ͍ͨ͠
ᶄ ᶆ͜ͷαΠτ༻ͷ 伴࡞ͬͯ ൿີ伴 ᶇ ᶈ࡞ͬͨ ެ։伴 ᶉ伴ͱchallengeͰ͢ ެ։伴 ᶊchallengeݕূ ᶋެ։伴Λอଘ
Registrationͷϑϩʔ https://developer.mozilla.org/ja/docs/Web/API/Web_Authentication_API
AttestationObject • ೝূث͕ൃߦ͢Δূ໌ॻͳͲؚ͕·ΕΔใ • CBORܗࣜͰΤϯίʔυ͞Ε͍ͯΔ • ·ͨɺূ໌ॻ `authData` keyͷதʹόΠφϦͰؚ·Ε͍ͯΔ
AttestationObject ެ։伴ؚ͕·Ε͍ͯΔͷ͜͜ https://www.w3.org/TR/webauthn-3/# fi g-attStructs
AttestationObjectΛόΠφϦΤσΟλͰ͘
Attestation Objectͷunpack • a32: 32όΠτ όΠφϦจࣈྻ • N: ϏοάΤϯσΟΞϯ 32bit
unsigned int • n/a: 16bit unsigned intΛऔ্ͬͨͰͦΕΛ͞ͱΈͳͦ͠ͷόΠτΛͱΔ • a*: Γશ෦ όΠφϦจࣈྻ
COSEͷத https://zenn.dev/macopy/scraps/8f50c18 fb 0b164
ొ࣌ʹαʔόʔ͕Δݕূ https://developer.mozilla.org/ja/docs/Web/API/Web_Authentication_API ҙ: ͜ͷϥΠϒίʔσΟϯάͰiiiͷҰ෦Λলུ͍ͯ͠·͢
ίϥϜ `attStmt` • attStmtެ։伴ͷॺ໊ݕূͳͲʹ༻͍ΒΕΔใ • YubikeyͳͲͷηΩϡϦςΟΩʔfmtʹ` fi do-u2f`͕ઃఆ͞Ε͍ͯΔ • `attStmt`ʹॻ͔Εͨূ໌ॻͱॺ໊Ͱਖ਼نͷηΩϡϦςΟΩʔ͔Βൃߦ͞Εͨൿ
ີ伴ɾެ։伴Ͱ͋Δ͜ͱ͕ݕূͰ͖Δ • ύεΩʔͰnone͕ઃఆ͞ΕΔ͜ͱ͕͋Δ • 1PasswordͰnone, iCloud KeychainͰ`packed`, Google Password ManagerͰ…, Windows HelloͰtpm
ຊͷνϟʔτ • ࣗݾհͳͲ 15:00 ʙ 15:05 • WebAuthnͱPasskeyͷ֓ཁ 15:05 ʙ
15:10 • Registration࣮ 15:10ʙ15:25 • Login࣮ 15:25ʙ15:35 • ·ͱΊ(όοϑΝ) 15:35ʙ15:40
Loginͷϑϩʔ https://developer.mozilla.org/ja/docs/Web/API/Web_Authentication_API
AuthenticatorData https://www.w3.org/TR/webauthn-3/# fi g-authData
Կʹॺ໊Λߦͳ͍ͬͯΔ͔ • authenticatorData + sha256(clientDataJSON) https://www.w3.org/TR/webauthn-3/# fi g-signature
ೝূ࣌ʹαʔόʔ͕Δݕূ https://developer.mozilla.org/ja/docs/Web/API/Web_Authentication_API
ຊͷνϟʔτ • ࣗݾհͳͲ 15:00 ʙ 15:05 • WebAuthnͱPasskeyͷ֓ཁ 15:05 ʙ
15:10 • Registration࣮ 15:10ʙ15:25 • Login࣮ 15:25ʙ15:35 • ·ͱΊ(όοϑΝ) 15:35ʙ15:40
·ͱΊ • WebAuthnެ։伴҉߸ͷੑ࣭Λར༻ͯ͠ύεϫʔυೝূͷམͱ݀͠ Λ௵͍ͯ͠Δ • ެ։伴͕࿙Ӯͯ͠ॺ໊Λੜ͢Δ͜ͱ͕Ͱ͖ͳ͍ • ੬ऑͳύεϫʔυ(=͍֮͑͢ύεϫʔυ)༻Ͱ͖ͳ͍ • ͍ճ͕͠Ͱ͖ͳ͍
• SpecΛಡΊPerlͰ࣮Ͱ͖Δͧ
·ͱΊ2 • ৭ʑෳࡶͳͷͰɺ͓ࣄͰϥΠϒϥϦΛͬͨํ͕ྑ͍ • PerlbatrossSimpleWebAuthn + Authen::WebAuthn • ࠓճͷίʔυΛॻ͘ͱ͖طଘͷϥΠϒϥϦͷதΛͨ͘͞Μࢀর͠ ·ͨ͠
• Specͷ͏͔ͪͳΓͷݕূΛͬ͢ඈ͍ͯ͠·͢ • ͚ͩͲΈΛ͍ͬͯΔͱσόοά͕ḿΔͷͰɺҰॻ͍ͯΈΔͱཧղ ͕ਂ·Γ·͢
ࢀߟจݙ • W3C Web Authentication: An API for accessing Public
Key Credentials Level 2 https://www.w3.org/TR/webauthn-2/ • mdn ΣϒೝূAPI https://developer.mozilla.org/ja/docs/Web/API/Web_Authentication_API • mercari engineering: WebAuthn͜ͱ͡Ί https://engineering.mercari.com/blog/entry/ 2019-06-04-120000/ • WEB+DB Press Vol.136 ಛू2 ࣮ઓೖύεΩʔ • Digital Identityٕज़ษڧձ Advent Calendar 2023 https://qiita.com/advent-calendar/2023/ iddance
See also • ImHexͰWebAuthnͷAttestationObjectΛύʔε͢Δ https:// zenn.dev/macopy/scraps/8f50c18fb0b164 • PerlͷCBOR::PPͱunpackͰWebAuthnͷAttestation ObjectΛύʔε ͢Δ
https://zenn.dev/macopy/scraps/e042aa351a57a7 • ࠓճͷ࣮ https://github.com/mackee/yapchiroshima2024
ϒϩάͰײ͓͓ͪͯ͠Γ·͢ʂ 🙏