3 ms·
First, I think the idea of you making API requests using your users' credentials is a bad one from the start. If the third party in question wants to allow req
by cperciva 18y ago
First, I think the idea of you making API requests using your users' credentials is a bad one from the start. If the third party in question wants to allow requests-on-behalf-of, they should provide a proper API for it; if not, you shouldn't be working against their wishes by impersonating your users.
That said, if you really really have to do this: Have your users provide you with their username and password; generate a random symmetric encryption key; store (username, encrypted password) on your systems and send (username, encryption key) to the user as a cookie.
This will give you safety against an attacker who can steal your database or the user's cookies; it won't give you any protection against an attacker who can steal both of those (that would impossible), nor will it give you any protection against an attacker who controls your server at a time when a user tries to use your service (again, that would be impossible).
But I still think this is a really bad idea.
- geuis 18y agoThanks for the symmetric key idea. Yah, I don't like the idea of storing a user's credentials for a 3rd party service. Unfortunately the 3rd party requires http auth to access their api, and the app I'm working on interfaces with an individual's account. I wish the service had something like Flickr does for their API. The user could allow my app access 1 time, and it could work seemlessly without having to throw u/p back and forth.
- jrockway 18y agoFirst, I think the idea of you making API requests using your users' credentials is a bad one from the start. If the third party in question wants to allow requests-on-behalf-of, they should provide a proper API for it; if not, you shouldn't be working against their wishes by impersonating your users. This is true, but unfortunately we live in the real world, and hacks are sometimes necessary. Look at Mint.com, for example. Give some site all your banking details? WHOA THERE. But it turns out the service is very useful, and it works with pretty much every bank. If they had waited for proper APIs to exist, someone else would have beaten them to market.