ボット検知をネイティブアプリケーションに追加する
ボット検知をネイティブアプリケーションに追加する場合、使用するSDKと認証フローによっては、構成をほとんどまたは全く必要としません。
Auth0.swiftとAuth0.Android
ユニバーサルログインを使用している場合、ボット検知は以下のSDKバージョンによって自動的にサポートされています。
Auth0.swift
バージョン1.28.0+Auth0.Android
バージョン1.25.0+
ユニバーサルログインを使用していない場合、ボット検知はサポートされていますが、アプリケーションを適宜構成する必要があります。
アプリケーションは、
requires_verification
という例外(ログイン試行が高リスクであると判定されると例外をスローする)を処理し、CAPTCHA検証ステップを生じさせるためにWebAuthフローをトリガーする必要があります。WebAuthフローをトリガーしたら、ユーザーがユーザー名をもう一度入力する必要がないように、
login_hint
パラメーターを渡してください。
Auth0.swiftの例
アプリケーションが、Authentication APIを通じてデータベースログイン/サインアップを実行する場合は、isVerificationRequired
エラーを処理する必要があります。このエラーは、要求が疑わしいとフラグが立てられ、ユーザー認証に別の検証ステップが必要であることを示します。
Auth0
.authentication()
.login(usernameOrEmail: email,
password: password,
realmOrConnection: connection,
scope: scope)
.start { result in
switch result {
case .success(let credentials): // ...
case .failure(let error) where error.isVerificationRequired:
DispatchQueue.main.async {
Auth0
.webAuth()
.connection(connection)
.scope(scope)
.useEphemeralSession()
// ☝🏼 Otherwise a session cookie will remain
.parameters(["login_hint": email])
// ☝🏼 So the user doesn't have to type it again
.start { result in
// ...
}
}
case .failure(let error): // ...
}
}
Was this helpful?
サインアップの場合は、別のパラメーターを追加して、ユーザーをサインアップページに直接移動させることができます。
.parameters(["login_hint": email, "screen_hint":"signup"])
ユニバーサルログインをセットアップする方法については、「Auth0.swiftを使ってみる」をお読みください。
Auth0.Androidの例
アプリケーションが、Authentication APIを通じてデータベースログイン/サインアップを実行する場合は、AuthenticationException#isVerificationRequired()
エラーを処理する必要があります。このエラーは、要求が疑わしいとフラグが立てられ、ユーザーのログインに別の検証ステップが必要であることを示します。
final String email = "username@domain.com";
final String password = "a secret password";
final String realm = "my-database-connection";
AuthenticationAPIClient authentication = new AuthenticationAPIClient(account);
authentication.login(email, password, realm)
.start(new BaseCallback<Credentials, AuthenticationException>() {
@Override
public void onFailure(AuthenticationException error) {
if (error.isVerificationRequired()){
Map<String, Object> params = new HashMap<>();
params.put("login_hint", email); // So the user doesn't have to type it again
WebAuthProvider.login(account)
.withConnection(realm)
.withParameters(params)
.start(LoginActivity.this, new AuthCallback() {
// You might already have an AuthCallback instance defined
@Override
public void onFailure(@NonNull Dialog dialog) {
// Error dialog available
}
@Override
public void onFailure(AuthenticationException exception) {
// Error
}
@Override
public void onSuccess(@NonNull Credentials credentials) {
// Handle WebAuth success
}
});
}
}
@Override
public void onSuccess(Credentials payload) {
// Handle API success
}
});
Was this helpful?
サインアップの場合は、別のパラメーターを追加して、ユーザーをサインアップページに直接移動させることができます。
params.put("screen_hint", "signup");
ユニバーサルログインをセットアップする方法については、「ユニバーサルログインSDKによるAuth0.Androidの認証」ドキュメントをお読みください。
Lock.SwiftとLock.Android
ユニバーサルログインを使用している場合、ボット検知は以下のSDKバージョンによって自動的にサポートされています。
Lock.Swift
バージョン2.19.0+Lock.Android
バージョン2.22.0+
ユニバーサルログインを使用していない場合、ボット検知はサポートされていますが、アプリケーションを適宜構成する必要があります。
アプリケーションは、
requires_verification
という例外(ログイン試行が高リスクであると判定されると例外をスローする)を処理し、CAPTCHA検証ステップを生じさせるためにWebAuthフローをトリガーする必要があります。WebAuthフローをトリガーしたら、ユーザーがユーザー名をもう一度入力する必要がないように、
login_hint
パラメーターを渡してください。
Authentication API(認証API)
Authentication APIを直接使用している場合、ボット検知はサポートされていますが、アプリケーションを適宜構成する必要があります。
アプリケーションは、
requires_verification
エラー(ログイン試行が高リスクであると判定されるとAuthentication APIによって返される)を処理し、CAPTCHA検証ステップを生じさせるためにWebAuthフローをトリガーする必要があります。