InHouse authorization on Azure Easy Tables

2019-07-25 06:53发布

We are using the sync feature of the Azure Easy tables from our iOS App. We have implemented our own Authentication and Authorization in our system. I have done it for Easy APIs. I want to extend the same logic on Easy Tables sync also. I am not sure how to add this logic to easy tables data changes.

Any pointers would be highly appreciated.

1条回答
\"骚年 ilove
2楼-- · 2019-07-25 07:15

Technically, this is just as easy as Easy APIs. Your authentication / authorization mechanism must produce a JWT with a known audience, issuer and signing secret that you return to your client. Your client places the JWT that is received in the client.currentUser.mobileServicesAuthenticationToken (the actual name of this property varies based on client due to capitalization rules). Once this is done, the client will submit the token during each request.

In your backend, you need to set the auth setting for your server to something new. In Easy Tables, this involves editing the main file and adjusting the call that creates the zumo server. Look for code in the app.js file that looks like this:

var mobile = azureMobileApps({
    // Explicitly enable the Azure Mobile Apps home page
    homePage: true
});

Make it look like this:

var mobile = azureMobileApps({
    homePage: true,
    auth: {
        audience: "the-aud-field-from-your-JWT",
        issuer: "the-iss-field-from-your-JWT",
        secret: "the-secret-used-to-sign-the-JWT"
    }
};

Reference: http://azure.github.io/azure-mobile-apps-node/global.html#authConfiguration

There is a little gotcha in terms of the secret. This value is fed into the jsonwebtoken decoder directly, so you may need to convert the secret you use into a Buffer, per the jsonwebtoken instructions.

查看更多
登录 后发表回答