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
PerlでつくるフルスクラッチWebAuthn/パスキー認証 / Demonstration ...
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
mackee
February 10, 2024
7.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
860
perlをWebAssembly上で動かすと何が嬉しいの??? / Where does Perl-on-Wasm actually make sense?
mackee
0
1.5k
Agentに至る道 〜なぜLLMは自動でコードを書けるようになったのか〜
mackee
6
6.8k
今!ソフトウェアエンジニアがハードウェアに手を出すには
mackee
14
7.6k
ワンバイナリWebサービスのススメ
mackee
10
9.3k
tanukistack ライブコーディング / tanukistack live-coding
mackee
0
940
range over funcの使い道と非同期N+1リゾルバーの夢 / about a range over func
mackee
0
1.2k
perl for shell, awk and sed programmers
mackee
3
3k
今更GoのWebフレームワークを作ろうとしているワケ / Why am I trying to create a Go web framework now?
mackee
1
1.2k
Featured
See All Featured
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.6k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
760
How to Talk to Developers About Accessibility
jct
2
590
Amusing Abliteration
ianozsvald
1
350
GraphQLとの向き合い方2022年版
quramy
50
15k
How to Ace a Technical Interview
jacobian
280
24k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
A designer walks into a library…
pauljervisheath
211
25k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Git: the NoSQL Database
bkeepers
PRO
433
67k
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
ϒϩάͰײ͓͓ͪͯ͠Γ·͢ʂ 🙏