Wiki source code of SAML Server

Version 3.1 by Admin on 2020/01/18 13:44

Show last authors
1
2
3 {{id name="_GoBack"/}}SAML Server
4 SAML is setup on ONECount which can support both IDP and SP initiated logins. The main use of this saml is to provide authentication and authorization services for the SP while ONECount being IDP. We are using OPENSAML API to read the login requests and create SAML responses based on the authentication result. This document uses the following abbreviations.
5 SP (Service Provider) : The system which is having the services the user requests for. The Service provider would just render services based on the authentication information provided by IDP.
6 IDP (Identity Provider) : The system which manages the user details and the user privileges. The IDP would authenticate user and provide necessary information regarding the user to the SP.
7 SAML: Security Assertion Markup Language is an XML-based, open-standard data format for exchanging authentication and authorization data between an identity provider and a service provider. SAML is a product of the OASIS Security Services Technical Committee. This defines the way SP and IDP communication protocols and how to react to requests.
8 **SSO SERVICES:** In our ONECount we primarily use SAML for SSO Services across all the domains. The SSO services can be broadly divided into 2 types they are
9
10 * SP Initiated login
11 * IDP Initiated Login
12
13 **SP Initiated login:** In this type of login the service provider requests for authentication to the IDP on for the same site. In our setup the example for this is harbourside MEDED website login. In SP initiated login the SP needs to create SAML request and send into to ONECount. The onecount then authenticates the user and sends the required details to the SP back as SAML response.
14 **IDP Initiated login:** In this type of login the request for authentication would be by made by a partner site or third party site other than SP. In our setup the example is for ethos where the harbourside acts as partner site and has link to ethos websites where we authenticate the user and send required information to SP which is ETHOS in this context. In this type login is initiated by IDP to the SP.
15 **DataBase models:** we have 2 tables in onecount_super data base as these configurations are common for all the clients. WE populate these tables based on the saml meta data file of service provider and other configurations. The table names are
16
17 {{id name="OLE_LINK2"/}}
18
19 {{id name="OLE_LINK3"/}} onecount_saml_metadata and
20
21 {{id name="OLE_LINK4"/}}
22
23 {{id name="OLE_LINK5"/}}
24
25 {{id name="OLE_LINK6"/}} onecount_saml_relaystate_mapping and their structure is as follows.
26 onecount_saml_metadata
27
28 |=(((
29 **Column**
30 )))|=(((
31 **Type**
32 )))|=(((
33 **Comments**
34 )))
35 |(((
36 entity_id
37 )))|(((
38 varchar(400)
39 )))|(((
40
41
42 {{id name="OLE_LINK1"/}}The entity id of SP which we get in SAML Metadata file.
43 )))
44 |(((
45 soap_binding
46 )))|(((
47 text
48 )))|(((
49 The SOAP binding of SP which we get in SAML Metadata file.
50 )))
51 |(((
52 redirect_binding
53 )))|(((
54 text
55 )))|(((
56 The redirect binding of SP which we get in SAML Metadata file.
57 )))
58 |(((
59 certificate_encryption
60 )))|(((
61 text
62 )))|(((
63 The certificate encryption key of SP which we get in SAML Metadata file.
64 )))
65 |(((
66 certificate_signature
67 )))|(((
68 text
69 )))|(((
70 The certificate signature key of SP which we get in SAML Metadata file.
71 )))
72 |(((
73 logout_post_binding
74 )))|(((
75 text
76 )))|(((
77 The logout post binding of SP which we get in SAML Metadata file.
78 )))
79 |(((
80 logout_redirect_binding
81 )))|(((
82 text
83 )))|(((
84 The logout redirect binding of SP which we get in SAML Metadata file.
85 )))
86 |(((
87 post_binding
88 )))|(((
89 text
90 )))|(((
91 The post binding of SP which we get in SAML Metadata file.
92 )))
93 |(((
94 expiry
95 )))|(((
96 date
97 )))|(((
98 The expiry date of metadata of SP which we get in SAML Metadata file.
99 )))
100 |(((
101 xml_dump
102 )))|(((
103 longtext
104 )))|(((
105 The whole xml metadata as string.
106 )))
107 |(((
108 saml_id
109 )))|(((
110 int(11)
111 )))|(((
112 Unique primary for this table
113 )))
114 |(((
115 fields
116 )))|(((
117 varchar(400)
118 )))|(((
119 JSON format string of demographic fields of user the SP needs with onecount question ID as key and name the SP wants for this particular question.
120 Sample : {1:Email,226:Prefix,4:First name,218:Middle name,5:Last name,12:Postal code,98:Degree,234:Profession,242:Specialty,ocid:OCID}
121 )))
122 |(((
123 client_auth
124 )))|(((
125 varchar(400)
126 )))|(((
127 Client login URL to login page to which we send user for challenge questions when cookies are not found.
128 )))
129 |(((
130 appkey
131 )))|(((
132 varchar(200)
133 )))|(((
134 The app key for the client which we use to make requests to ONECount API.
135 )))
136 |(((
137 brand_info
138 )))|(((
139 varchar(40)
140 )))|(((
141 The brand information required for styling the login/lookup page.
142 )))
143
144
145 onecount_saml_relaystate_mapping\\
146
147 |=(((
148 **Column**
149 )))|=(((
150 **Type**
151 )))|=(((
152 **Comments**
153 )))
154 |(((
155 saml_relaystate_id
156 )))|(((
157 int(11)
158 )))|(((
159 Unique primary key for this table
160 )))
161 |(((
162 saml_id
163 )))|(((
164 int(11)
165 )))|(((
166 Foreign key from onecount_saml_mapping table
167 )))
168 |(((
169 relaystate
170 )))|(((
171 varchar(400)
172 )))|(((
173 Relay state pattern or SP website address sample education.annenberg.net
174 )))
175 |(((
176 client_id
177 )))|(((
178 int(11)
179 )))|(((
180 Client id of our client
181 )))
182
183
184 \\\\\\\\\\\\\\\\\\\\When ever we need a new client to use the saml when we configure these parameters from the metadata file and the conf paramaters they provide they should be good.
185 **Login Mechanism :** The total login process can be divided into 3 parts
186
187 * Login Request
188 * Authentication
189 * Login Response
190
191 Login Request: The login request needs to be a valid saml request.
192 SP intitiated login: In the case of the SP initiated login ONECount supports Post request with the request payload. We read the request by opensaml java api and extract the required parameters for authentication.
193 IDP Initiated login: In the case of IDP initiated login the partner site needs to have the relay state which is the url of the SP that they want to user to access. They also need to add a query parameter clientid which is used by the onecount to correctly identify the client- SP pair.
194 Login Mechanism:
195 The SAML Server relies on cookies for user identification. When the saml receives the login request that looks up the configuration form the database based on entity ID if its SP initiated or relay state and clientid. Then that checks for OCGT cookie. If the cookie is found then that searches the onecount_super database for the ocid of the user form OC_CLIENTS_TOKENS table based on the client id and ocgt value. If an entry is found that means that we are able to identify the user based on the oc_gt cookie.
196 If the cookie is not found or the user could not be identified based on oc_gt and clientid then the server is unable to accurately identify the user then the saml redirects the user to login/lookup page for further authentication.while redirectiong the user the whole url of partner site is URLENCODED and sent as return parameter to login/lookup page. When the user authenticates himself the login server sets the updated cookie for the user which is taken and searched in the database.
197 When the user is found the server makes a call to ONECount API to retrieve the user information. Once the user information is acquired the saml request is generated.
198 SAML Response:
199 The response is generated based on the configuration files using opensaml API. If that is SP initiated login then we have the extra parameter "InResponseTo" in the response which will have the unique request identifier which is used by the service provider to determine their internal state. In the request if the server receives any relay state then SAML server retains that and forwards the relay state without any modification. If it is IDP initiated login then the server will have the SP requested url as the relay state. In our setup we are using URL post binding to send the response to the SP.\\