403.60 - 使用Azure移动应用程序验证Cordova的禁止错误

时间:2016-03-11 21:13:28

标签: cordova azure oauth-2.0 azure-web-sites azure-mobile-services

解决方案
Phonegap oauth2 redirect issue 身份验证适用于设备但不适用于Ripple 仍然试图弄清楚如何让它在Ripple上工作

初始问题
我正在按照教程创建一个针对Azure App Service进行身份验证的入门Cordova应用程序: https://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-cordova-get-started-users/https://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-how-to-configure-microsoft-authentication/

我可以直接浏览zumotest4.azurewebsites.net上的应用服务,但Cordova应用程序(由Azure Mobile App快速入门生成)失败。天蓝色移动服务电话client.login('microsoftaccount');会启动OAuth登录页面,但在提交凭据后,OAuth登录屏幕会保持打开状态,并显示空白屏幕。网络跟踪显示403回调的禁止故障。 Azure应用服务错误日志将错误报告为HTTP错误403.60 - 禁止。

Backend = .NET(C#)

未对请求进行身份验证时,服务器设置为“允许请求(无操作)”。待办事项控制器设置为[授权]。

    [Authorize]
    public class TodoItemController : TableController<TodoItem>
    {...

Microsoft注册的应用程序配置:

- 移动或桌面客户端应用:是

-Target domain:blank

-Restrict JWT签发:是

-Root domain:zumotest4.azurewebsites.net

- 重定向网址:

*https://zumotest4.azurewebsites.net/.auth/login/microsoftaccount/callback

*https://zumotest4.azurewebsites.net/.auth/login/microsoftaccount

*https://zumotest4.azurewebsites.net/.auth/login/done 

*https://zumotest4.azurewebsites.net

Cordova客户CSP: <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://login.windows.net https://login.live.com https://zumotest4.azurewebsite...; style-src 'self'">

Cordova客户端index.js:

function onDeviceReady() {
    client = new WindowsAzure.MobileServiceClient('https://zumotest4.azurewebsites.net');

    // Login to the service
    client.login('microsoftaccount')
        .then(function () {
            // BEGINNING OF ORIGINAL CODE

            // Create a table reference
            todoItemTable = client.getTable('todoitem');

            // Refresh the todoItems
            refreshDisplay();

            // Wire up the UI Event Handler for the Add Item
            $('#add-item').submit(addItemHandler);
            $('#refresh').on('click', refreshDisplay);

            // END OF ORIGINAL CODE

        }, handleError);
}

网络追踪:

姓名:https://zumotest4.azurewebsite..."%"3dc28004776f304afca14c71b77d660d8d_20160311125405"%"26redir"%"3d" -H "Accept-Encoding: gzip, deflate, sdch" -H "Accept-Language: en-US,en;q=0.8" -H "Upgrade-Insecure-Requests: 1" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36" -H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" -H "Referer: https://login.live.com/oauth20..."%"3A"%"2F"%"2Fzumotest4.azurewebsites.net"%"2F.auth"%"2Flogin"%"2Fmicrosoftaccount"%"2Fcallback&response_type=code&scope=wl.basic&state=nonce"%"3Dc28004776f304afca14c71b77d660d8d_20160311125405"%"26redir"%"3D" -H "Cookie: CompletionOrigin=http://localhost:4400; CompletionType=postMessage; Nonce=JpK4rfK4vvSKl3Mr6xhuJdy5b0xzu2nls5zL4ShiBrxVjw64e9n9/JXXhLlOeq3S8Pn9YFfV9G2RGowbFB4YZem5vCGwDWHV3vHoa0iT3/XvHHA9SAOD5AjlXxN3ffbk; AppServiceSessionMode=token; ARRAffinity=45469bcdd9e2de45e5ee43c5a6d02e5e7b574ac8ea3eb9b10e5cce208e5268b6" -H "Connection: keep-alive" -H "Cache-Control: max-age=0" --compressed

状态:403 - 禁止

输入:文档

发起人:https://zumotest4.azurewebsite..."%"3dc28004776f304afca14c71b77d660d8d_20160311125405"%"26redir"%"3d" -H "Accept-Encoding: gzip, deflate, sdch" -H "Accept-Language: en-US,en;q=0.8" -H "Upgrade-Insecure-Requests: 1" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36" -H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" -H "Referer: https://login.live.com/oauth20..."%"3A"%"2F"%"2Fzumotest4.azurewebsites.net"%"2F.auth"%"2Flogin"%"2Fmicrosoftaccount"%"2Fcallback&response_type=code&scope=wl.basic&state=nonce"%"3Dc28004776f304afca14c71b77d660d8d_20160311125405"%"26redir"%"3D" -H "Cookie: CompletionOrigin=http://localhost:4400; CompletionType=postMessage; Nonce=JpK4rfK4vvSKl3Mr6xhuJdy5b0xzu2nls5zL4ShiBrxVjw64e9n9/JXXhLlOeq3S8Pn9YFfV9G2RGowbFB4YZem5vCGwDWHV3vHoa0iT3/XvHHA9SAOD5AjlXxN3ffbk; AppServiceSessionMode=token; ARRAffinity=45469bcdd9e2de45e5ee43c5a6d02e5e7b574ac8ea3eb9b10e5cce208e5268b6" -H "Connection: keep-alive" -H "Cache-Control: max-age=0" --compressed

提前感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

在浏览器中进行身份验证需要一些额外的步骤。请参阅此GitHub问题中提到的解决方案:https://github.com/Azure/azure-mobile-apps-js-client/issues/81。如果有帮助,请告诉我。