Invalid iat parameter

Created on 16 March 2023, about 2 years ago
Updated 21 March 2023, about 2 years ago

Problem/Motivation

Single Sign On requests were failing so I reported the issue to Zendesk. After investigation they have responded that this module is sending time stamps in the wrong format e.g. "Wed Mar 15 2023 16:01:46 GMT+0000". They have stated that this "must be an integer (no decimals) and it must be in UTC. It also must be within 3 minutes of the current time when the Zendesk server receives it."

All other causes have been ruled out by Zendesk and testing using an alternative Wordpress plugin.

Steps to reproduce

Install module.
Configure Zendesk module.
Configure SSO on Zendesk.
Attempt to sign in using SSO.

🐛 Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @nathanjon123
  • Status changed to Postponed: needs info about 2 years ago
  • 🇬🇧United Kingdom joachim

    Thanks for the bug report and for investigating the problem.

    I think I've seen this too -- I'll check my project's case tracker when next at work.

    > e.g. "Wed Mar 15 2023 16:01:46 GMT+0000". They have stated that this "must be an integer (no decimals) and it must be in UTC

    What does 'integer' mean in this context? Is the example format you give an example of what we're doing wrong, or of what Zendesk should receive?

  • Thanks for the reply. This is an example of what was sent - apparently it should be standard integer with no decimals so I'm assuming Unix Timestamp

  • If it helps - two further things I've done to rule things out:

    Tried changing the following in the ZendeskSSOController.php file:

    Changed $url variable to static domain with /access/jwt - no change
    Changed getRequestTime() to getCurrentTime() - no change

  • Strangely, clearing the cache under Performance on Drupal does allow the user to login briefly to Zendesk via SSO.

  • 🇬🇧United Kingdom joachim

    That's interesting! I wonder what is getting cached that causes the problem.

    Can you step through it with a debugger to try to find out?

  • It's definitely a caching issue - Zendesk confirmed through their logs that a request iat value was the same 6 minutes later which is beyond their 3 minute tolerance.

    Unfortunately, debugging this is beyond my knowledge.

    However, what I have done to confirm it is the cache is enable the Mix module and put the site into Development mode and this fully resolves the issue which means its the either the Twig cache, backend cache or browser/proxy cache as these are disabled by the Mix module in dev mode.

  • 🇬🇧United Kingdom joachim

    > either the Twig cache, backend cache or browser/proxy cache as these are disabled by the Mix module in dev mode.

    In your settings.local.php file, copy this line:

    $settings['cache']['bins']['render'] = 'cache.backend.null';
    

    and try changing the 'render' to different values for different types of cache. The possible values are the names of the cache_* tables without the cache_ prefix.

    If it's browser cache though, I don't know how we'd fix that.

  • Looks like uncommenting this line:

    $settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';

    Fixes the issue

  • 🇬🇧United Kingdom joachim

    Interesting!
    I wonder what's getting put in the dynamic page cache to cause that.
    Thanks for investigating?

  • 🇬🇧United Kingdom joachim

    This is what we pass to zendesk:

              'iat' => \Drupal::time()->getRequestTime(),
    

    The return value of getRequestTime() is a unix timestamp.

    It looks like Zendesk support's analysis of the cause for the problem is wrong.

  • Status changed to Active about 2 years ago
  • 🇬🇧United Kingdom joachim

    I've figured it out -- the redirect to zendesk was getting cached, so users were getting a stale token, AND one that was possibly not even for their user!

    • joachim committed 05383326 on 3.0.x
      Issue #3348376 by nathanjon123, joachim: Fixed SSO errors caused by...
  • Status changed to Fixed about 2 years ago
  • 🇬🇧United Kingdom joachim

    Should be fixed. Thanks for your help figuring this out!

    Releasing a new alpha now -- please test! :)

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024