<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>identity provider | Spagno's Blog</title><link>/tag/identity-provider/</link><atom:link href="/tag/identity-provider/index.xml" rel="self" type="application/rss+xml"/><description>identity provider</description><generator>Wowchemy (https://wowchemy.com)</generator><language>en-us</language><lastBuildDate>Wed, 13 Mar 2019 00:00:00 +0000</lastBuildDate><image><url>/images/icon_hua320044a33bf4566f6947aefcc55cba9_1117206_512x512_fill_lanczos_center_2.png</url><title>identity provider</title><link>/tag/identity-provider/</link></image><item><title>Google OAuth as Identity Provider with Red Hat login in OCP 3.11</title><link>/post/google-oauth-as-identity-provider-with-red-hat-login-in-ocp-311/</link><pubDate>Wed, 13 Mar 2019 00:00:00 +0000</pubDate><guid>/post/google-oauth-as-identity-provider-with-red-hat-login-in-ocp-311/</guid><description>&lt;p>When I was in Red Hat, I needed to grant access to my lab to some of my colleagues.&lt;br>
The lab uses httpasswd IdentityProvider and It was really painful to add new users to the file each time.&lt;br>
So, an idea popped up: could I use the google oauth Identity Provider with our Red Hat login?&lt;br>
Well, it can be done! This is a detailed how-to&lt;/p>
&lt;p>I logged in &lt;a href="https://console.developers.google.com/apis/dashboard" title="https://console.developers.google.com/apis/dashboard" target="_blank" rel="noopener">https://console.developers.google.com/apis/dashboard&lt;/a>  with my Red Hat credentials.&lt;/p>
&lt;p>At the top of the page, click the select box next to the &lt;strong>google APIs&lt;/strong> logo
&lt;figure id="figure-google-apis">
&lt;a data-fancybox="" href="/post/google-oauth-as-identity-provider-with-red-hat-login-in-ocp-311/images/image01_hu8b562bbacd33de561e2312c31dd6a7df_59958_2000x2000_fit_lanczos_2.png" data-caption="google apis">
&lt;img data-src="/post/google-oauth-as-identity-provider-with-red-hat-login-in-ocp-311/images/image01_hu8b562bbacd33de561e2312c31dd6a7df_59958_2000x2000_fit_lanczos_2.png" class="lazyload" alt="" width="1920" height="1080">
&lt;/a>
&lt;figcaption>
google apis
&lt;/figcaption>
&lt;/figure>
&lt;/p>
&lt;p>Choose &lt;strong>REDHAT.COM&lt;/strong> in the &lt;strong>Select from&lt;/strong> box and then click &lt;strong>NEW PROJECT&lt;/strong>
&lt;figure id="figure-location">
&lt;a data-fancybox="" href="/post/google-oauth-as-identity-provider-with-red-hat-login-in-ocp-311/images/image02_hub8b4af18d339ee45d3b7591cfb769979_99387_2000x2000_fit_lanczos_2.png" data-caption="location">
&lt;img data-src="/post/google-oauth-as-identity-provider-with-red-hat-login-in-ocp-311/images/image02_hub8b4af18d339ee45d3b7591cfb769979_99387_2000x2000_fit_lanczos_2.png" class="lazyload" alt="" width="1920" height="1080">
&lt;/a>
&lt;figcaption>
location
&lt;/figcaption>
&lt;/figure>
&lt;/p>
&lt;p>Choose your &lt;strong>Project Name&lt;/strong> and be sure that the &lt;strong>Location&lt;/strong> is &lt;strong>redhat.com&lt;/strong>. Then click &lt;strong>CREATE&lt;/strong>
&lt;figure id="figure-new-project">
&lt;a data-fancybox="" href="/post/google-oauth-as-identity-provider-with-red-hat-login-in-ocp-311/images/image01_hu8b562bbacd33de561e2312c31dd6a7df_59958_2000x2000_fit_lanczos_2.png" data-caption="new project">
&lt;img data-src="/post/google-oauth-as-identity-provider-with-red-hat-login-in-ocp-311/images/image01_hu8b562bbacd33de561e2312c31dd6a7df_59958_2000x2000_fit_lanczos_2.png" class="lazyload" alt="" width="1920" height="1080">
&lt;/a>
&lt;figcaption>
new project
&lt;/figcaption>
&lt;/figure>
&lt;/p>
&lt;p>On the left, you&amp;rsquo;ll find the &lt;strong>credentials&lt;/strong> section: click on it
&lt;figure id="figure-credentials">
&lt;a data-fancybox="" href="/post/google-oauth-as-identity-provider-with-red-hat-login-in-ocp-311/images/image03_hu1932725998a2900f0ac49b549d3c78de_70701_2000x2000_fit_lanczos_2.png" data-caption="credentials">
&lt;img data-src="/post/google-oauth-as-identity-provider-with-red-hat-login-in-ocp-311/images/image03_hu1932725998a2900f0ac49b549d3c78de_70701_2000x2000_fit_lanczos_2.png" class="lazyload" alt="" width="1920" height="1080">
&lt;/a>
&lt;figcaption>
credentials
&lt;/figcaption>
&lt;/figure>
&lt;/p>
&lt;p>Under &lt;strong>credentials&lt;/strong>, click on the tab &lt;strong>OAuth Consent Screen&lt;/strong>
&lt;figure id="figure-oauth-consent-screen">
&lt;a data-fancybox="" href="/post/google-oauth-as-identity-provider-with-red-hat-login-in-ocp-311/images/image04_hud4b539d1c646604f8b87321bbd04279a_72622_2000x2000_fit_lanczos_2.png" data-caption="oauth consent screen">
&lt;img data-src="/post/google-oauth-as-identity-provider-with-red-hat-login-in-ocp-311/images/image04_hud4b539d1c646604f8b87321bbd04279a_72622_2000x2000_fit_lanczos_2.png" class="lazyload" alt="" width="1920" height="1080">
&lt;/a>
&lt;figcaption>
oauth consent screen
&lt;/figcaption>
&lt;/figure>
&lt;/p>
&lt;p>Now we have to configure the &lt;strong>Application type&lt;/strong> as &lt;strong>internal&lt;/strong> and add your ocp domain in &lt;strong>Authorized Domain&lt;/strong> and your &lt;strong>Application Name&lt;/strong>. Then click &lt;strong>save&lt;/strong> and you&amp;rsquo;ll be redirected in the &lt;strong>credentials&lt;/strong> configuration
&lt;figure id="figure-application-type">
&lt;a data-fancybox="" href="/post/google-oauth-as-identity-provider-with-red-hat-login-in-ocp-311/images/image05_hua3f1e6835828f9913c5da4ff7e1cdd7d_81305_2000x2000_fit_lanczos_2.png" data-caption="application type">
&lt;img data-src="/post/google-oauth-as-identity-provider-with-red-hat-login-in-ocp-311/images/image05_hua3f1e6835828f9913c5da4ff7e1cdd7d_81305_2000x2000_fit_lanczos_2.png" class="lazyload" alt="" width="1920" height="1080">
&lt;/a>
&lt;figcaption>
application type
&lt;/figcaption>
&lt;/figure>
&lt;figure id="figure-authorized-domain">
&lt;a data-fancybox="" href="/post/google-oauth-as-identity-provider-with-red-hat-login-in-ocp-311/images/image06_hu03570c4226fe56686e2827b4ed5593e3_214824_2000x2000_fit_lanczos_2.png" data-caption="authorized domain">
&lt;img data-src="/post/google-oauth-as-identity-provider-with-red-hat-login-in-ocp-311/images/image06_hu03570c4226fe56686e2827b4ed5593e3_214824_2000x2000_fit_lanczos_2.png" class="lazyload" alt="" width="1920" height="1053">
&lt;/a>
&lt;figcaption>
authorized domain
&lt;/figcaption>
&lt;/figure>
&lt;/p>
&lt;p>Click &lt;strong>Create credentials&lt;/strong> and select &lt;strong>Oauth Client ID&lt;/strong>
&lt;figure id="figure-create-credentials">
&lt;a data-fancybox="" href="/post/google-oauth-as-identity-provider-with-red-hat-login-in-ocp-311/images/image07_hu576e1bcbcd94c0cada91b5c20e0aee07_102242_2000x2000_fit_lanczos_2.png" data-caption="create credentials">
&lt;img data-src="/post/google-oauth-as-identity-provider-with-red-hat-login-in-ocp-311/images/image07_hu576e1bcbcd94c0cada91b5c20e0aee07_102242_2000x2000_fit_lanczos_2.png" class="lazyload" alt="" width="1920" height="1053">
&lt;/a>
&lt;figcaption>
create credentials
&lt;/figcaption>
&lt;/figure>
&lt;/p>
&lt;p>Select &lt;strong>Web application&lt;/strong> in &lt;strong>Application type&lt;/strong> and choose the &lt;strong>Name&lt;/strong>. In &lt;strong>Authorized JavaScript origins&lt;/strong> add the URI of your ocp webconsole. In &lt;strong>Authorized redirect URIs&lt;/strong> add your callback uri. In OCP 3.11 your callback uri should be: &lt;strong>&lt;code>https://&amp;lt;master&amp;gt;/oauth2callback/&amp;lt;identityProviderName&amp;gt;&lt;/code>&lt;/strong>. The &lt;strong>IdentityProviderName&lt;/strong> must have the same name as the one we&amp;rsquo;ll configure in OpenShift. Then click &lt;strong>create&lt;/strong>. A popup will be shown giving you the &lt;strong>client ID&lt;/strong> and the &lt;strong>client secret&lt;/strong>. Save that information because we&amp;rsquo;ll need them later to setup OpenShift
&lt;figure id="figure-web-application">
&lt;a data-fancybox="" href="/post/google-oauth-as-identity-provider-with-red-hat-login-in-ocp-311/images/image08_hu4531b58442898cdc612b3daec369365b_128741_2000x2000_fit_lanczos_2.png" data-caption="web application">
&lt;img data-src="/post/google-oauth-as-identity-provider-with-red-hat-login-in-ocp-311/images/image08_hu4531b58442898cdc612b3daec369365b_128741_2000x2000_fit_lanczos_2.png" class="lazyload" alt="" width="1920" height="1053">
&lt;/a>
&lt;figcaption>
web application
&lt;/figcaption>
&lt;/figure>
&lt;figure id="figure-credentials">
&lt;a data-fancybox="" href="/post/google-oauth-as-identity-provider-with-red-hat-login-in-ocp-311/images/image09_hufd3f1eb3c71e1badc7cbd8ebfd343622_114304_2000x2000_fit_lanczos_2.png" data-caption="credentials">
&lt;img data-src="/post/google-oauth-as-identity-provider-with-red-hat-login-in-ocp-311/images/image09_hufd3f1eb3c71e1badc7cbd8ebfd343622_114304_2000x2000_fit_lanczos_2.png" class="lazyload" alt="" width="1920" height="1053">
&lt;/a>
&lt;figcaption>
credentials
&lt;/figcaption>
&lt;/figure>
&lt;/p>
&lt;p>Now it&amp;rsquo;s time to configure our OpenShift.
The following procedure must be done in **ALL **the masters of the cluster.&lt;/p>
&lt;p>You must log in the master server and modify the &lt;strong>/etc/origin/master/master-config.yml&lt;/strong> file adding this snippet under the section &lt;strong>identityProviders&lt;/strong>&lt;/p>
&lt;pre>&lt;code>  - name: RedHat
    challenge: false
    login: true
    mappingMethod: claim
    provider:
      apiVersion: v1
      kind: GoogleIdentityProvider
      clientID: &amp;quot;xxx&amp;quot;
      clientSecret: &amp;quot;xxx&amp;quot;
      hostedDomain: &amp;quot;redhat.com&amp;quot;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
&lt;/code>&lt;/pre>
&lt;p>&lt;strong>name&lt;/strong> must be the same as the &lt;strong>IdentityProviderName&lt;/strong> we have configured in the callback URI&lt;/p>
&lt;p>&lt;strong>clientID&lt;/strong> and &lt;strong>clientSecret&lt;/strong> are the info we got in the &lt;strong>credentials&lt;/strong> setup in google.&lt;/p>
&lt;p>After that, restart &lt;strong>api&lt;/strong> and &lt;strong>controllers&lt;/strong>&lt;/p>
&lt;pre>&lt;code>[root@ocp-master1 ~]# master-restart api api
2
[root@ocp-master1 ~]# master-restart controllers controllers
2
[root@ocp-master1 ~]# ‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
&lt;/code>&lt;/pre>
&lt;p>Now we can check if all works good. Open in your browser your OCP webconsole and select the &lt;strong>RedHat&lt;/strong> identity provider
&lt;figure id="figure-oauth-page">
&lt;a data-fancybox="" href="/post/google-oauth-as-identity-provider-with-red-hat-login-in-ocp-311/images/image10_hu839ab8518ef279d89bbef369a7dd57c7_64779_2000x2000_fit_lanczos_2.png" data-caption="oauth page">
&lt;img data-src="/post/google-oauth-as-identity-provider-with-red-hat-login-in-ocp-311/images/image10_hu839ab8518ef279d89bbef369a7dd57c7_64779_2000x2000_fit_lanczos_2.png" class="lazyload" alt="" width="1920" height="1053">
&lt;/a>
&lt;figcaption>
oauth page
&lt;/figcaption>
&lt;/figure>
&lt;/p>
&lt;p>You&amp;rsquo;ll be redirect into the &lt;strong>RED HAT INTERNAL SSO&lt;/strong>
&lt;figure id="figure-sso-page">
&lt;a data-fancybox="" href="/post/google-oauth-as-identity-provider-with-red-hat-login-in-ocp-311/images/image11_hu362bb386e16c0f16a194e0e87aaf5270_131251_2000x2000_fit_lanczos_2.png" data-caption="sso page">
&lt;img data-src="/post/google-oauth-as-identity-provider-with-red-hat-login-in-ocp-311/images/image11_hu362bb386e16c0f16a194e0e87aaf5270_131251_2000x2000_fit_lanczos_2.png" class="lazyload" alt="" width="1920" height="1080">
&lt;/a>
&lt;figcaption>
sso page
&lt;/figcaption>
&lt;/figure>
&lt;/p>
&lt;p>And finally you&amp;rsquo;ll have access to your OpenShift
&lt;figure id="figure-webconsole">
&lt;a data-fancybox="" href="/post/google-oauth-as-identity-provider-with-red-hat-login-in-ocp-311/images/image12_hu68c835f028cbfba169dcda78333a7220_333960_2000x2000_fit_lanczos_2.png" data-caption="webconsole">
&lt;img data-src="/post/google-oauth-as-identity-provider-with-red-hat-login-in-ocp-311/images/image12_hu68c835f028cbfba169dcda78333a7220_333960_2000x2000_fit_lanczos_2.png" class="lazyload" alt="" width="1920" height="1080">
&lt;/a>
&lt;figcaption>
webconsole
&lt;/figcaption>
&lt;/figure>
&lt;/p>
&lt;pre>&lt;code>[root@ocp-master1 ~]# oc get user
NAME                  UID                                    FULL NAME         IDENTITIES
aspagnol@redhat.com   f2e04e82-40d9-11e9-ac71-005056a802f7   Andrea Spagnolo   RedHat:108476506439924310236
[root@ocp-master1 ~]# oc get identity
NAME                           IDP NAME   IDP USER NAME           USER NAME             USER UID
RedHat:108476506439924310236   RedHat     108476506439924310236   aspagnol@redhat.com   f2e04e82-40d9-11e9-ac71-005056a802f7
[root@ocp-master1 ~]# ‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
&lt;/code>&lt;/pre>
&lt;p>Now you can manage your users directly in OpenShift and, for example, create an admin group and add the users&lt;/p>
&lt;pre>&lt;code>[root@ocp-master1 ~]# oc adm groups new admins
group.user.openshift.io/admins created
[root@ocp-master1 ~]# oc adm policy add-cluster-role-to-group cluster-admin admins
cluster role &amp;quot;cluster-admin&amp;quot; added: &amp;quot;admins&amp;quot;
[root@ocp-master1 ~]# oc adm groups add-users admins aspagnol@redhat.com
group &amp;quot;admins&amp;quot; added: &amp;quot;aspagnol@redhat.com&amp;quot;
[root@ocp-master1 ~]# oc describe groups admins
Name:          admins
Created:     About a minute ago
Labels:          &amp;lt;none&amp;gt;
Annotations:     &amp;lt;none&amp;gt;
Users:          aspagnol@redhat.com
[root@ocp-master1 ~]# ‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
&lt;/code>&lt;/pre>
&lt;p>And we can check in the webconsole
&lt;figure id="figure-webconsole">
&lt;a data-fancybox="" href="/post/google-oauth-as-identity-provider-with-red-hat-login-in-ocp-311/images/image13_hu8cf877d91d41146558a71c6423f1d258_343294_2000x2000_fit_lanczos_2.png" data-caption="webconsole">
&lt;img data-src="/post/google-oauth-as-identity-provider-with-red-hat-login-in-ocp-311/images/image13_hu8cf877d91d41146558a71c6423f1d258_343294_2000x2000_fit_lanczos_2.png" class="lazyload" alt="" width="1920" height="1053">
&lt;/a>
&lt;figcaption>
webconsole
&lt;/figcaption>
&lt;/figure>
&lt;/p>
&lt;p>You can find the complete documentation about the Identity Providers in OCP &lt;a href="https://docs.openshift.com/container-platform/3.11/install_config/configuring_authentication.html" target="_blank" rel="noopener">here&lt;/a>.
You can also configure the inventory  to add the GoogleIdentityProvider directly during the installation of OCP&lt;/p>
&lt;pre>&lt;code>openshift_master_identity_providers=[{'name': 'RedHat', 'challenge': 'false', 'login': 'true', 'kind': 'GoogleIdentityProvider', 'clientID': 'xxx', 'clientSecret': 'xxx', 'hostedDomain': 'redhat.com'}]‍‍
&lt;/code>&lt;/pre>
&lt;h2 id="please-note">Please Note&lt;/h2>
&lt;p>If yours OpenShift masters need a proxy to go to internet, the proxy &lt;strong>MUST&lt;/strong> have  &lt;strong>&lt;a href="/www.googleapis.com">https://www.googleapis.com&lt;/a>&lt;/strong> in allow because it&amp;rsquo;s needed by the server to get the oauth2 token&lt;/p>
&lt;p>That&amp;rsquo;s All!&lt;/p></description></item></channel></rss>