패키지, 저장소 및 앱 카테고리 검색

패키지 상세v18.9.3

recaptcha_enterprise_flutter

reCAPTCHA Enterprise용 Flutter 플러그인입니다.

AndroidiOS
30일 다운로드
15.6만
좋아요
55
Pub 점수
150

패키지 설치

flutter pub add recaptcha_enterprise_flutter

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

안드로이드 및 iOS용 모바일 애플리케이션에 Google의 reCAPTCHA Enterprise를 통합하는 플러터 플러그인입니다. 고급 위험 분석을 통해 사용자 상호작용을 검증함으로써 개발자가 앱을 봇과 자동화된 위협으로부터 보호할 수 있도록 합니다. 기업 수준의 CAPTCHA 도전 과제 구현을 간소화하며, 사용자 경험을 훼손하지 않고 원활한 인증 흐름을 지원합니다. Google 클라우드 인프라를 활용하여 최소한의 구성으로 강력한 보안을 제공합니다. 민감한 환경에서 고보안 검증이 필요한 앱에 적합합니다.

사용 사례

  • 봇 공격으로부터 로그인 폼 보호하기
  • 자동 요청으로부터 API 엔드포인트 보호하기
  • 사기성 가입 방지
  • 금융 또는 헬스케어 앱의 보안 강화
  • 중요한 작업 중 인간 사용자 확인

주요 기능

  • Google reCAPTCHA Enterprise와 통합
  • 안드로이드 및 iOS 플랫폼을 지원합니다
  • Flutter 친화적인 API를 활용한 최소 설정
  • 위험 분석 및 도전 과제 처리 제공
  • 토큰 검증을 통한 서버 측 검증을 활성화합니다

적합한 대상

  • 강력한 봇 보호가 필요한 모바일 앱
  • 기업 수준의 보안 요구 사항
  • 민감한 사용자 데이터를 처리하는 애플리케이션
  • Google Cloud 서비스를 사용하는 개발자
  • 보안 기준 준수를 요구하는 프로젝트

고려 사항

  • reCAPTCHA Enterprise가 활성화된 Google Cloud 프로젝트가 필요합니다
  • 완전한 보안을 위해 서버 측 토큰 검증이 필요합니다
  • 과도하게 사용할 경우 사용자 경험에 영향을 줄 수 있습니다
  • 도전 과제 전달에 네트워크 연결에 의존합니다
  • 웹 구현에 비해 사용자 정의가 제한적

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

reCAPTCHA Enterprise Flutter Module

Please note that issues filed in this repository are not an official Google support channel and are answered on a best effort basis. For official support, please visit: https://cloud.google.com/support-hub.

If you have an issue with the Flutter plugin please post issues in this repository. If you are having issues with the underlying SDK, please post issues in https://github.com/GoogleCloudPlatform/recaptcha-enterprise-mobile-sdk.

For general documentation on reCAPTCHA Enterprise for mobile applications, see Android and iOS.

Integrating reCAPTCHA Enterprise with your Flutter Application

This guide outlines the steps to integrate reCAPTCHA Enterprise into your Flutter application for enhanced security.

1. Environment Setup
  1. Add the reCAPTCHA Enterprise Flutter library:

    Execute the following command in your Flutter project's root directory:

    flutter pub add recaptcha_enterprise_flutter
    

    Note: This library supports only iOS and Android platforms.

2. Client Initialization
  1. Obtain Site Keys:

    Acquire your reCAPTCHA Enterprise site keys for both Android and iOS platforms from the Google Cloud Console.

  2. Instantiate the RecaptchaClient:

    Initialize the client using the appropriate site key based on the platform. It's crucial to initialize the client as early as possible within your application's lifecycle to minimize latency.

    import 'package:flutter/material.dart';
    import 'package:recaptcha_enterprise_flutter/recaptcha_enterprise_flutter.dart';
    import 'dart:io' show Platform;
    
    void main() async {
      WidgetsFlutterBinding.ensureInitialized();
    
      final siteKey = Platform.isAndroid
          ? "<ANDROID_SITE_KEY>"
          : "<IOS_SITE_KEY>";
    
      RecaptchaClient client = await Recaptcha.fetchClient(siteKey);
    
      runApp(MyApp(client: client));
    }
    
    class MyApp extends StatelessWidget {
      final RecaptchaClient client;
    
      const MyApp({super.key, required this.client});
    
      // ... other code ...
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          home: MyHomePage(title: 'reCAPTCHA Demo', client: client),
        );
      }
    }
    

    Important:

    • Replace <ANDROID_SITE_KEY> and <IOS_SITE_KEY> with your actual reCAPTCHA Enterprise site keys.
    • The example above demonstrates platform-specific site key selection. You can adopt alternative strategies, such as using asset files, to manage your site keys.
    • Initialization of the SDK can take several seconds to complete. To mitigate this latency, initialize the client as early as possible,
3. Executing reCAPTCHA Actions
  1. Invoke the execute method:

    For each action within your application that requires reCAPTCHA protection (e.g., login, registration), call the execute method of the RecaptchaClient, passing a RecaptchaAction instance.

    class MyHomePage extends StatefulWidget {
      const MyHomePage({super.key, required this.title, required this.client});
    
      final String title;
      final RecaptchaClient client;
    
      Future<bool> _login() async {
        try {
          String token = await client.execute(RecaptchaAction.LOGIN());
          // Send the token to your server for assessment.
          return await handleToken(token); // handleToken is a function that sends the token to your backend.
        } catch (err) {
          // Handle reCAPTCHA execution errors.
          print('reCAPTCHA execution error: $err');
          return false;
        }
      }
    
      // ... other code ...
    
      @override
      State<MyHomePage> createState() => _MyHomePageState();
    }
    
    class _MyHomePageState extends State<MyHomePage> {
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(
            title: Text(widget.title),
          ),
          body: Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                // ... other UI elements ...
                ElevatedButton(
                  onPressed: () async {
                    bool loginSuccess = await widget._login();
                    if(loginSuccess){
                      // handle successful login
                    } else {
                      // handle failed login
                    }
                  },
                  child: const Text('Login'),
                ),
              ],
            ),
          ),
        );
      }
    
    }
    Future<bool> handleToken(String token) async{
      // sends token to your backend.
      // this is a placeholder function, and needs to be implemented.
      return true;
    }
    
    • Replace handleToken(token) with your server-side logic for assessing the reCAPTCHA token.
4. Error Handling
  1. Implement Robust Error Handling:

    Your application must gracefully handle potential errors during reCAPTCHA service communication. Implement appropriate error handling mechanisms to manage scenarios where the API encounters issues.

  2. Refer to Official Documentation:

    Consult the official Google Cloud reCAPTCHA Enterprise documentation for detailed information on error codes and best practices:

Sample App

Copy example/assets/configs/dev.json.example to example/assets/configs/dev.json and add your sitekeys to the file.

Change ios bundle id in example/ios/Runner.xcodeproj/project.pbxproj from google.FlutterTestApp in three places to your own bundle id.

Change the Android bundle id in example/android/app/build.gradle from google.FlutterTestApp to your own.

Start an emulator, e.g. open -a Simulator or ~/Library/Android/sdk/emulator/emulator -avd Pixel_4_API_32

Run app:
cd example && flutter run
Run unit tests:
flutter test
Running Integration Tests
cd example && flutter test integration_test/app_test.dart

카테고리

의존성

의존성 목록 1 개

  • plugin_platform_interface^2.0.2

소스 저장소

이 패키지를 사용하는 프로젝트