I develop SSO system based on OAuth2.
I have 3 services:
SSO identity provider which contains Users and OAuth2 server - http://sso.idp.loc
SSO service provider with front-end part on Angular - http://sso.sp-angular.loc
- SSO service provider (casual website) - http://sso.sp-web.loc
Service providers check every request access token issued by identity provider.
Mechanism is next:
- Go to any serivce provider and press login
- Redirect to sso.idp.loc/login_check to check credentials (from cookies).
- If not authorized - go to sso.idp.loc/login.
- After logging in - set cookies for identity provider and redirect to target service provider with these cookies in get parameter.
- Set new cookies from get parameter for service provider and redirect to target path.
- If suddenly authentification is failed on service provider - go to sso.idp.loc/login_check with target path.
Cookies contain oauth access and tokens.
Everyting is fine while access token is valid. Once access token expires service prodider goes to sso.idp.loc/login_check and checks again access token and then tries to get new once using refresh token. If success then new creadentials is set to sso.idp.loc and service provider. Let's say is happened on sso.sp-web.loc.
Here I have several problems:
- Then another service provider sso.sp-angular.loc does not know that credentials are changed and next request will redirect to sso.idp.loc/login_check (it can be sorted out by sending request second time).
- When user is editing form on sso.sp-web.loc and token has become expired then submit will fail.
- How to manage ajax calls when token expired?
Should be consideried a fact that access token can be changed at any time.
Probably something is wrong in my system. I will be glad to here any solutions.