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
Firebase Hostingを使ってPasskeyをandroidアプリで試してみよう
Search
RyuNen344
December 08, 2023
Programming
2
1.9k
Firebase Hostingを使ってPasskeyをandroidアプリで試してみよう
RyuNen344
December 08, 2023
Tweet
Share
More Decks by RyuNen344
See All by RyuNen344
Cache Me If You Can
ryunen344
3
7.3k
WindowInsetsだってテストしたい
ryunen344
1
300
サプライチェーン攻撃に備える
ryunen344
1
3k
Okioに愛を込めて
ryunen344
3
2.5k
Xcode Meets Gradle
ryunen344
0
370
わかった気になる、Coroutine1.7.0のチャンネルのパフォーマンス向上
ryunen344
0
400
K/NとNSKeyedArchiverと私
ryunen344
0
560
ComposeのModalBottomSheetは (まだ)沼
ryunen344
1
1.9k
うわっ…もしかして私のコー ド、遅すぎ…?
ryunen344
1
970
Other Decks in Programming
See All in Programming
O Que É e Como Funciona o PHP-FPM?
marcelgsantos
0
200
「ちょっと古いから」って避けてた技術書、今だからこそ読もう
mottyzzz
12
7.2k
エンジニアインターン「Treasure」とHonoの2年、そして未来へ / Our Journey with Hono Two Years at Treasure and Beyond
carta_engineering
0
430
理論と実務のギャップを超える
eycjur
0
180
AkarengaLT vol.38
hashimoto_kei
1
120
20251016_Rails News ~Rails 8.1の足音を聴く~
morimorihoge
3
740
NIKKEI Tech Talk#38
cipepser
0
230
When Dependencies Fail: Building Antifragile Applications in a Fragile World
selcukusta
0
110
デミカツ切り抜きで面倒くさいことはPythonにやらせよう
aokswork3
0
260
AI Agent 時代的開發者生存指南
eddie
4
2.1k
Software Architecture
hschwentner
6
2.3k
GC25 Recap: The Code You Reviewed is Not the Code You Built / #newt_gophercon_tour
mazrean
0
110
Featured
See All Featured
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1k
The Straight Up "How To Draw Better" Workshop
denniskardys
238
140k
Six Lessons from altMBA
skipperchong
29
4k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
48
9.7k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.2k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
34
2.3k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.5k
Docker and Python
trallard
46
3.6k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Building Applications with DynamoDB
mza
96
6.7k
Transcript
Firebase Hostingを使ってPasskeyを androidアプリで試してみよう Bunjiro Miyoshi(RyuNen344) GDG DevFest Tokyo 2023
About Me • RyuNen344 • Kotlin Multiplatform(KMM/KMP)好き • 特技はKotlin/NativeでObj-Cを書くこと •
Gradleは友達, コワクナイ
Agendas 1. What is Passkey 2. Minimum requirements for practicing
Passkey 3. Setup Firebase Hosting 4. Practice androidx.CredentialManager
What is Passkey • FIDO2を使って同一エコシステム上であればキーが同期される規格 • FIDO ◦ 専用デバイスの公開鍵と署名をやりとりすることで認証する •
FIDO2 ◦ 認証器がより柔軟になった(端末認証, 生体認証が利用可) ◦ WebAuthnは柔軟にするために使われている規格(Web API)
What is Passkey • DevFest & Android Dev Summit Japan
2022のえーじさんによるセッショ ンも非常にわかりやすいのでおススメ • サービスへの組み込み方は👇がおススメ ◦ Android Developers ▪ https://developer.android.com/design/ui/mobile/guides/p atterns/passkeys ◦ DroidKaigi 2023 ▪ 様々なユースケースに利用できる "パスキー" の導入事例の紹介と UXの課題解説/ritou
Supported Services • いろいろな会社/サービスが続々サポートし始めている ◦ DocuSign ◦ Google ◦ カヤック
◦ メルカリ ◦ NTT ドコモ ◦ PayPal ◦ Shopify ◦ LINEヤフー(旧:Yahoo! JAPAN) ◦ GitHub ◦ Amazon ◦ etc…. https://developers.google.com/identity/passkeys#relying-parties
Minimum requirements for practicing Passkey • ローカル認証(生体認証, 知識認証)を有効化している端末 • android14
device or androidx.CredentialManager • Digital Asset Links • WebAuthn:PublicKeyCredentialCreationOptionsJSON/PublicKe yCredentialRequestOptionsJSON
About androidx.CredentialManager • 2023年11月1日に1.2.0(初めてのstable🎉)がリリース • android14に追加されたCredentialManagerをAndroid4.4から使用で きるようにする • Passkeyはandroid9以降のみ, それ以下はパスワードとSign
in with googleのみ
About androidx.CredentialManager • Intent引き回し芸を内部でやってくれるので使わない手はない • Smart Lock for Passwords, FIDO2(play-services-fido)を使用して
いるアプリは移行してあげるとよい ◦ アプリで検出不能なFIDO認証情報(物理的なセキュリティキー)を使 用する必要がある場合はまだfidoで行なう必要ある
About Digital Asset Links • 雑に言うと$domain/.well-known/assetlink.jsonのこと 👉つまりドメインを確保してjsonを配置しなければならない
About Digital Asset Links • 雑に言うと$domain/.well-known/assetlink.jsonのこと 🤔Firebase周りで見かけたことあるな
About Digital Asset Links • Firebase Dynamic Links(以降FDL)をつかうと見かける ◦ FDLはサービスシャットダウンがアナウンスされている🥺
• 実はFDLのmigration guideが公開されている ◦ https://firebase.google.com/support/guides/app-links-uni versal-links ◦ その中でFirebase Hostingに移行するセクションがある 😎Firebase Hostingつかおう
Setup Firebase Hosting 1. Firebase Projectをつくる 2. Firebase CLIをインストールしてセットアップする 3.
assetlink.jsonを作る 4. WebAuthnのjsonを作る 5. Firebase Hostingにdeployする
Setup Firebase Hosting 1. Firebase Projectをつくる 2. Firebase CLIをインストールしてセットアップする 3.
assetlink.jsonを作る 4. WebAuthnのjsonを作る 5. Firebase Hostingにdeployする 公式サイト通りなので割愛 https://firebase.google.com/docs/cli
Setup Firebase Hosting 1. Firebase Projectをつくる 2. Firebase CLIをインストールしてセットアップする 3.
assetlink.jsonを作る 4. WebAuthnのjsonを作る 5. Firebase Hostingにdeployする
Create AssetLink.json
Create AssetLink.json targetがドメインをどう扱って良いかを宣言する Passkeyを実装するためには👇両方必要 1. handle_all_urls(URLを処理する) 2. get_login_creds(認証情報を取り扱う)
Create AssetLink.json package_nameにはapplicationIdを指定する sha256_cert_fingerprintsはkeytoolsかapksignerを使って確認すると早い
Setup Firebase Hosting 1. Firebase Projectをつくる 2. Firebase CLIをインストールしてセットアップする 3.
assetlink.jsonを作る 4. WebAuthnのjsonを作る 5. Firebase Hostingにdeployする
Create json for WebAuthn • Passkeyを試すための最小限必要なjsonは👇の2つ a. PublicKeyCredentialCreationOptionsJSON ▪ キー生成をするためのjson
▪ https://w3c.github.io/webauthn/#dictdef-publickeycrede ntialcreationoptionsjson b. PublicKeyCredentialRequestOptionsJSON ▪ 生成済みのキーを取得するためのjson ▪ https://w3c.github.io/webauthn/#dictdef-publickeycrede ntialrequestoptionsjson
PublicKeyCredentialCreationOptions
PublicKeyCredentialCreationOptions RP(Relying Party)にはFirebase Hostingで作ったドメインを指定する
PublicKeyCredentialCreationOptions user, challengeは本来動的に生成するもの(*今回は横着して固定値)
PublicKeyCredentialCreationOptions authenticatorSelection.authenticatorAttachmentの値で挙動が変わる platform: 現在のデバイスを登録 cross-platform: 多要素認証を登録する(のでPasskey文脈では使われない) null: ユーザーが希望するデバイスを登録
PublicKeyCredentialRequestOptions
PublicKeyCredentialRequestOptions RP(Relying Party)にはFirebase Hostingで作ったドメインを指定する challengeは本来動的に生成するもの(*今回は横着して固定値)
Setup Firebase Hosting 1. Firebase Projectをつくる 2. Firebase CLIをインストールしてセットアップする 3.
assetlink.jsonを作る 4. WebAuthnのjsonを作る 5. Firebase Hostingにdeployする
Setup Firebase Hosting 1. Firebase Projectをつくる 2. Firebase CLIをインストールしてセットアップする 3.
assetlink.jsonを作る 4. WebAuthnのjsonを作る 5. Firebase Hostingにdeployする 😎firebase deployを実行するだけ
Practice androidx.CredentialManager 1. update gradle dependency 2. implement with CredentialManager
Practice androidx.CredentialManager 1. update gradle dependency 2. implement with CredentialManager
Update gradle dependency play-servicesの認証情報を使う場合は credentials-play-services-authも追加でimplementationする
Practicing androidx.CredentialManager 1. update gradle dependency 2. implement with CredentialManager
Implement with CredentialManager 😎あとは基本公式どおり・・・・だけど
Implement with CredentialManager
Implement with CredentialManager WebAuthn用のjsonをHttpClient等で取得して渡す
😎Ready for Passkey 😎動的なバックエンド実装を用意するならCloud Functionsを使うとよい
References • https://developer.android.com/training/sign-in/passkeys • https://developers.google.com/identity/passkeys • https://developers.google.com/digital-asset-links • https://www.youtube.com/watch?v=TWlZzPrlFYA •
https://github.com/android/identity-samples • https://github.com/android/codelab-fido2 • https://github.com/google/webauthndemo
EOF