django / channels_redis

Redis channel layer backend for Django Channels

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

support microsoft entra id for authentication with azure cache for redis

dimbleby opened this issue · 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.

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.