InHouse authorization on Azure Easy Tables

故事扮演 提交于 2019-12-11 14:36:26

问题


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:


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.



来源:https://stackoverflow.com/questions/38067636/inhouse-authorization-on-azure-easy-tables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!