다음을 통해 공유


지문(생체 인식) 인증(HTML)

[ 이 문서는 Windows 런타임 앱을 작성하는 Windows에서 8.x 및 Windows Phone 8.x 개발자를 대상으로 합니다. Windows 10용으로 개발하는 경우에는 최신 설명서를 참조하세요.]

사용자가 특정 작업에 동의해야 하는 경우 지문(생체 인식) 인증 요청을 포함하여 앱의 보안을 향상시킬 수 있습니다. 예를 들어 제한된 리소스 액세스 또는 앱에서 바로 구매 권한을 부여하기 전에 지문 인증을 요구할 수 있습니다. Windows.Security.Credentials.UI 네임스페이스의 UserConsentVerifier 클래스를 사용하여 지문 인증을 관리할 수 있습니다.

장치에 지문 판독기가 있는지 확인하려면 UserConsentVerifier.CheckAvailabilityAsync 메서드를 호출합니다. 장치에서 지문 인증을 지원하는 경우에도 앱에서는 지문 인증을 사용하거나 사용하지 않도록 설정하도록 사용자에게 설정 옵션을 제공해야 합니다. 이 설정을 만드는 방법에 대한 자세한 내용은 앱 설정 추가를 참조하세요.

다음 예제에서는 현재 컴퓨터가 지문 인증을 지원하는지 확인하고 결과와 함께 메시지를 반환하는 메서드를 보여 줍니다.

function checkFingerprintAvailability() {
    try {
        // Check the availability of fingerprint authentication.

        Windows.Security.Credentials.UI.UserConsentVerifier.checkAvailabilityAsync().then(
        function (ucvAvailability) {

            switch (ucvAvailability)
            {
                case Windows.Security.Credentials.UI.UserConsentVerifierAvailability.available:
                    outputDiv.innerHTML = "<br/>Fingerprint verification is available.";
                    break;
                case Windows.Security.Credentials.UI.UserConsentVerifierAvailability.deviceBusy:
                    outputDiv.innerHTML = "<br/>Biometric device is busy.";
                    break;
                case Windows.Security.Credentials.UI.UserConsentVerifierAvailability.deviceNotPresent:
                    outputDiv.innerHTML = "<br/>No biometric device found.";
                    break;
                case Windows.Security.Credentials.UI.UserConsentVerifierAvailability.disabledByPolicy:
                    outputDiv.innerHTML = "<br/>Biometric verification is disabled by policy.";
                    break;
                case Windows.Security.Credentials.UI.UserConsentVerifierAvailability.notConfiguredForUser:
                    outputDiv.innerHTML = "<br/>The user has no fingerprints registered. Please add a fingerprint to the " +
                                    "fingerprint database and try again.";
                    break;
                default:
                    outputDiv.innerHTML = "<br/>Fingerprints verification is currently unavailable.";
                    break;
            }
        });
    }
    catch (ex) {
        outputDiv.innerHTML = "<br/>Fingerprint authentication availability check failed: " + ex.toString();
    }
}

지문 스캔에서 사용자 동의를 요청하려면 UserConsentVerifier.RequestVerificationAsync 메서드를 호출합니다. 지문 인증이 작동하려면 사용자가 이전에 지문 "서명"을 지문 데이터베이스에 추가한 상태여야 합니다. UserConsentVerifier.RequestVerificationAsync를 호출하면 지문 스캔을 요청하는 모달 대화 상자가 사용자에게 표시됩니다. 다음 이미지와 같이 모달 대화 상자의 일부로 사용자에게 표시되는 메시지를 UserConsentVerifier.RequestVerificationAsync 메서드에 제공할 수 있습니다.

지문 인증 모달 대화 상자

다음 예제에서는 지문 검증을 요청하고 결과와 함께 메시지를 반환하는 메서드를 보여 줍니다.

function requestConsent(userMessage) {
    if (!userMessage) {
        userMessage = "Please provide fingerprint verification.";
    }

    try {
        // Request the logged on user's consent via fingerprint swipe.
        Windows.Security.Credentials.UI.UserConsentVerifier.requestVerificationAsync(userMessage) 
        .then(
            function (consentResult) { 
                switch (consentResult) {
                    case Windows.Security.Credentials.UI.UserConsentVerificationResult.verified:
                        outputDiv.innerHTML = "<br/>Fingerprint verified.";
                        break;
                    case Windows.Security.Credentials.UI.UserConsentVerificationResult.deviceBusy:
                        outputDiv.innerHTML = "<br/>Biometric device is busy.";
                        break;
                    case Windows.Security.Credentials.UI.UserConsentVerificationResult.deviceNotPresent:
                        outputDiv.innerHTML = "<br/>No biometric device found.";
                        break;
                    case Windows.Security.Credentials.UI.UserConsentVerificationResult.disabledByPolicy:
                        outputDiv.innerHTML = "<br/>Biometric verification is disabled by policy.";
                        break;
                    case Windows.Security.Credentials.UI.UserConsentVerificationResult.notConfiguredForUser:
                        outputDiv.innerHTML = "<br/>The user has no fingerprints registered. Please add a fingerprint to the " +
                                        "fingerprint database and try again.";
                        break;
                    case Windows.Security.Credentials.UI.UserConsentVerificationResult.retriesExhausted:
                        outputDiv.innerHTML = "<br/>There have been too many failed attempts. Fingerprint authentication canceled.";
                        break;
                    case Windows.Security.Credentials.UI.UserConsentVerificationResult.canceled:
                        outputDiv.innerHTML = "<br/>Fingerprint authentication canceled.";
                        break;
                    default:
                        outputDiv.innerHTML = "<br/>Fingerprint authentication is currently unavailable.";
                        break;
                }
            });
    }
    catch (ex) {
        outputDiv.innerHTML = "<br/>Fingerprint authentication failed: " + ex.toString();
    }
}

관련 항목

UserConsentVerifier 샘플

UserConsentVerifier

Windows.Security.Credentials.UI

인증 및 사용자 ID