How to get all sign-in attributes while authenticating using SAML through firebase?

140 Views Asked by At
  • React app is using firebase for SSO authentication with SAML

Example code -

export async function signInWithRedirectToProvider(providerId) {
  const auth = getAuth();
  const provider = new SAMLAuthProvider(providerId);
  await signInWithRedirect(auth, provider);
}

In the next step - just as mentioned in the documents

firebase.auth().getRedirectResult()
  .then((result) => {
    // User is signed in.

    // Provider data available in result.additionalUserInfo.profile,
    // or from the user's ID token obtained from result.user.getIdToken()
    // as an object in the firebase.sign_in_attributes custom claim.
  })
  .catch((error) => {
    // Handle error.
  });

Final Step -
We retrieve the user attributes associated with the SAML provider from the ID token using the firebase.sign_in_attributes claim.

However, the firebase.sign_in_attributes claim doesn't contain all the attributes those are received from the SAML assertions.

For example, the application I am working on needs to get university users data and it contains user role.

Name="urn:mace:dir:attribute-def:eduPersonAffiliation"
It seems the SAML assertion contains the attribute but firebase.sign_in_attributes claim excludes this attribute somehow while other attributes are present.

So, basically I am stuck here, any help in the right direction would be much appreciated!
Thanks!

I tried tracing the logs from SAML calls and I can see the attributes there and however after firebase authentication some of the attributes are not there as the end response I receive in my application.

0

There are 0 best solutions below