Setting up SAML for Google Cloud Identity for Customers and Partners (CICP)



A little under a decade ago I wrote my first SAML IdP for the Google Search Appliance (yeah, that wonderful yellow box!). Since then, that script changed many hands and I’ve resued and adapted as an IDP for Google GSuites SSO and now finally in this article for Google Cloud.

This article circles back on that script but extends it for the Firebase Authentcation enchancements recently integrated into Google Cloud called Cloud Identity for Customers and Partners. This article is basically a picture book on how to setup your own SAML IdP and perform SSO with a Service Provider (SP) that is based off of the Firebase SDK or ‘roll your own’ Service Provider that hosts the SAML endpoint.

This is a simple ‘how to get started’ tutorial and ofcourse do not use any script contained here in production/qa,anywhere outside of yoru laptop! Also please note i’ve included public/private and API keys here. You really should regenerate the public/private keys (see Appendix).


As mentioned, there are two ways you can use this script with the same IdP:

  • SAML IDP with SP using Firebase Client SDK In this mode, you are using the FireBase javascript SDK running on your SP. This is the normal way you use this feature and is what is documented in the quickstart. The javascript runs in your browser and does all the legwork for you to handle the SAML, OIDC roundtrips. However, your site needs to use the SDK.

  • SAML IDP with SP without Firebase Client SDK Users that do not want to use the Firebase SDK, you can host your own (AssertionConsumerService) ACS endpoint. What this means is a SAML IDP will redirect your users back to your own server and you have to validate the SAMLRequest using CICP’s APIs. This usecase is for for more advanced usecases.

Note: at the time of writing (11/21), you need to manually alter the SAMLConfig ACS endpoint via API. Eventually you’ll be able to just edit the setting via the console…Also, I do not know much javascript so the example provided is not optimal.

You can find the source here


As this is just a tutorial to help you understand, we will setup the IdP and SP all locally on your workstation. The IdP used is common across both scenarios described above (as it should be) but the SP is different since one uses the Firebase SDK for CICP and the other manages the ACS. Switching between the two requires you to update the CICP ACS url (more on this later).

Configure /etc/hosts

Since we’re running everything locally, override the /etc/hosts file

Configure CICP on any project

(in this example, the project I use in the example is called cicp-project)

Enable the CICP API

Setup Providers


We will setup Google OIDC too just for fun

  • click edit on Google Note down the ClientID you see:

    • For my project, its ClientID:


  • Setup Consent Screen You need to set some setting on the Consent screen here since we turned on OIDC


  • click create on SAML Enter the following:

    • Name: myIdP
    • EntityID:
    • SSO URL:
    • Certificate: copy+paste the file contents inside idp/server.crt (as before, you should generate you eally own keys!)
    • Service Provider ID:


  • Under Settings

    • Add Authorized DOmain: This will add your SP domain as a valid redirect for all auth mechanisms


  • Users

    • Nothing to do here; just verify no users are currently in your local project. (we will come back to this later)


  • Providers

    Click on “App Setup Details” on the top right This will give you a javascript snippet for your Firebase UI

    copy the snippet into sp_firebase/layout.html

    For me, its:

      <script src=""></script>
        var config = {
          apiKey: "AIzaSyCgD_yHPgEoC52gY7KnSqe67e4B6ixo0c8",
          authDomain: "",


  • Edit sp_firebase/secure.html, add the SAML providerID: saml.myidp
          const provider = new firebase.auth.SAMLAuthProvider('saml.myidp');

Start IDP

Now start the commond IdP: Start SAML IDP

    cd idp

      docker run -t -p 28080:28080 \
        -v `pwd`:/app/:ro \
        --entrypoint=/app/ \
        salrashid123/appssso \
        --debug  \
        --cert_file=/app/server.crt \

You might be wondering why you’re running some image called salrashid123/appssso…thats just a prebaked image with the python xmlsec libraries build in. You are free to recreate that image…here is the repo and Dockerfile

SP Scenario: FirebaseSDK

First lets start the Firebase SDK based SP:

    cd sp_firebase

    virtualenv env
    source env/bin/activate
    pip install -r requirements.txt


Test Login

Open Incognito window goto:


Login with OIDC

First try Login with google account (in my example, i used

If everything goes well, you’ll get redirect and see the current loged in user at the footer of the page


Login with SAML

In a new incognito window and goto

Click Login with SAML

You’ll get redirected to SAML Login page on the IdP:


Enter (any* username/password (this is because i don’t do any validation on the idP; this is just a test!)

I entered:

You’ll see a temp page with the SAML Response (normally, your users don’t see this and i added in this pause just to show you the decoded SAML POST data)


Once you click continue, you’ll see a login success screen on the IDP with the users credentials displayed


Note two users is provisioned per each login:


SP Scenario: Self hosted ACS

In this scenario, we will run our own IDP.

First step is to stop the SP from the previous step (SP Scenario: FirebaseSDK) if you are still running it.

Then use the API key, projectID and saml_providder for your setup and start the SP:

    cd sp/

      docker run -t -p 38080:38080 \
        -v `pwd`:/app/:ro \
        --entrypoint=/app/ \
        salrashid123/appssso \
        --debug  \
        --port=38080 \ \
        --cert_file=/app/server.crt \
        --key_file=/app/server.key \
        --saml_provider_id=saml.myIdP \
        --projectId=226130788915  \
        --sp_domain= \

Ok, you still can’t run the full flow yet because we need to modify the ACS URL back to our own provider. By default, the ACS is

  • "callbackUri": ""

but we need it to point to our endpoint

  • "callbackUri": ""

Plese see the Appendix section on how to run through these steps.

Once youve done it, you can access the SP at: images/sp_login_2.png

At that point, you’ll get redirected once clicking on the button to same IDP as earlier.

Login and you’ll go back to the images/sp_custom_2.png

Note the saml2p:Response Destination= value images/custom_2_login.png

Custom Domain for FireBase SDK

By default when you setup CICP with FirebaseSDK, your ACS redirects you to a domain like "

However, you may want to setup a custom domain hosted on firebase. If you set up a custom hosted domain, firebase will automatically manage the redirect back to your app. THis works as long as you use the firebaseSDK for the SP.

To set this up, first setup “Firebase Hosting” and setup a custom domain. For me, it was (you ofcourse need to own the domain and edit the DNS settings, proper (the /etc/hosts trick wont work)). Once you set that up and provide the IPs they specify (wait maybe 1hr)

  For my domain,
      $ nslookup



Then edit the javascript in sp_firebase/layout.html to add on the auth domain you have

        var config = {
          apiKey: "AIzaSyCgD_yHPgEoC52gY7KnSqe67e4B6ixo0c8",
          //authDomain: "", 
          authDomain: ""   

You also need to update SAML CallbackURI manually as described in the appendix to

Once all that is done, if you use the firebaseSDK scenario, the IDP will redirect you back to the domain above which intun will send you back to your site with an initialized firebase user

Thats all folks.



The following procedure details how to update the SAMLConfig manually via API. At the moment, the UI does not allow you to modify the SAML ACS callback url so we need to update it via the API.

  • To do this, we need to first get the admin service account for your firebase project (one should exist already)
    PROJECT_NAME=$(gcloud config list --format="value(core.project)")

    $ gcloud iam service-accounts list
    NAME                                EMAIL
    App Engine default service account
  • Then get the key and activate it:
    gcloud iam service-accounts keys  create sp_firebase/svc_account.json

    gcloud auth activate-service-account  --key-file=`pwd`/sp_firebase/svc_account.json
  • Now get a token and the current config itno a file
    export TOKEN=$(gcloud auth print-access-token)

    curl -s -X GET -H 'Content-Type: application/json' -H "Authorization: Bearer $TOKEN" > update_config.json
  • Your file should look something like this:

  • update_config.json

        "name": "projects/cicp-project/inboundSamlConfigs/saml.myidp",
        "idpConfig": {
          "idpEntityId": "",
          "ssoUrl": "",
          "idpCertificates": [
              "x509Certificate": "-----BEGIN CERTIFICATE-----\nMIIDqTCCApGgAwIBAgIBBDANBgkqhkiG9w0BAQsFADBvMQswCQYDVQQGEwJVUzET\nMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEPMA0G\nA1UEChMGR29vZ2xlMRMwEQYDVQQLEwpFbnRlcnByaXNlMQ0wCwYDVQQDEwRNeUNB\nMB4XDTE4MTIxMzA1MTcyN1oXDTMyMDgyMTA1MTcyN1owZDELMAkGA1UEBhMCVVMx\nEzARBgNVBAgTCkNhbGlmb3JuaWExDzANBgNVBAoTBkdvb2dsZTETMBEGA1UECxMK\nRW50ZXJwcmlzZTEaMBgGA1UEAxMRc3NvLmlkcGRvbWFpbi5jb20wggEiMA0GCSqG\nSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDSHLQ5sYOTCWKYtYcg1G8AUS5zs/K5gd9+\nB06+zo5y671R6Bzf4HX1onfpzWU0pMfE8r2geBiL7F2mMWxPsxdGRIm2DFDbpT51\nTlcwdS9E5ThALevqMNNL9YRMxZkaCBd9Zmt0Yw5OO4DnjdmtR1ZJd14PksrKd0FA\nTOMcx949ZhUtqGljaKR9DT+Pqvv+WW94aHYkOnXr+LA4BXj/+2ikkSlFFm1ZtP8J\nCDO0JmwPOeTRrxs3rDYisDBZJ4h11tvWHbruq8KqfAOnVYNtV8R2yHdMlBrphohQ\nWVgXeBtzRmm2wXMOYHpRUqzs36Mlzn2EE3lVv7yC/0SUadqoDfnpAgMBAAGjWzBZ\nMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NMIEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAc\nBgNVHREEFTATghFzZXJ2ZXIuZG9tYWluLmNvbTALBgNVHQ8EBAMCBeAwDQYJKoZI\nhvcNAQELBQADggEBADoI8vUcEjdWVtSA6x82mNIoOilT9XLAXjKCcxG9S7+nrKc4\nvh/FunLgvGIel0qpJP3deVKiZqL8DwJMT0107I79h5TyMaVsGuxVqKhL7kC2BhZS\najf/KtXxk0FlEtYc8sqK6h5UQiwhN57StQuvowEJoKQZTnRixY3bC1Ul9b0NzNmv\nAwVpYaJZuofq0PPx5ivyxsHdMSBbG71QthIFY0Yne8kZDsDNyVwk3AlDXN4xz2fO\nKlFW5/wU8PSxuxImbu4FPjidlnMxNT8h34CrzBhfna4V8gjp4mEWRfedvLGDuZTi\nlzEsi+LxZMh83EyJqQ0PE1cOlvBpw0/5/N4NBuc=\n-----END CERTIFICATE-----"
        "spConfig": {
          "spEntityId": "",
          "callbackUri": ""
        "displayName": "myIdP",
        "enabled": true
  • Note the "callbackUri": "" value (cicp-project is the one i used, your project will be different). This is what we need to update

    • For FirebaseSDK (default): "callbackUri": ""
    • For Non FirebaseSDK: "callbackUri": ""
    • For FirebaseSDK with Custom Domain "callbackUri": "" (or which ever is your custom domain as shown above)
  • Submit a PATCH request to update

    curl -i -X PATCH -d @update_config.json  -H 'Content-Type: application/json' -H "Authorization: Bearer $TOKEN"

OpenSSL Certificate

openssl req -x509 -newkey rsa:4096 -keyout server.key -out server.crt -days 365 -nodes

This site supports webmentions. Send me a mention via this form.