开发者

OAuth security issues on an Android mobile phone?

开发者 https://www.devze.com 2023-02-26 11:21 出处:网络
I am writing a client application that will run on Android phones that will interact with an OAuth server on the user\'s behalf.I have the OAuth server side code running on my web server for maintaini

I am writing a client application that will run on Android phones that will interact with an OAuth server on the user's behalf. I have the OAuth server side code running on my web server for maintaining the OAuth session details while handshaking with the remote OAuth server. Now I am wrangling with how to best handle the client side considerations on the smart phone.

Let's assume for this question that I have, in the past, received an access token granted to me by the remote OAuth server after they logged the user in and the user granted my application access rights. Let's also assume it is a "good until revoked" access token.

The main concern of course is implementing something that does not leave the user at risk. The simplest method would be to have my web server return the access token to my client code on the smart phone in encrypted form, and simply store that encrypted token in the user's local storage. Or for even tougher security, return my own encrypted unique identifier that my client code on the smart phone passes in with each request. My web server could then decrypt the received ID, and lookup the most recent access token in a local database. This seems pretty secure except in the case of the user losing the phone. I guess I could implement something like the "remember me" option on browser's so if the user does not check it then a new re-authorization session would be triggered every session.

If my application were dealing with financial information then I would not even consider a "remember me" option, but the application behind the remote OAuth server is more on the level of sensitivity of Twitter or Flickr.

My questions are:

  • Is my proposed access token management and OAuth handling scheme sound and secure enough for the application I am describing?
  • Are there better methods? If so what?
  • Any other thoughts or comments y开发者_Python百科ou might have on OAuth and mobile phones?

** UPDATE - found these very helpful thread in the related questions list after this post was published:

OAuth secrets in mobile apps

Can I avoid baking my Twitter API consumer secret into my iPhone app binary?

** UPDATE 2 - If you switch from a Sessions OAuth store to a database store like MySQL, remember to register the server for the given consumer key and user ID or you will get an error when you call requestRequestToken. This web page concerning the ELance API has a nice example (Look for the section titled "Step 2: Get Request Token" and look for the snippet with the updateServer call):

http://www.elance.com/p/api/examples/oauth/php

You'll have to adapt the example for your own remote OAuth server needs.

-- roschler


I have some experience working with Yandex (No. 1 Russian search engine) OAuth servers. This is how they do it..

OAurh server accessed only by HTTPS. Thus, token is transferred by the network in encrypted manner. As it is HTTPS - client can check servers validity via certificates checking.

Also, they recommend to store received access token in encrypted way. As for me, i have my own storage implementation, which stores access token in 3DES-encrypted way in SharedPreferences. Key to 3DES encryption is a users selected "PIN-code". Each time application starts it is requesting a PIN and then trying to decrypt token.

You can look at my library implementing access to one of the Yandex serices (using OAuth to grant access).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号