{"id":142,"date":"2017-01-27T10:01:40","date_gmt":"2017-01-27T10:01:40","guid":{"rendered":"http:\/\/www.infotheme.in\/blog\/?p=142"},"modified":"2017-01-27T10:01:40","modified_gmt":"2017-01-27T10:01:40","slug":"create-single-sign-on-system-in-php","status":"publish","type":"post","link":"https:\/\/infotheme.net\/blog\/create-single-sign-on-system-in-php\/","title":{"rendered":"How to Make Single Sign On System (SSO) Using Php &#8211; One Login for Multi Sites"},"content":{"rendered":"<p>Google having one login system for all of their own products as Youtube, Gmail and etc. So as every website owner want this type of single login system in their multi websites. As many extensions and scripts are available, but they are li&#8217;l bit costly. So here i have decided to share about <strong>How to make Google Style <a href=\"https:\/\/en.wikipedia.org\/wiki\/Single_sign-on\" target=\"_blank\" rel=\"nofollow noopener\">SSO<\/a> (Single Sign-On) System using php<\/strong>. You can implement this free solution in your wordpress, joomla, magento and drupal hosted website. We also call this solution one login for multi-websites or multi domains. Here we will learn how we can create a single session and access all websites by just one time login. But Before starting a code portion of this tutorial, i want to share some information about SSO.<\/p>\n<figure id=\"attachment_498\" aria-describedby=\"caption-attachment-498\" style=\"width: 600px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" class=\"size-full wp-image-498\" src=\"http:\/\/www.infotheme.in\/blog\/wp-content\/uploads\/2016\/12\/SSO-IN-PHP-Insbyrah.jpg\" alt=\"How to Make SSO Single Sign On System In Php\" width=\"600\" height=\"450\" \/><figcaption id=\"caption-attachment-498\" class=\"wp-caption-text\">How to Make SSO Using Php<\/figcaption><\/figure>\n<div id=\"toc_container\" class=\"no_bullets\"><p class=\"toc_title\">Contents<\/p><ul class=\"toc_list\"><li><a href=\"#What_is_SSO_Single_Sign-On_System\"><span class=\"toc_number toc_depth_1\">1<\/span> What is SSO (Single Sign-On System) ?<\/a><\/li><li><a href=\"#What_Is_Single_Sign_Off_SSO_System\"><span class=\"toc_number toc_depth_1\">2<\/span> What Is Single Sign Off (SSO) System ?<\/a><\/li><li><a href=\"#What_security_issue_may_occur\"><span class=\"toc_number toc_depth_1\">3<\/span> What security issue may occur ?<\/a><\/li><li><a href=\"#How_to_Make_Single_Sign_On_SSO_and_Single_Sign_Off_System_in_PHP\"><span class=\"toc_number toc_depth_1\">4<\/span> How to Make Single Sign On (SSO) and Single Sign Off System in PHP<\/a><ul><li><a href=\"#What_is_my_Methodology_to_Make_it_Perfect_Easy_SSO\"><span class=\"toc_number toc_depth_2\">4.1<\/span> What is my Methodology to Make it Perfect &amp; Easy SSO :<\/a><\/li><li><a href=\"#How_to_Make_SSO_In_PHP_Integration\"><span class=\"toc_number toc_depth_2\">4.2<\/span> How to Make SSO In PHP &amp; Integration:<\/a><\/li><\/ul><\/li><li><a href=\"#Conclusion_8211_SSO_System_In_PHP\"><span class=\"toc_number toc_depth_1\">5<\/span> Conclusion &#8211; SSO System In PHP<\/a><\/li><\/ul><\/div>\n<h2><span id=\"What_is_SSO_Single_Sign-On_System\">What is SSO (Single Sign-On System) ?<\/span><\/h2>\n<p>SSO is an access control property where a user login with a single user id and password to get access of different &#8211; different but connected systems, without using different credentials for each system. It accomplished by LDAP ( Lightweight Directory Access Protocol) and LDAP database. Doing this thing possible and easy but keep in mind all domain should have same DNS (Domain Name Server). It&#8217;s a easy and reliable way to logins into different system by just one login.<\/p>\n<h2><span id=\"What_Is_Single_Sign_Off_SSO_System\">What Is Single Sign Off (SSO) System ?<\/span><\/h2>\n<p>SSO (Single Sign On) system have another property which called as Single Sign Off system, the property have a facility of single sign off or logout, means if user sign our from one system, user will automatically signed off from all systems or websites. At this moment on web there are too many services which provides one login system but all website don&#8217;t have integration of their api. Such as if you want singe sign on system using facebook, you need to integrate facebook login api to do this task.<\/p>\n<h2><span id=\"What_security_issue_may_occur\">What security issue may occur ?<\/span><\/h2>\n<p>As we are working on an important part of user of any website or\u00a0system. So we need to do care about few things on it, because user data is much important for all of website users and owners. So if you are a programmer\u00a0you need to do care about website and user data. According to a report of march 2012 a vulnerability disclosed about phishing which was named as &#8220;Covert Redirect&#8221;. So after reading this\u00a0vulnerability I wanna say you something here if you are generating a ticket or TGT (Ticket Granting Ticket) to access and authenticate credentials of user so don&#8217;t return too much data of users. Just make a private session for each user by this\u00a0ticket. So we will care about this thing in our code.<\/p>\n<h2><span id=\"How_to_Make_Single_Sign_On_SSO_and_Single_Sign_Off_System_in_PHP\">How to Make Single Sign On (SSO) and Single Sign Off System in PHP<\/span><\/h2>\n<p>So do you know how we will create sso using php, Trust me!\u00a0you don&#8217;t need any programming skills to make it possible. Just drag and drop system here, really it&#8217;s too easy. Non Programmer can do this. Hmm interested so do you know how can you make this possible. Ok! it was a bad joke i know \ud83d\ude42 but you really need good programming skills to create it. So let&#8217;s start learning <strong>Development of SSO (Single Sign On) System in\u00a0php<\/strong>.<\/p>\n<h3><span id=\"What_is_my_Methodology_to_Make_it_Perfect_Easy_SSO\">What is my Methodology to Make it Perfect &amp; Easy SSO :<\/span><\/h3>\n<p>Here I am creating an access token, and different different databases for all my two other sites. So here are 3 sites SSO DEMO, SSO Forum and SSO Shop. All three website having different different features and their own databases, So during development of this system I thought, it can be use in old sites, means if you have lot&#8217;s of registered users in your websites, so How to use this SSO System for Existing Sites, So after a wide research i got two answers, One is we can merge all users to a database, but how it will work if all sites having different different CMS, or script. So I thought better to make \u00a0it for different different databases. But the best way for startup i will recommend create a Master Database which will include Authentication data and user data table, as Google&#8217;s accounts.google.com sub domain (It&#8217;s just a guess about google, I don&#8217;t know what they do). So here you have to create a Master site and other child sites.<\/p>\n<p><strong>Note : I Recommend This Can Be Use In Production, But\u00a0As Few Days ago Some Hackers Said &#8220;Security is an Illusion :)&#8221; It&#8217;s something like that. Make it much secure on your end.<\/strong><\/p>\n<p>Finally here i am going to introduce my codes and way to make a SSO using PHP.<\/p>\n<h3><span id=\"How_to_Make_SSO_In_PHP_Integration\">How to Make SSO In PHP &amp; Integration:<\/span><\/h3>\n<p>To make a perfect sso system you have to care about, your users data and prevent it from data Stolen, I recommend no Scrapping Please \ud83d\ude42 , Let&#8217;s Start to make it with php code.<\/p>\n<p><strong>Directory Structure:<\/strong><\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n\r\n|-&gt; Master Site's root (Mine is sso-demo.infotheme.in)\r\n\r\n| \u00a0 \u00a0 \u00a0 \u00a0 \u00a0|-&gt; index.php\r\n\r\n| \u00a0 \u00a0 \u00a0 \u00a0 \u00a0|-&gt; auth-access.php\r\n\r\n| \u00a0 \u00a0 \u00a0 \u00a0 \u00a0|-&gt;app_config.php \r\n\r\n--------------OR--------------- \r\n\r\n| \u00a0 \u00a0 \u00a0 \u00a0 \u00a0|-&gt; one-login.php \r\n\r\n| \u00a0 \u00a0 \u00a0 \u00a0 \u00a0|-&gt; one-time-register.php\r\n\r\n| \u00a0 \u00a0 \u00a0 \u00a0 \u00a0|-&gt; auth-access.php\r\n\r\n| \u00a0 \u00a0 \u00a0 \u00a0 \u00a0|-&gt;app_config.php\r\n\r\n--------For Child Sites---------\r\n\r\n|-&gt; All Child Sites root\r\n\r\n| \u00a0 \u00a0 \u00a0 \u00a0 \u00a0|-&gt; app_config.php\r\n| \u00a0 \u00a0 \u00a0 \u00a0 \u00a0|-&gt; auth-access.php\r\n<\/pre>\n<p>Index.php :\u00a0\u00a0Can Includes Login and Registration Form, Or you can change it&#8217;s path and file name according to your requirement<\/p>\n<p>In this SSO system our app_config.php file is God.<\/p>\n<p>Step 1: First you have to create an one-login.php file, over your master site, Which will be similar to this.<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n\r\n&lt;h1 class=&quot;sso_community_heading&quot;&gt;One Login For All Sites&lt;\/h1&gt;\r\n\r\n\r\n&lt;div class=&quot;inner_wrapper_flex&quot;&gt;\r\n\r\n&lt;h3&gt;One Login For All Sites&lt;\/h3&gt;\r\n\r\n\r\n&lt;div class=&quot;app_sites_links&quot;&gt;\r\n&lt;a href=&quot;Your Master Site's Home Page URL&quot;&gt;SSO DEMO&lt;\/a&gt;\r\n&lt;a href=&quot;Your First Child Site's Home Page URL&quot;&gt;SSO FORUM&lt;\/a&gt;\r\n&lt;a href=&quot;Your Second Child Site's Home Page URL&quot;&gt;SSO SHOP&lt;\/a&gt;\r\n&lt;\/div&gt;\r\n\r\n\r\n&lt;div class=&quot;app_login_form_wrapper&quot;&gt;\r\n\r\n&lt;form class=&quot;app_login_form&quot; name=&quot;app_sso_login_form&quot; id=&quot;app_sso_login_form&quot; action=&quot;&quot; method=&quot;post&quot;&gt;\r\n&lt;input type=&quot;email&quot; name=&quot;app_login_email&quot; class=&quot;app_login_email&quot; id=&quot;app_login_email&quot; value=&quot;&quot; placeholder=&quot;Email&quot; autocomplete=&quot;off&quot;\/&gt;\r\n&lt;input type=&quot;password&quot; name=&quot;app_login_pass&quot; class=&quot;app_login_pass&quot; id=&quot;app_login_pass&quot; value=&quot;&quot; placeholder=&quot;Password&quot; \/&gt;\r\n&lt;button type=&quot;submit&quot; name=&quot;app_login_action&quot; class=&quot;app_login_action&quot; id=&quot;app_login_Action&quot;&gt;Login&lt;\/button&gt;\r\n&lt;\/form&gt;\r\n\r\n&lt;a class=&quot;app_related_link&quot; href=&quot;?step=register&quot;&gt;Create New Account&lt;\/a&gt;\r\n&lt;\/div&gt;\r\n\r\n&lt;\/div&gt;\r\n\r\n<\/pre>\n<p>So here in this step you have created an Login Form to Login with all websites.<\/p>\n<p>Step 2: Now it&#8217;s time to create a php file with single register form for all website. In this section, you need to care about all websites database, means you have to add all mandatory fields here, according to database user table. So as i have added only 4 Fields which are mandatory to all my 3 websites.<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n\r\n&lt;div class=&quot;inner_wrapper_flex&quot;&gt;\r\n\r\n&lt;h3&gt;Create One Account For All Sites&lt;\/h3&gt;\r\n\r\n\r\n&lt;div class=&quot;app_sites_links&quot;&gt;\r\n&lt;a href=&quot;Your Master Site's Home Page URL&quot;&gt;SSO DEMO&lt;\/a&gt;\r\n&lt;a href=&quot;Your First Child Site's Home Page URL&quot;&gt;SSO FORUM&lt;\/a&gt;\r\n&lt;a href=&quot;Your Second Child Site's Home Page URL&quot;&gt;SSO SHOP&lt;\/a&gt;\r\n&lt;\/div&gt;\r\n\r\n\r\n&lt;div class=&quot;app_reg_form_wrapper&quot;&gt;\r\n\r\n&lt;form class=&quot;app_reg_form&quot; name=&quot;app_sso_reg_form&quot; id=&quot;app_sso_reg_form&quot; action=&quot;&quot; method=&quot;post&quot;&gt;\r\n&lt;input type=&quot;text&quot; name=&quot;app_reg_name&quot; class=&quot;app_reg_name&quot; id=&quot;app_reg_name&quot; value=&quot;&quot; placeholder=&quot;Full Name&quot;\/&gt;\r\n&lt;input type=&quot;email&quot; name=&quot;app_reg_email&quot; class=&quot;app_reg_email&quot; id=&quot;app_reg_email&quot; value=&quot;&quot; placeholder=&quot;Email Address&quot;\/&gt;\r\n&lt;input type=&quot;text&quot; name=&quot;app_reg_skills&quot; class=&quot;app_reg_skills&quot; id=&quot;app_reg_skills&quot; value=&quot;&quot; placeholder=&quot;Your Skills&quot;\/&gt;\r\n&lt;input type=&quot;password&quot; name=&quot;app_reg_pass&quot; class=&quot;app_reg_pass&quot; id=&quot;app_reg_pass&quot; value=&quot;&quot; placeholder=&quot;Create A Password&quot;\/&gt;\r\n&lt;button type=&quot;submit&quot; name=&quot;app_reg_action&quot; class=&quot;app_reg_action&quot; id=&quot;app_reg_Action&quot;&gt;Create Account&lt;\/button&gt;\r\n&lt;\/form&gt;\r\n\r\n&lt;a class=&quot;app_related_link&quot; href=&quot;Your Login Link Here&quot;&gt;Login to Your Account&lt;\/a&gt;\r\n&lt;\/div&gt;\r\n\r\n&lt;\/div&gt;\r\n\r\n<\/pre>\n<h2><span id=\"Conclusion_8211_SSO_System_In_PHP\">Conclusion &#8211; SSO System In PHP<\/span><\/h2>\n<p>So guys, as we learned here lot&#8217;s of things about <strong>SSO (Single Sign On System) and Single Sign Off System in PHP<\/strong>. But as I am still working on the code of SSO System, and it&#8217;s a biggest project for me. So Please keep in touch I will come here with next part of &#8220;<strong>How to Make SSO (Single Sign On) and Single Sign Off System In PHP<\/strong>&#8220;. Rest I develop it completely please comment and give your feedback to me, please also mentioned on which cms you want this script. I will come with complete package of SSO soon.Have a nice coding \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Google having one login system for all of their own products as Youtube, Gmail and etc. So as every website owner want this type of [&hellip;] <span class=\"read-more-link\"><a class=\"read-more\" href=\"https:\/\/infotheme.net\/blog\/create-single-sign-on-system-in-php\/\">Read More<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[135],"tags":[150,151,152],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/infotheme.net\/blog\/wp-json\/wp\/v2\/posts\/142"}],"collection":[{"href":"https:\/\/infotheme.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/infotheme.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/infotheme.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/infotheme.net\/blog\/wp-json\/wp\/v2\/comments?post=142"}],"version-history":[{"count":0,"href":"https:\/\/infotheme.net\/blog\/wp-json\/wp\/v2\/posts\/142\/revisions"}],"wp:attachment":[{"href":"https:\/\/infotheme.net\/blog\/wp-json\/wp\/v2\/media?parent=142"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/infotheme.net\/blog\/wp-json\/wp\/v2\/categories?post=142"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/infotheme.net\/blog\/wp-json\/wp\/v2\/tags?post=142"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}