I'm working on an architecture of a distributed system, basically in ruby (rails, sinatra, etc).
I has several pure API only components, say API_C1, API_C2, API_C3. It has several web client applications, say Portal1, Portal2 and some native client application, say Native1.
Requirements:
- SSO for all web clients (Portal1, Portal2), centralized authentication.
- All API components should expose their API with authorization.
- Centralized API authorizarion.
I did several POCs to try some options but still don't have a full picture.
I tried rubycas server for SSO. It works pretty well. I consider using java cas implementation if necessary.
Centralized API authorization is rather tricky for me. I tend going OAuth2 way but have some questions:
- Is it possible to have centralized OAuth provider serving all API compoments? How it should work then and what libs/gems to use?
- How can I make my web apps (Portal1 and Portal2) trusted by default. I don't want a user to authorize access for trusted applications.
For native client apps (non web environment) I want to support 2 legs OAuth. Is it correct choice? Is it possible to have both 3 legs and 2 legs working?
How user creds are transformed into oauth token? Suppose the following use case:
- user logs in into Portal1 (via CAS server) and opens some page
- Portal1 backend server should pull data from API_C1 and API_C2 to show the page. How to authorize API here?
I have some thoughts like having API components under the same SSO CAS session. This is kind of allows my scenario 4) resolved, nothing to code here. But using session for APIs is a bad practice and how then to mix session and OAuth authorization for APIs?
Please, point me right direction. May be there are some other options to do everything like customized OpenId or OAuth providers to support SSO?