I have searched the forum for some resources:
- Security of Token Based Authentication
- Is token based authentication secure when
- Implementing a token authentication
I am bouncing around ideas on implementation of single sign-on / token based authentication process. Roughly, requirement would be:
- User web app / mobile app / mobile web, etc
- System 1: User info and login information, generate token and provide some services (eg.
getUserData
) - System 2: An external party that has control over user specific data
- System 3: Yet another external party like System 2
- User need to only sign in once at System 1, and then able to communicate with System 2 and System 3
Think about bank, or something like Mint.com, after initial setup, user can sign in once through Mint which then have access to go to your banks (and possibly multiple banking institutions) - thus gaining access to different systems with a single sign in. However, in my case it will be more than just read-only access that Mint.com is doing.
My initial thought roughly looks like this:
User Sign In ----> System 1, login verification generate token for itself (call it token1)
System 1 ---> generate token and pass it to System 2 (call it token2)
System 1 ---> generate token and pass it to System 3 (call it token3)
System 1 ---> return [token1, token2, token3]
From here, user (ie. the app or site, etc) have 3 tokens that it can use to communicate. If user need to execute action / retrieve data from System 1, it will pass in token1 with the request, etc with System 2 and System 3
Is this approach make sense?
There are of course security concern around this - what if the token is stolen somewhere along the way and now somebody with that token can execute actions on the system the token is for - obviously, this would be bad for things like banking system.
How does the System verify that the request sender that that give the token actually is the legitimate user the token was generated for?
One thought is 2nd authentication level, ie. with every request the user make, it needs to enter a special code (eg. like your bank card PIN) to go along with the token in the request - but doesn't this get annoying? Every request, user has to enter a PIN.
Thoughts and comments would be greatly appreciated.
EDIT: I already looked at OAuth ... As far as my understanding goes, you need to implement an OAuth provider that generates the token and allow you to use it with the OAuth provider itself, in other words, the OAuth provider is System #1 - but how can I make System 2 and 3 accepts that OAuth token as well? Or may be I misunderstood OAuth.
Also, even if using OAuth will work with the way I want it (System 1, System 2, System 3, etc), the question remains: What if an external malicious party gain access to that token? How can I identify to make sure the one using the token is the authorized party?