Setting up js azure app service custom login authentication

I started implementing 2 years ago my Basic Authentication in Azure Mobile Service with node.js to use it in my jQuery / cordova appery.io app. I have a database with users, passwords, etc., as well as a node.js login username that generates a valid jwt, for example:

http://www.thejoyofcode.com/Exploring_custom_identity_in_Mobile_Services_Day_12_.aspx

http://chrisrisner.com/Version-1-of-the-Mobile-Services-JWT-token-has-been-deprecated

But now I have migrated to the azure app service and have no idea how to implement custom auto-text with javascript.

In the examples above:

"ISS": "urn: Microsoft: Windows-blue: Zumo", "Faith": 2, "AUD": aud,

But I read that "aud" and "iss" should be my azure site and "sub" my own userId to generate a valid jwt in my custom auth to use in azure. Right?

https://shellmonger.com/2016/04/08/30-days-of-zumo-v2-azure-mobile-apps-day-5-custom-authentication/

The token is important. There are some requirements for using third-party tokens with the Azure Mobile App: It must follow the Json Web Token format User ID must be in subject (sub) Audience (audi) and issuer (iss) must be known and configured

I am calling my API login with an ajax message and I get a valid JWT token ( http://jwt.io ), but I don’t know, t know the correct process to log in and use azure services because I don’t know how to use it correctly in my application. I changed MobileServices.Web.min.js to azure-mobile-apps-client.js in the app. https://github.com/Azure/azure-mobile-apps-js-client

Can I use the jwt token generated in azure node.js, or exchange it for a session token and use the client.login () JS SDK method?

EDIT: I see the light is being added again to the ajax POST           headers: {'X-ZUMO-AUTH': usuarioToken},

So my "authenticated users" api is working with the old MobileServices.Web.min.js again! It also works great with the invokeApi method:

var mobileClient = new WindowsAzure.MobileServiceClient(urlApp,keyApp);
mobileClient.currentUser = {
    userId: myCustomUserId,
    mobileServiceAuthenticationToken: myCustomToken
};
mobileClient
    .invokeApi('data', {
            method: 'POST',
            headers: {'X-ZUMO-AUTH': myCustomToken},
            body: JSON.stringify(theData)
        }) //end invokeApi
    .done(
        function (response) {
            alert(response);
        },
        function (error) {
            alert("error"));
        }
    ); //end done

      

The generated mobileClient contains the following data:

mobileClient= {"applicationUrl":"https://xxx.azure-mobile.net/","applicationKey":"hGhzxxx","version":"ZUMO/1.2 (lang=Web; os=--; os_version=--; arch=--; version=1.2.21003.0)","currentUser":{"userId":"Custom:25F600BB-xxxx-xxxx-xxxx-8329BCCF31D2","mobileServiceAuthenticationToken":"ey__rest of jwt token"},"_serviceFilter":null,"_login":{"_loginState":{"inProcess":false,"cancelCallback":null},"ignoreFilters":true},"push":{"_apns":null,"_gcm":null,"_registrationManager":null}}

      

I will try again with new azure-mobile-apps-client.js Any comments would be appreciated

+3


source to share





All Articles