Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caching requests while authenticating as an Integration #947

Open
PhiloNL opened this issue Dec 10, 2020 · 0 comments
Open

Caching requests while authenticating as an Integration #947

PhiloNL opened this issue Dec 10, 2020 · 0 comments

Comments

@PhiloNL
Copy link

PhiloNL commented Dec 10, 2020

Not sure if this is a bug or something which should be added to the documentation.
When caching requests the cache key is based on a couple of request headers (#558). I'm assuming this works fine when using AUTH_ACCESS_TOKEN for authentication as this token does not change.

When authenticating as an integration it's required to include a JSON Web Token which is valid for a few seconds up to a couple of minutes (I think 10 minutes is the limit). I'm always including a new JWT token which works fine but I'm guessing this is causing trouble with caching since the cache key is changing on every request because the Authorization header has changed (new JWT token).

Replacing the Authorization header on the HeaderCacheKeyGenerator with the installation id seems like a good alternative:

        $builder = new Builder();
        $builder->addHeaderValue('Installation-id', $installationId);

        $client = new Client($builder, 'machine-man-preview');
        $client->addCache($pool, [
                'cache_key_generator' => new HeaderCacheKeyGenerator([
                    'Installation-id',
                    'Cookie',
                    'Accept',
                    'Content-type',
                ]),
            ]
        );

Not sure if there is a better alternative to fix this.
Let me know if you want me to create PR to update the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant