channels_redis icon indicating copy to clipboard operation
channels_redis copied to clipboard

support microsoft entra id for authentication with azure cache for redis

Open dimbleby opened this issue 10 months ago • 1 comments

Azure cache for redis supports authentication using microsoft entra tokens, it would be great if I could make use of that with django + channels

https://learn.microsoft.com/en-us/azure/azure-cache-for-redis/cache-azure-active-directory-for-authentication#microsoft-entra-client-workflow describes what the client needs to do

presumably would need a bit of extra configuration ENTRA_USER or somesuch, and logic per that link.

I am afraid I am unlikely to contribute this myself but open this anyway in case either: you want to shut it down immediately or, more optimistically, it catches the attention of someone who would like to implement it.

dimbleby avatar Apr 17 '24 09:04 dimbleby

channels_redis only passes along what each hosts entry is to the redis async client if it is a dictionary (ignoring the address or tuple shortcut).

Much of the headache comes from managing reauthentication, as otherwise they state to pass in the Object ID and the Entra token as username and password respectively.

Passing in a credential_provider that handles the token refresh should be a good start. I am unsure how to handle the required AUTH call to Redis itself. Perhaps health_check_interval or retry but that is deeper into redis-py than I am familiar with. Asking in redis-py itself might provide a better answer (I came up empty looking for Entra related things 😞).

channels_redis isn't quite the layer that is at fault here, but with the correct dictionary passed into hosts (for redis-py to use) everything should be happy.

bbrowning918 avatar Apr 23 '24 19:04 bbrowning918