Reputation: 4236
I have a site A, which embeds modules in an iframe B. The modules may be other-domain. The user has an authenticated session in A, and I want B to refuse to load unless the user has a valid session in A. B does not need to know anything beyond the fact that the user has an authenticated session with A. No session data is needed.
At the moment, neither A nor B are behind HTTPS, but I am looking to change that once I can convince the people upstairs to buy an SSL certificate.
So, I've thought of two quite different schemes to accomplish this in a secure fashion, but I am uncertain which of them will work better, so I am hoping to get some feedback here. Any help is appreciated!
?session=SESSION_ID
to B's URLA/verify?session=SESSION_ID
Upsides
Downsides
Upsides
Downsides
Upvotes: 3
Views: 884
Reputation: 64536
Option 3
A
generates a random hash and stores it in a database table along with the session ID (two fields). A
passes the hash to each URL for B
like `B/?hash=x'
A
checks if the hash matches any in the database table and also checks if the session ID is still authenticated (might have logged out or expired) then tells B
if it's good or not. Like A/verify?hash=x
.
As you say, B
doesn't need to know anything other than if it's authenticated or not.
This way no session ID is passed around in the URL which again as you say is not ideal.
Upvotes: 2