Remora.Discord
Remora.Discord copied to clipboard
[Bug]: Different tokens share the cache
Description
When using Remora.Discord with different Bearer tokens then the cache will be shared among all tokens.
Steps to Reproduce
- Switch token used during execution
Expected Behavior
The cache should differ between token.
Current Behavior
Cache does not respect token at all.
Library / Runtime Information
Irrelevant
Do we want separate caches for separate tokens? Ideally, the data should be the same regardless of the apparent user. Is there some specific case where it differs that you've encountered?
A basic example when the cache will return wrong information for a different token is simply every URL that includes /@me/ in the URL. (https://github.com/Remora/Remora.Discord/blob/main/Backend/Remora.Discord.API.Abstractions/API/Rest/IDiscordRestUserAPI.cs#L53)
In addition it could be possible that one User Token (OAuth2 Bearer) might not have the same read permissions as another one and the cache could provide a bit to much information for that token.
Ah, I see. I'll look into integrating the token into the cache keys in some kind of hashed format so we don't leak it to external services.