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
6.9k
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
97
perlをWebAssembly上で動かすと何が嬉しいの??? / Where does Perl-on-Wasm actually make sense?
mackee
0
970
Agentに至る道 〜なぜLLMは自動でコードを書けるようになったのか〜
mackee
6
5.8k
今!ソフトウェアエンジニアがハードウェアに手を出すには
mackee
14
7k
ワンバイナリWebサービスのススメ
mackee
10
8.8k
tanukistack ライブコーディング / tanukistack live-coding
mackee
0
660
range over funcの使い道と非同期N+1リゾルバーの夢 / about a range over func
mackee
0
1.2k
perl for shell, awk and sed programmers
mackee
3
2.8k
今更GoのWebフレームワークを作ろうとしているワケ / Why am I trying to create a Go web framework now?
mackee
1
1.1k
Featured
See All Featured
The Spectacular Lies of Maps
axbom
PRO
1
800
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
370
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Paper Plane
katiecoart
PRO
1
51k
My Coaching Mixtape
mlcsv
0
140
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
118
120k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
22k
Making the Leap to Tech Lead
cromwellryan
135
9.9k
Embracing the Ebb and Flow
colly
88
5.1k
Fireside Chat
paigeccino
42
3.9k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.2k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.5k
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
ϒϩάͰײ͓͓ͪͯ͠Γ·͢ʂ 🙏