来自凭证选择器的密码

时间:2013-09-05 15:37:34

标签: authentication windows-8 windows-store-apps winjs

我在我的应用程序中使用Credential Picker进行用户身份验证。我的数据库中的身份验证详细信息是字符串格但Credential Picker传递的密码是加密形式(默认情况下是协商身份验证协议),那么如何解密该密码以便我可以匹配我的数据库密码。 使用DB存储密码进行密码匹配的最佳和正确的解决方案是什么? 下面是代码片段:

function launchCredentialPicker() {
    Windows.Security.Credentials.UI.CredentialPicker.pickAsync("My Target", "My Message", "my Caption").then(function (results) {

        var domainName = results.credentialDomainName;
        WinJS.Application.sessionState.Username = results.credentialUserName;
        WinJS.Application.sessionState.Password = results.credentialPassword;
        WinJS.Application.sessionState.RememberPassword = (results.credentialSaveOption === Windows.Security.Credentials.UI.CredentialSaveOption.hidden) ? "Hidden" :
                               ((results.credentialSaveOption === Windows.Security.Credentials.UI.CredentialSaveOption.selected) ? "Selected" : "Unselected");

    });
}

1 个答案:

答案 0 :(得分:3)

您需要使用CredentialPickerOptions对象PickAsync CredentialPicker方法。配置CredentialPickerOptions以使用基本身份验证后,您将能够看到用户输入的密码。

var options = new Windows.Security.Credentials.UI.CredentialPickerOptions();
options.authenticationProtocol = Windows.Security.Credentials.UI.AuthenticationProtocol.basic;

Windows.Security.Credentials.UI.CredentialPicker.pickAsync(options).then(/* */);