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
Introduction to WebAuthn Testing API
Search
Yoshikazu Nojima
May 29, 2019
Technology
3
1.9k
Introduction to WebAuthn Testing API
An Introduction to Google Chrome WebAuthn Testing API
Yoshikazu Nojima
May 29, 2019
Tweet
Share
More Decks by Yoshikazu Nojima
See All by Yoshikazu Nojima
サーバーサイド開発者のためのパスキー入門
ynojima
4
720
Mavenパッケージの署名検証
ynojima
1
52
FIDO CTAP2 from Authenticator perspective
ynojima
2
890
WebAuthn & WebAuthn4J Introduction
ynojima
2
2.5k
WebAuthn for Java developers
ynojima
2
1.9k
WebAuthn from the relying-party view
ynojima
2
6k
WebAuthn in a nutshell - NTT Tech Conf #3 (ja)
ynojima
2
1.9k
Spring Securityでハードウェアトークン認証
ynojima
0
870
Other Decks in Technology
See All in Technology
プロセス改善による品質向上事例
tomasagi
2
2.6k
室長と気ままに学ぶマイクロソフトのビジネスアプリケーションとビジネスプロセス
ryoheig0405
0
370
Goで作って学ぶWebSocket
ryuichi1208
1
1.1k
RECRUIT TECH CONFERENCE 2025 プレイベント【高橋】
recruitengineers
PRO
0
160
JEDAI Meetup! Databricks AI/BI概要
databricksjapan
0
110
現場で役立つAPIデザイン
nagix
33
12k
「海外登壇」という 選択肢を与えるために 〜Gophers EX
logica0419
0
710
2/18/25: Java meets AI: Build LLM-Powered Apps with LangChain4j
edeandrea
PRO
0
120
滅・サービスクラス🔥 / Destruction Service Class
sinsoku
6
1.6k
Cloud Spanner 導入で実現した快適な開発と運用について
colopl
1
680
Classmethod AI Talks(CATs) #16 司会進行スライド(2025.02.12) / classmethod-ai-talks-aka-cats_moderator-slides_vol16_2025-02-12
shinyaa31
0
110
明日からできる!技術的負債の返済を加速するための実践ガイド~『ホットペッパービューティー』の事例をもとに~
recruitengineers
PRO
3
400
Featured
See All Featured
It's Worth the Effort
3n
184
28k
Designing for Performance
lara
604
68k
The Language of Interfaces
destraynor
156
24k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
9
440
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
174
51k
Thoughts on Productivity
jonyablonski
69
4.5k
BBQ
matthewcrist
87
9.5k
YesSQL, Process and Tooling at Scale
rocio
172
14k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
4
410
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Done Done
chrislema
182
16k
How to train your dragon (web standard)
notwaldorf
91
5.8k
Transcript
Copyright © Yoshikazu Nojima 2018 WebAuthnテスト自動化入門 2019-05-29 iddance #1 能島
良和 (@shiroica)
Copyright © Yoshikazu Nojima 2018 自己紹介 • 能島良和 • 通信キャリアでホスティングサービスの開発・運用
• 前職は通信キャリア系SIerで社内向けにSpringのPJ支援業務 • Apache CloudStack Commiter(活動休止中。。) • WebAuthn4Jというライブラリ作ってます • https://github.com/webauthn4j/webauthn4j • JJUG発表資料:Java開発者のためのWebAuthn入門 • https://speakerdeck.com/ynojima/webauthn-for-java-developers • Twitter:@shiroica • GitHub:ynojima 1
Copyright © Yoshikazu Nojima 2018 WebAuthn採用時の悩み 2 どうやって自動テスト書く?
Copyright © Yoshikazu Nojima 2018 E2Eテストで扱う典型的な認証フロー(パスワード認証) 1. 登録画面に遷移する 2. 登録画面でユーザー名と
パスワードを入力する 3. 登録ボタンを押す 4. 認証画面に遷移する 5. 認証画面でユーザー名と パスワードを入力する 6. 認証画面で認証ボタンを押す 3 自動化は容易
Copyright © Yoshikazu Nojima 2018 E2Eテストで扱う典型的な認証フロー(WebAuthn認証) 1. 登録画面に遷移する 2. 登録画面でユーザー名を入力する
3. Authenticatorの追加ボタンを押す 4. Authenticatorデバイス側で承認ジェスチャーを行う 5. 登録ボタンを押す 6. 認証画面に遷移する 7. 認証画面で認証ボタンを押す 8. Authenticatorデバイスで認証ジェスチャーを行う 4
Copyright © Yoshikazu Nojima 2018 E2Eテストで扱う典型的な認証フロー(WebAuthn認証) 1. 登録画面に遷移する 2. 登録画面でユーザー名を入力する
3. Authenticatorの追加ボタンを押す 4. Authenticatorデバイス側で承認ジェスチャーを行う 5. 登録ボタンを押す 6. 認証画面に遷移する 7. 認証画面で認証ボタンを押す 8. Authenticatorデバイスで認証ジェスチャーを行う 5 手動操作が必要
Copyright © Yoshikazu Nojima 2018 6 認証ジェスチャなしで応答を 返す、エミュレータが欲しい
Copyright © Yoshikazu Nojima 2018 Web Authentication Testing API WebAuthnのE2Eテスト実装を支援するためのChromeのAPI
Chrome://flags画面あるいは起動オプションから有効化可能(デフォルトでは無効) 7
Copyright © Yoshikazu Nojima 2018 selenium-javaでのテストコード例(1/2) 8 @RunWith(SpringRunner.class) @SpringBootTest(classes =
SampleWebApplication.class, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) public class E2ETestBase { protected WebDriver driver; protected WebDriverWait wait; @BeforeClass public static void setupClassTest(){ WebDriverManager.chromedriver().setup(); } @Before public void setupTest() { ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.addArguments(“--enable-web-authentication-testing-api”); //chromeOptions.setHeadless(true); driver = new ChromeDriver(chromeOptions); wait = new WebDriverWait(driver, 5); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); } @After public void teardown() { if (driver != null) driver.quit();} } 起動オプションで指定 Headless起動も可能
Copyright © Yoshikazu Nojima 2018 selenium-javaでのテストコード例(2/2) 9 public class RegistrationAndAuthenticationE2ETest
extends E2ETestBase{ @Test public void test() { // Registration SignupComponent signupComponent = new SignupComponent(driver); signupComponent.navigate(); signupComponent.setFirstname(“John”); signupComponent.setLastname(“Doe”); signupComponent.setUsername(“
[email protected]
”); signupComponent.setPassword(“password”); signupComponent.clickAddAuthenticator(); signupComponent.getResidentKeyRequirementDialog().clickNo(); signupComponent.waitRegisterClickable(); signupComponent.clickRegister(); // Password authentication wait.until(ExpectedConditions.urlToBe(“http://localhost:8080/angular/login”)); PasswordLoginComponent passwordLoginComponent = new PasswordLoginComponent(driver); passwordLoginComponent.setUsername(“
[email protected]
”); passwordLoginComponent.setPassword(“password”); passwordLoginComponent.clickLogin(); // 2nd-factor authentication AuthenticatorLoginComponent authenticatorLoginComponent = new AuthenticatorLoginComponent(driver); // nop wait.until(ExpectedConditions.urlToBe(“http://localhost:8080/angular/profile”)); } テストコード自体は ページオブジェクト パターンに則った Seleniumの普通の テストコード
Copyright © Yoshikazu Nojima 2018 ChromeのAuthenticatorエミュレータが返却する Attestation Certificate • Attestation
Certificateは自己署名証明書 • RPがルート証明書とチェーンしているか検証している場合、検証エラー 10
Copyright © Yoshikazu Nojima 2018 おまけ • WebAuthn4JではAuthenticatorのエミュレータをPure Javaで実装 •
ブラウザ使わずにサーバー単体でのテストを実装可能 11 // 認証デバイスエミュレータの接続されたクライアントエミュレータを準備 private ClientPlatform clientPlatform = EmulatorUtil.createClientPlatform(new AndroidSafetyNetAuthenticator()); @Test void validate_test(){ String rpId = “example.com”; Challenge challenge = new DefaultChallenge(); AuthenticatorSelectionCriteria authenticatorSelectionCriteria = new AuthenticatorSelectionCriteria(AuthenticatorAttachment.CROSS_PLATFORM, true, UserVerificationRequirement.REQUIRED); PublicKeyCredentialParameters publicKeyCredentialParameters = new PublicKeyCredentialParameters(PublicKeyCredentialType.PUBLIC_KEY, COSEAlgorithmIdentifier.ES256); PublicKeyCredentialUserEntity publicKeyCredentialUserEntity = new PublicKeyCredentialUserEntity(); AuthenticationExtensionsClientInputs<RegistrationExtensionClientInput> extensions = new AuthenticationExtensionsClientInputs<>(); PublicKeyCredentialCreationOptions credentialCreationOptions = new PublicKeyCredentialCreationOptions( new PublicKeyCredentialRpEntity(rpId, “example.com”), publicKeyCredentialUserEntity, challenge, Collections.singletonList(publicKeyCredentialParameters), null, Collections.emptyList(), authenticatorSelectionCriteria, AttestationConveyancePreference.DIRECT, extensions ); // エミュレータによるCredentialの生成 PublicKeyCredential<AuthenticatorAttestationResponse, RegistrationExtensionClientOutput> publicKeyCredential = clientPlatform.create(credentialCreationOptions); // 以下省略 }
Copyright © Yoshikazu Nojima 2018 まとめ • WebAuthnは認証デバイスに対するユーザーの承認ジェスチャーが必要 • E2E自動テスト実施する上で承認ジェスチャー要件が障害
• Chromeは起動オプションでAuthenticatorエミュレータに実装を切替、 承認ジェスチャーをスキップ可能 • WebAuthnでも諦めずにE2Eテストを書いていきましょう! 12
Copyright © Yoshikazu Nojima 2018 おまけ1 ChromiumのWebAuthnのE2Eテストコード https://github.com/chromium/chromium/blob/fc74bfe460548ef49e12 d78c476f0ffc5ff2db99/third_party/blink/web_tests/http/tests/credenti almanager/virtual-navigator-credentials.html#L20-L43
13
Copyright © Yoshikazu Nojima 2018 おまけ2 WebAuthn Testing API Design
Doc https://docs.google.com/document/d/1bp2cMgjm2HSpvL9-WsJoIQMsBi1oKGQY6CvWD- 9WmIQ/edit#heading=h.wemjkxju7znw 14