{"id":38855,"date":"2016-08-26T14:35:34","date_gmt":"2016-08-26T09:05:34","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=38855"},"modified":"2016-08-26T16:40:28","modified_gmt":"2016-08-26T11:10:28","slug":"jenkins-google-authentication","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/jenkins-google-authentication\/","title":{"rendered":"Jenkins Google Authentication"},"content":{"rendered":"<p style=\"text-align: center;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-large wp-image-39316\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/08\/key_and_lock-1-1024x491.jpg\" alt=\"Old fashioned key and lock\" width=\"625\" height=\"299\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2016\/08\/key_and_lock-1-1024x491.jpg 1024w, \/blog\/wp-ttn-blog\/uploads\/2016\/08\/key_and_lock-1-300x143.jpg 300w, \/blog\/wp-ttn-blog\/uploads\/2016\/08\/key_and_lock-1-624x299.jpg 624w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><\/p>\n<p align=\"justify\">In Jenkins by default user authentication is not enabled but we can establish the user authentication from the Global Security section. We have to create users for team members and it maintains all user in its own database. But we can also configure Jenkins with Google oAuth. So, if you are leveraging Google services and already have users on it. The users can login to Jenkins and perform their task.<\/p>\n<p>I am assuming that we have already <a href=\"http:\/\/www.tothenew.com\/blog\/how-to-setup-jenkins-for-a-maven-project\/\">installed Jenkins server<\/a> and have admin right to make changes in it. The whole configuration is divided into three easy steps.<\/p>\n<h1 style=\"color: orange;\"><span style=\"color: #000000;\"><strong>1. Create Google OAuth Client Key<\/strong><\/span><\/h1>\n<p align=\"justify\">Before we start, we need to a create a project in Google developer console. In this project we will generate authantication credentials to enable OAuth API.<\/p>\n<ul>\n<li>To create your project login to Google developer <a title=\"console\" href=\"https:\/\/console.developers.google.com\/\">console<\/a> and in top bar select <b>Create project:<\/b><\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-39260\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/08\/Screen-Shot-2016-08-12-at-6.05.34-PM.png\" alt=\"Screen Shot 2016-08-12 at 6.05.34 PM\" width=\"1460\" height=\"462\" \/><\/p>\n<ul>\n<li>In the pop-up window specify your project name it can be any name which is more meaning full to you. Here I have created a project named <b>Jenkins OAuth<\/b>. In the advanced section, you can select app engine geographical location:<img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-39265\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/08\/Screen-Shot-2016-08-19-at-2.23.57-PM1.png\" alt=\"Screen Shot 2016-08-19 at 2.23.57 PM\" width=\"1460\" height=\"462\" \/><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>It will take few minutes to create your project. Once it completes, on the left sidebar under API Manager select <b>Credentials<\/b> and then click on <b>Create Credentials:<\/b><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-39271\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/08\/Screen-Shot-2016-08-19-at-2.56.46-PM.png\" alt=\"Screen Shot 2016-08-19 at 2.56.46 PM\" width=\"1460\" height=\"462\" \/><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>In Create Credentials drop down menu there are three options. We will choose <b>OAuth client ID<\/b> to create client id. It will genrate API credentials and these credentails are required to configure in Jenkins in last step:<br \/>\n<img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-39274\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/08\/Screen-Shot-2016-08-19-at-3.30.00-PM.png\" alt=\"Screen Shot 2016-08-19 at 3.30.00 PM\" width=\"1460\" height=\"462\" \/><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>As we are going to integrate this in Jenkins and it is a web service, So in application type select <b>Web application:<\/b><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-39276\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/08\/Screen-Shot-2016-08-19-at-3.57.33-PM.png\" alt=\"Screen Shot 2016-08-19 at 3.57.33 PM\" width=\"1272\" height=\"360\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2016\/08\/Screen-Shot-2016-08-19-at-3.57.33-PM.png 1272w, \/blog\/wp-ttn-blog\/uploads\/2016\/08\/Screen-Shot-2016-08-19-at-3.57.33-PM-300x84.png 300w, \/blog\/wp-ttn-blog\/uploads\/2016\/08\/Screen-Shot-2016-08-19-at-3.57.33-PM-1024x289.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2016\/08\/Screen-Shot-2016-08-19-at-3.57.33-PM-624x176.png 624w\" sizes=\"(max-width: 1272px) 100vw, 1272px\" \/><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li>In the next section, Register Jenkins URI from where we allowed to access the Google APIs. We have to provide Jenkins server detail. You can replace <b>jenkins.mydimain.com<\/b> with your own Jenkins URI. This will be the landing page of your Jenkins server. Once you hit this page it will be redirected to google for the authentication:<img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-39278\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/08\/Screen-Shot-2016-08-19-at-3.57.45-PM.png\" alt=\"Screen Shot 2016-08-19 at 3.57.45 PM\" width=\"1226\" height=\"266\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2016\/08\/Screen-Shot-2016-08-19-at-3.57.45-PM.png 1226w, \/blog\/wp-ttn-blog\/uploads\/2016\/08\/Screen-Shot-2016-08-19-at-3.57.45-PM-300x65.png 300w, \/blog\/wp-ttn-blog\/uploads\/2016\/08\/Screen-Shot-2016-08-19-at-3.57.45-PM-1024x222.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2016\/08\/Screen-Shot-2016-08-19-at-3.57.45-PM-624x135.png 624w\" sizes=\"(max-width: 1226px) 100vw, 1226px\" \/><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li>The authorized redirect URIs is required to redirect you after successful login. It is the combination of your Jenkins landing page and a suffix string to validate you are a logged in user. As we want to land user to Jenkins dashboard, so it has the same URI which we mentioned in the previous step and don&#8217;t forget to include <b>securityRealm\/finishLogin<\/b> at the end:<img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-39279\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/08\/Screen-Shot-2016-08-19-at-3.57.55-PM.png\" alt=\"Screen Shot 2016-08-19 at 3.57.55 PM\" width=\"1216\" height=\"262\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2016\/08\/Screen-Shot-2016-08-19-at-3.57.55-PM.png 1216w, \/blog\/wp-ttn-blog\/uploads\/2016\/08\/Screen-Shot-2016-08-19-at-3.57.55-PM-300x64.png 300w, \/blog\/wp-ttn-blog\/uploads\/2016\/08\/Screen-Shot-2016-08-19-at-3.57.55-PM-1024x220.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2016\/08\/Screen-Shot-2016-08-19-at-3.57.55-PM-624x134.png 624w\" sizes=\"(max-width: 1216px) 100vw, 1216px\" \/><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li>Here we have <b>Client ID<\/b> and <b>Client Secret<\/b>. Copy and save these credential as these will be used to enable Google APIs in Jenkins:<img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-39280\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/08\/Screen-Shot-2016-08-19-at-4.11.14-PM.png\" alt=\"Screen Shot 2016-08-19 at 4.11.14 PM\" width=\"1060\" height=\"322\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2016\/08\/Screen-Shot-2016-08-19-at-4.11.14-PM.png 1060w, \/blog\/wp-ttn-blog\/uploads\/2016\/08\/Screen-Shot-2016-08-19-at-4.11.14-PM-300x91.png 300w, \/blog\/wp-ttn-blog\/uploads\/2016\/08\/Screen-Shot-2016-08-19-at-4.11.14-PM-1024x311.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2016\/08\/Screen-Shot-2016-08-19-at-4.11.14-PM-624x189.png 624w\" sizes=\"(max-width: 1060px) 100vw, 1060px\" \/><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h1 style=\"color: orange;\"><span style=\"color: #000000;\"><strong>2. Install Google Login Plugin<\/strong><\/span><\/h1>\n<p align=\"justify\">In Jenkins there is no mechanism to configure OAuth but there are many plugins are available and we are using <b>Google Login plugin<\/b>. We can easily install this plugin from Manage Jenkins &#8211;&gt; Manage Plugins &#8211;&gt; Available and search for &#8220;Google Login&#8221;. Select the plugin. There is no need to restart to install this plugin. This plugin allows for the register Google OAuth and performs authentication:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-39281\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/08\/Screen-Shot-2016-08-19-at-4.20.20-PM.png\" alt=\"Screen Shot 2016-08-19 at 4.20.20 PM\" width=\"1720\" height=\"122\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2016\/08\/Screen-Shot-2016-08-19-at-4.20.20-PM.png 1720w, \/blog\/wp-ttn-blog\/uploads\/2016\/08\/Screen-Shot-2016-08-19-at-4.20.20-PM-300x21.png 300w, \/blog\/wp-ttn-blog\/uploads\/2016\/08\/Screen-Shot-2016-08-19-at-4.20.20-PM-1024x72.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2016\/08\/Screen-Shot-2016-08-19-at-4.20.20-PM-624x44.png 624w\" sizes=\"(max-width: 1720px) 100vw, 1720px\" \/><\/p>\n<h1 style=\"color: orange;\"><span style=\"color: #000000;\"><strong>3. Configure Jenkins<\/strong><\/span><\/h1>\n<p align=\"justify\">In this step, we will setup Google security credentials in installed plugin. Navigate to manage Jenkins &#8211;&gt; Configure Global Security and select <b>Login with Google<\/b> under Security Realm paste credentials generated in the first step. In the last field do not forget to enter your domain name it allows you to restrict access to given domain name:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-39283\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/08\/Screen-Shot-2016-08-12-at-6.30.48-PM.png\" alt=\"Screen Shot 2016-08-12 at 6.30.48 PM\" width=\"2008\" height=\"390\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2016\/08\/Screen-Shot-2016-08-12-at-6.30.48-PM.png 2008w, \/blog\/wp-ttn-blog\/uploads\/2016\/08\/Screen-Shot-2016-08-12-at-6.30.48-PM-300x58.png 300w, \/blog\/wp-ttn-blog\/uploads\/2016\/08\/Screen-Shot-2016-08-12-at-6.30.48-PM-1024x198.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2016\/08\/Screen-Shot-2016-08-12-at-6.30.48-PM-624x121.png 624w\" sizes=\"(max-width: 2008px) 100vw, 2008px\" \/><\/p>\n<p align=\"justify\">Immediately after saving changes Jenkins will allow access to all users in your domain. Now, try to login into your Jenkins it will redirect you to Google Authentication page. If everything is set up properly you will be logged in but just in case you&#8217;re still facing any problem go back and check each step. The logged in user can do anything and if you want to restrict users you can implement <a href=\"https:\/\/wiki.jenkins-ci.org\/display\/JENKINS\/Standard+Security+Setup\">Matrix-based<\/a> security.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Jenkins by default user authentication is not enabled but we can establish the user authentication from the Global Security section. We have to create users for team members and it maintains all user in its own database. But we can also configure Jenkins with Google oAuth. So, if you are leveraging Google services and [&hellip;]<\/p>\n","protected":false},"author":165,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":114},"categories":[1174,2348,1],"tags":[1892,3922,227,2852,1682,3926,3924,3925,3923],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/38855"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/165"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=38855"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/38855\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=38855"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=38855"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=38855"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}