Skip to content

Google

Google is an identity-provider option for Process Focus. For the shared registration behaviour, see Single-Sign-On (SSO).

Setting up a Google Workspace identity provider requires injecting two secrets. We recommend you use the configureOrg method to do that, as this will provide proper error feedback when configuration is missing.

Export configureOrg as an Effect to load the required configuration. When the runtime executes it, a missing value fails configuration with an error identifying the missing key. See Configuration for how Config, yield*, and configureOrg work together.

import { AuthenticationConfig } from "@pf/auth-config"
import { Organisation } from "@pf/process"
import { Config, Effect } from "effect"
export const org = new Organisation({ name: "My organisation" })
export const configureOrg = Effect.gen(function* () {
const googleClientId = yield* Config.String("GOOGLE_CLIENT_ID")
const googleClientSecret = yield* Config.String("GOOGLE_CLIENT_SECRET")
new AuthenticationConfig(org, "auth", {
identityProviders: {
google: {
clientID: googleClientId,
clientSecret: googleClientSecret,
scopes: ["openid", "email", "profile"],
},
},
})
return org
})

You need two pieces of configuration here:

  1. Client ID.
  2. Client secret.

Google doesn’t make creating these values easy. Detailed steps are in the next section.

This configuration does not allow anyone to log in yet, unless they have an invitation.

If you use organisational units in your Google Directory, it’s possible to use them as well. For example, you could surface the organisational unit as the role. That makes Process Focus seamless: a new user logs in and is immediately assigned the right role based on the organisational unit they are in.

The role construct IDs must match the Google organisational unit paths. For example, a role with ID Office Staff directly under the organisation has the path /Office Staff.

import { AuthenticationConfig } from "@pf/auth-config"
import { Organisation, Role } from "@pf/process"
import { Config, Effect } from "effect"
export const org = new Organisation({ name: "My organisation" })
export const officeStaff = new Role(org, "Office Staff")
export const supportStaff = new Role(org, "Support Staff")
export const management = new Role(org, "Management")
export const configureOrg = Effect.gen(function* () {
const googleClientId = yield* Config.String("GOOGLE_CLIENT_ID")
const googleClientSecret = yield* Config.String("GOOGLE_CLIENT_SECRET")
const googleServiceAccountKey = yield* Config.String("GOOGLE_SERVICE_ACCOUNT_KEY")
const googleAdminEmail = yield* Config.String("GOOGLE_ADMIN_EMAIL")
new AuthenticationConfig(org, "auth", {
identityProviders: {
google: {
clientID: googleClientId,
clientSecret: googleClientSecret,
scopes: ["openid", "email", "profile"],
invitedOrgUnits: [
"/Office Staff",
"/Support Staff",
"/Management",
],
orgUnitAsRole: true,
serviceAccountKey: googleServiceAccountKey,
adminEmail: googleAdminEmail,
},
},
})
return org
})

The OAuth client signs users in. Process Focus uses a separate service account to look up their organisational unit in Google Directory.

  1. In Google Cloud, enable the Admin SDK API in the project that owns the service account. Create a service account and download a JSON key for it.
  2. In the Google Admin console, have a Workspace super administrator set up domain-wide delegation for the service account’s numeric client ID. Grant it only https://www.googleapis.com/auth/admin.directory.user.readonly. Leave the sign-in scopes in the example unchanged.
  3. In your Process Focus environment, set GOOGLE_SERVICE_ACCOUNT_KEY to the Base64-encoded contents of the downloaded JSON key and store it as a secret. Set GOOGLE_ADMIN_EMAIL to the email address of a Workspace administrator who can read the relevant users in Directory. Process Focus makes the lookup on behalf of that administrator.

List the exact Google organisational unit paths in invitedOrgUnits. Set orgUnitAsRole: true if you also want to assign matching Process Focus roles on first sign-in.

In the example above, invitedOrgUnits acts as an invitation for anyone whose Google Workspace organisational unit exactly matches a listed path. On their first Google sign-in, Process Focus checks their unit in Google Directory. Someone in /Office Staff can sign in to the Dashboard without a separate invitation or registration link. With orgUnitAsRole enabled, they also receive the matching Office Staff role unless an explicit invitation supplies their roles.

Listing /Office Staff does not invite members of its child units. Add each child path separately or create an individual invitation.

You can still use Google for SSO even if you don’t use Google Directory. Create an OAuth token as per the next section, and select External for Audience when creating the app in your project.

The steps below summarise the process; Google’s console changes often:

  1. Log in to the Google Console.

  2. Create a project: it’s best to create a new project for every new app or project.

  3. Select that project.

  4. Go to the credentials page. For a new project (which you should have created), you will need to start creating an app, so click “Get started”:

    Google auth platform setup prompt with Get started button

  5. Create an app by providing a name. Note you can have only one app per project.

  6. Then, for Audience, select Internal if you rely on your Google Workspace Directory, or External if you want to use Google purely as social login. For external apps, you can add a list of Gmail addresses which should have access.

  7. Follow the instructions, or go to the Clients page to create an OAuth client.

    Google Cloud credentials page showing OAuth 2.0 client IDs

  8. Click Create credentials and select OAuth client ID:

    Create credentials menu with OAuth client ID selected

  9. For Application type, select “Web application”. For Authorised redirect URIs supply a list of callbacks, for example for local testing, a localhost and port. You can also pass in URLs created when deploying via the Process Focus Cloud Console, or if you use custom domains, those as well.

    Google OAuth web application client configuration with authorised redirect URIs

    Then press Create (or Save when editing).

  10. Click Download JSON to store the credentials locally, and your agent will then know how to use this to configure your SSO in Process Focus:

    OAuth client created dialog with Download JSON button; credentials redacted