Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CAS vs. SAML vs. OAuth2

Before you put me down for asking too basic a question without doing any homework, I'd like to say that I have been doing a lot of reading on these topics, but I'm still confused.

My needs seem simple enough. At my company, we have a bunch of Ruby on Rails applications. I want to build an SSO authentication service which all those applications should use.

Trying to do some research on how to go about doing this, I read about CAS, SAML and OAuth2. (I know that the "Auth" in OAuth stands for authorization, and not authentication, but I read enough articles saying how OAuth can be used for authentication just fine - this is one of them.)

Could someone tell me in simple terms what these 3 are? Are they alternatives (competing)? Is it even right to be comparing them?

And there are so many gems which all seem to be saying very similar stuff:

  • https://github.com/rubycas/rubycas-server and https://github.com/rubycas/rubycas-client
  • https://github.com/nbudin/devise_cas_authenticatable
  • https://github.com/onelogin/ruby-saml
  • CASino and https://github.com/rbCAS/casino-activerecord_authenticator
  • And I am sure there are hundreds of OAuth related gems.

I just want a separate Rails application which handles all the authentication for my other Rails apps.

Note: I do not want to allow users to use their Google / Facebook accounts to login. Our users already have accounts on our site. I want them to be able to login using that account once and be able to access all our apps without signing in again. Signing out in any app should sign them out of all apps.

UPDATE

I have come across these two OAuth solutions:

  • http://dev.mikamai.com/post/110722727899/oauth2-on-rails
  • http://blog.yorkxin.org/posts/2013/11/05/oauth2-tutorial-grape-api-doorkeeper-en/

They seem to be describing something very similar to what I want. But I haven't found any guide / blog post / tutorial showing how to do this with SAML / CAS.

Suggestions welcome.

UPDATE 2

More details about our use-case.

We do not have any existing SAML architecture in place. Primarily, it is going to be OUR users (registered directly on our website) who are going to be accessing all our applications. In the future, we may have third-party (partner) companies calling our APIs. We may also have users from these third-party (partner) companies (registered on their websites) accessing our apps.

like image 621
Anjan Avatar asked Mar 14 '15 19:03

Anjan


People also ask

What is the difference between CAS and SAML?

CAS and SAML have their own unique benefits. SAML SSO, however, is the clear winner in terms of a more 'Modern' Industry Standard Protocol. SAML makes use of digital signatures to ensure security throughout the entire process and simplifies the integration for a more streamlined, easier to troubleshoot experience.

Is OAuth2 same as SAML?

Primarily, SAML 2.0 is designed to authenticate a user, so providing user identity data to a service. OAuth 2.0 is designed as an authorization protocol permitting a user to share access to specific resources with a service provider.

Does CAS use SAML?

CAS can act as a SAML2 identity provider accepting authentication requests and producing SAML assertions.

Does CAS support OAuth2?

OAuth/OpenID Authentication. Allow CAS to act as an OAuth/OpenID authentication provider. Please review the specification to learn more.


2 Answers

CAS-Server:

A stand-alone central login page where the user enters their credentials (i.e. their username and password).

CAS supports the standardized SAML 1.1 protocol primarily to support attribute release to clients and single sign-out.

(a table in a SQL database, ActiveDirectory/LDAP, Google accounts, etc.) Full compatibility with the open, multi-platform CAS protocol (CAS clients are implemented for a wide range of platforms, including PHP, various Java frameworks, .NET, Zope, etc.) Multi-language localization -- RubyCAS-Server automatically detects the user's preferred language and presents the appropriate interface.

enter image description here

SAML : Security Assertion Markup Language is an XML-based, open-standard data format for exchanging authentication and authorization data between parties, in particular, between an identity provider and a service provider. SAML authorization is a two step process and you are expected to implement support for both.

enter image description here

OAuth 2.0:

The OAuth 2.0 authorization framework enables a third-party application to obtain limited access to an HTTP service, either on behalf of a resource owner by orchestrating an approval interaction between the resource owner and the HTTP service, or by allowing the third-party application to obtain access on its own behalf.

enter image description here

Important Note :

SAML has one feature that OAuth2 lacks: the SAML token contains the user identity information (because of signing). With OAuth2, you don't get that out of the box, and instead, the Resource Server needs to make an additional round trip to validate the token with the Authorization Server.

On the other hand, with OAuth2 you can invalidate an access token on the Authorization Server, and disable it from further access to the Resource Server.

Both approaches have nice features and both will work for SSO. We have proved out both concepts in multiple languages and various kinds of applications. At the end of the day OAuth2 seems to be a better fit for our needs (since there isn't an existing SAML infrastructure in place to utilize).

OAuth2 provides a simpler and more standardized solution which covers all of our current needs and avoids the use of workarounds for interoperability with native applications.

When should I use which?

1.If your usecase involves SSO (when at least one actor or participant is an enterprise), then use SAML.

2.If your usecase involves providing access (temporarily or permanent) to resources (such as accounts, pictures, files etc), then use OAuth.

3.If you need to provide access to a partner or customer application to your portal, then use SAML.

4.If your usecase requires a centralized identity source, then use SAML (Identity provider).

5.If your usecase involves mobile devices, then OAuth2 with some form of Bearer Tokens is appropriate.

enter image description here

Reference 1,Reference 2,Reference 3

like image 131
Tharif Avatar answered Oct 11 '22 14:10

Tharif


If you need to authenticate for LDAP or ActiveDirectory then a solution like one of the CAS gems you mentioned above is right for you (RubyCAS, CASino).

If you can afford it, one of the commercial vendors (like Okta) is your best option because they will stay on top of security patches and manage your authentication needs for you. In particular, if you have to support ActiveDirectory, they've already implemented it.

OAuth is most useful for third party authentication, though it can do SSO. So if you wanted to support Google / Facebook logins or be a third party authenticator then it's a great choice. Since you don't want to support Google / Facebook then OAuth is probably not what you want.

If you are only intending to use HTTP POST for your SSO needs then the ruby-saml gem could be the way to go. You would have to implement your own Identity provider and add a service provider component to all your websites (possibly in the form of a gem.) Part of what you would need is a rails api to act as your identity provider. This gem helps support writing API's in rails.

EDIT

You mention the possibility that future third party users might be logging on to your site. This changes your calculus away from rolling your own ruby-saml solution.

The best way to share your authentication API is to implement an OAuth layer. Doorkeeper is a popular solution and is fast becoming the standard for Rails authentication. It's community support, flexibility and ease of use make it the best way to go for a consumable authentication API.

Railscast for implementing doorkeeper

like image 39
Uri Mikhli Avatar answered Oct 11 '22 14:10

Uri Mikhli