I'm trying to login with Apereo CAS 5.1.1 in my react application using OIDC. Looking for libraries to achieve this, I landed on oidc-client-js 1.7.0, but I'm encountering the following error:
ResponseValidator._validateAccessToken: Failed to validate at_hash dWr5-bD5lv8C1x3VcfFn1Q dWr5+bD5lv8C1x3VcfFn1Q==
Following the trace, I found where the exception is thrown
var a = s.substr(0, s.length / 2), u = this._joseUtil.hexToBase64Url(a);
return u !== e.profile.at_hash ?
(i.Log.error("ResponseValidator._validateAccessToken: Failed to validate at_hash", u, e.profile.at_hash), Promise.reject(new Error("Failed to validate at_hash"))) :
(i.Log.debug("ResponseValidator._validateAccessToken: success"), Promise.resolve(e));
The problem is that this._joseUtil.hexToBase64Url(a)
doesn't add padding (=
) and in this particular case the +
sign. That's because those characters aren't accepted in an URL. So, the comparison always (or almost always) will be false. For example, in this execution:
dWr5-bD5lv8C1x3VcfFn1Q != dWr5+bD5lv8C1x3VcfFn1Q==
On the other hand, I think there's something I'm missing or misconfigured in my application, because otherwise every person using this library will encounter the same issue.
So, my question is: How can I successfully validate the access token in this scenario?
Thanks.