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.3k
Firebase Hostingを使ってPasskeyをandroidアプリで試してみよう
RyuNen344
December 08, 2023
Tweet
Share
More Decks by RyuNen344
See All by RyuNen344
Okioに愛を込めて
ryunen344
3
1.2k
Xcode Meets Gradle
ryunen344
0
250
わかった気になる、Coroutine1.7.0のチャンネルのパフォーマンス向上
ryunen344
0
280
K/NとNSKeyedArchiverと私
ryunen344
0
410
ComposeのModalBottomSheetは (まだ)沼
ryunen344
1
1.3k
うわっ…もしかして私のコー ド、遅すぎ…?
ryunen344
1
710
K/NでCryptoKit使いたかった
ryunen344
0
300
SwiftPM with KMMをprivateなGitHub Releaseで運用する
ryunen344
0
290
Kotlin Nativeってandroid向けにもかけるんですよ
ryunen344
0
570
Other Decks in Programming
See All in Programming
データカタログ運用物語 〜令和6年夏の理想と現実〜
kuro_kurorrr
0
110
最近追加した型の紹介とその振り返り
aki19035vc
0
180
Microservices rules (July 2024) : what good looks like
cer
PRO
0
1.6k
I/O Extended Android in Korea 2024 ~ Whats new in Android development tools
pluu
0
250
APIのない大学ログインWebサービスをWKWebViewとJavaScriptでアプリ化した話
akidon0000
1
330
CSC307 Lecture 08
javiergs
PRO
0
330
3 Effective Rules for Success with Signals in Angular
manfredsteyer
PRO
0
120
CSC307 Lecture 14
javiergs
PRO
0
220
企業向け生成AIアプリの 開発から得られた知見
takaakikakei
0
310
[After Kotlin Fest 2024 LT Night @ Sansan] もっともっとKotlinを好きになる!K2 Compiler Pluginで遊んでみよう!
kitakkun
2
260
Rust.Nagoya #1
codemountains
0
170
日付と正規化
megmogmog1965
0
140
Featured
See All Featured
GitHub's CSS Performance
jonrohan
1026
450k
A Tale of Four Properties
chriscoyier
155
22k
Principles of Awesome APIs and How to Build Them.
keavy
124
16k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
12
3.8k
Building Your Own Lightsaber
phodgson
101
5.9k
Robots, Beer and Maslow
schacon
PRO
157
8.1k
Clear Off the Table
cherdarchuk
89
320k
What’s in a name? Adding method to the madness
productmarketing
PRO
21
2.9k
How to Ace a Technical Interview
jacobian
274
23k
In The Pink: A Labor of Love
frogandcode
139
22k
A Philosophy of Restraint
colly
200
16k
RailsConf 2023
tenderlove
16
720
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