简体   繁体   中英

how to allow access to web page only specific mobile app using user agent

I have created some php web pages for inserting webview & some json informations in an android app. And I want to protect my web data by allowing access to these web pages ONLY from my app , how is this possible ? I heard that this can be done by setting my own user agent in the app and catch it in my web page , but I don't know how to do this

Assuming that the connection between your app and the backend is via HTTPS, you could use client-side certificates to authenticate the caller (your app) to the backend server. Only if the caller provides the right certificate the transaction could move further.

Note that this is not unbreakable: someone who has access to your app can extract the certificate and replay it. This is not obvious to do so if you want a reasonable but not NSA grade solution it would be acceptable.

A simpler solution would be to send a hard-coded authentication token as part of the transaction, checked by the backend.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM