IBM Verify Identity Access (IVIA) Single Sign On with Google Social Identity Provider
Single Sign-On (SSO) simplifies authentication by allowing users to log in once and access multiple applications without repeatedly entering credentials. IBM Verify Identity Access (IVIA) supports various authentication methods, including federated authentication with social identity providers like Google
In this blog, we will walk through the steps to integrate IVIA with Google as a social identity provider using OpenID Connect (OIDC). This integration enables users to log in to IVIA-protected applications using their Google credentials
Prerequisites
Before you begin, ensure you have the following:
- An active Google Cloud account with an sample project
- IVIA activated with base & federation module
- Add below mapping rule in your IVIA environment
i) Go to Federation → Mapping Rules
ii) Click on +Add button , paste given code and select type as OIDC, you could name it as per your requirements, if you are following along name it as “GoogleIdentityMapping”
iii) Mapping Rule Code
importPackage(Packages.com.tivoli.am.fim.trustserver.sts);
importPackage(Packages.com.tivoli.am.fim.trustserver.sts.uuser);
importClass(Packages.com.ibm.security.access.httpclient.HttpClientV2);
importClass(Packages.com.ibm.security.access.httpclient.HttpResponse);
importClass(Packages.com.ibm.security.access.httpclient.Headers);
var accessTokenAttr = stsuu.getContextAttributes().getAttributeByName("access_token");
if (accessTokenAttr == null || accessTokenAttr.getValues().length === 0) {
throw "No access token received from Google.";
}
var accessToken = accessTokenAttr.getValues()[0];
var headers = new Headers();
headers.addHeader("Authorization", "Bearer " + accessToken);
var userInfoUrl = "https://www.googleapis.com/oauth2/v3/userinfo";
var response = HttpClientV2.httpGet(userInfoUrl, headers, null, null, null, null, null);
if (response == null) {
throw "No response from Google user info endpoint.";
}
var statusCode = response.getCode();
if (statusCode !== 200) {
throw "Failed to retrieve Google user info. HTTP Code: " + statusCode;
}
var responseBody = response.getBody();
var userInfo = JSON.parse(responseBody);
if (!userInfo || !userInfo.sub) {
throw "Google user information is incomplete.";
}
if (!userInfo.email_verified) {
throw "User's email is not verified.";
}
stsuu.setPrincipalName(userInfo.email);
Steps to Integrate Google as an Identity Provider
1.Configure Federation OIDC Relying Party in IVIA
i) Go to Federation → Federations
ii) Click on +Add button