Wednesday, March 7, 2012

Single-Sign-On using SAML

Overview

In a simple standalone web application, user authentication is implemented locally. This means the web application by itself is fully responsible for managing, validating and enforcing authentication. However in an enterprise setup where users need to work across multiple applications often from diverse vendors, this simple approach will be cumbersome. If each of the applications have their own list of user credentials, with possibly different usernames and passwords, users will have to remember multiple usernames and passwords and/or provide these credentials multiple times to get their work done using different applications.

Federated authentication solves this problem elegantly through SSO (Single-Sign-On) by managing the authentication credentials centrally and allowing individual applications to do delegate user authentication to the federation server without duplicating the authentication implementation and management. Also the user is saved from the overhead of entering authentication credentials more than once.

SAML (Security Assertion Markup Language) is a set of specifications that enable federated security (including authentication).

SAML Concepts

Identity provider (IDP): A central system responsible for managing and verifying user credentials. Behind the scene, the IDP provider may use mechanisms like Active Directory or LDAP (Light Weight Directory Access Protocol) to perform the actual authentication

Service Provider (SP): SP refers to one or more systems providing resources to users. The service provider delegates authentication requests to the IDP and verifies user authentication through security tokens like cookies and session identifiers.

SAML Assertion: An XML message conforming to SAML specification used to transfer requests and responses between systems configured to use SAML SSO.



1.    User tries to access an application resource from the service provider (SP)
2.1 If the user is already authenticated (verified through a session cookie), the resource provider returns the requested resource to the user.
2.2 If not already authenticated the service provider redirects the user to the identity provider login page.
3.    User is redirected to the identity provider login page
4.    User enters authentication credentials in the identity provider login page and submits it
5.1 Identity provider authenticates the users. If authentication is not successful, the IDP returns and error page or error message.
5.2 If authentication is successful IDP creates an HTTP request embedded with a SAML assertion (depicting successful authentication) against a pre-configured SP URL.
6.    The browser submits the redirect request from IDP containing SAML assertion to the SP.
7.    If SAML assertion is valid, SP creates a session and returns the requested resource along with a session cookie.

Support for SAML based SSO in typical web applications

The following are the common SAML use cases:
1) Federated SSO using an external IDP using SP initiated login.
2)  IDP initiated logout.
3) SP initiated logout.

The SAML assertions from IDP can be sent through HTTP(S) GET or HTTP(S) POST parameters. Due to possible URL length limits in some browsers, it’s preferable to use HTTP POST for all SAML assertions. SAML assertions are usually send as Base64 encoded strings.

Update 30-Dec-2015: Sample SAML SSO Java code at https://github.com/jubyrajan/saml-auth

Thursday, October 20, 2011

The fall of the mighty: On Gadaffi's death

A man who ruled over an entire country for 42 years like God, was dragged out of a drainage pipe and killed in cold blood.

However good or bad a ruler he was, its sad to see someone who lived like a king for 42 years being brought down to a state wherein he begs for his life on the streets to a bunch of hooligans. Some of his sons were also killed in cold blood.

The uncivilized nature of mob justice was in full display.


Saddam Hussein is a similar name that would come immediately to one's mind. But he at least had the chance of a trial.

Thursday, October 13, 2011

Dennis Ritchie (September 9, 1941 – October 12, 2011)

Another great pioneer passes away.  Just a few days after the death of Steve Jobs, Dennis Ritchie the man who gave us C and one of the great influences in Unix, passed away. May be less famous than Steve Jobs for non-techies, but in no way lesser.

Thursday, October 6, 2011

Steve Jobs (Feb 24, 1955 – Oct 5, 2011)

The irreplaceable loss of a business visionary, innovator, creative genius and thought leader.

Friday, September 2, 2011

Setting up Reliance Netconnect on Linux

It can be a very confusing and frustrating to setup wireless broadband like Tata Photon, Reliance Netconnect, etc. on Linux. Here's my experience on successfully setting up Reliance Netconnect on Fedora 15 using the wvdial PPP utility. The same could work for Tata Photon or any other modem based Internet service.

The concept is fairly simple. All such services work through a modem connected to the computer via the USB interface. We need to setup a PPP connection to the service provider via the modem. the wvdial command is more intelligent wrapper over the basic ppp utility.

1) Connect the USB Modem (Huawei EC 150 in my case)
2) Open terminal as root (or run the commands using sudo)
3) Type wvdialconf on the command prompt. This will create a default configuration file /etc/wvdial.conf with the following contents
[Dialer Defaults]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Modem Type = Analog Modem
Phone = Phone
ISDN = 0
Username = Username
Password = Password
Modem = /dev/ttyUSB0
Baud = 9600
Note: The values for some of the properties might be different based on your modem type

4) Modify /etc/wvdial.conf as follows:
[Dialer Defaults]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Modem Type = Analog Modem
Phone = #777
ISDN = 0
Username = your MDN number
Password = your MDN number
Modem = /dev/ttyUSB0
Baud = 9600

5) Type wvdial on the command prompt. By default it takes the setting from  /etc/wvdial.conf if required you could place this file anywhere and pass it as the first argument to wvdial.
[root@juby juby]# wvdial
--> WvDial: Internet dialer version 1.61
--> Initializing modem.
--> Sending: ATZ
ATZ
OK
--> Sending: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
OK
--> Modem initialized.
--> Sending: ATDT#777
--> Waiting for carrier.
ATDT#777
CONNECT
--> Carrier detected.  Waiting for prompt.
~[7f]}#@!}!}!} }8}"}&} } } } }#}$@#}%}&"7Hj}'}"}(}"e[12]~
--> PPP negotiation detected.
--> Starting pppd at Fri Sep  2 10:38:55 2011
--> Pid of pppd: 1836
--> Using interface ppp0
--> pppd: <
--> pppd: <
--> pppd: <
--> local  IP address 115.242.244.59
--> pppd: <
--> remote IP address 220.224.141.145
--> pppd: <
--> primary   DNS address 202.138.103.190
--> pppd: <
--> secondary DNS address 202.138.117.60
--> pppd: <

6) Add the primary and secondary DNS addresses to /etc/resolv.conf with the following entries:

nameserver 202.138.103.190
nameserer 202.138.117.60


7) Make sure that Internet traffic is routed through the PPP interface using ifconfig command.
If there are other interfaces (say LAN) turn them off by typing ifconfig if-name down
8) Ensure that the default traffic handler goes through the PPP interface. Type route on the command prompt. You should see something as follows:

[root@juby etc]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
220.224.141.145 *               255.255.255.255 UH    0      0        0 ppp0
192.168.122.0   *               255.255.255.0   U     0      0        0 virbr0
default         *               0.0.0.0         U     0      0        0 ppp0

The default entry ensures that Internet traffic is routed through the PPP interface.

Till step 5) is usually straightforward and the procedure is explained in many other articles and blogs. However many people typically face problems from  step 6) onwards, wherein inspite of having their modem setup and connected, they are not able to access the Internet.


Note: Please see the man pages for wvdial, wvdialconf, ifconfig, route for the details of these commands.

This approach should work on most Linux distros and versions provided wvdial is installed and the system is able to detect the USB dongle.