我目前正試圖通過Crossbar/Autobahn使用Websockets實現用戶通知系統。我已經做了多次試驗,並經歷的文檔,但是,我不知道是否有具有以下工作流程的解決方案:在Web應用程序使用Crossbar/Autobahn進行用戶通知的身份驗證?
- 用戶的跡象 - 這是通過JWT 完成
- Frontend建立與正在運行的
crossbar
實例的websocket連接。 - 前端嘗試訂閱特定於用戶通知的URI:即
com.example.notifications.user.23
或com.example.user.23.notifications'. Where
23`是用戶標識。 - 檢查用戶的智威湯遜是否允許用戶訪問訂閱。
- 當活動生成並導致通知時,後端發佈用戶特定的URI。
對於第3步,我不知道當前的支持auth方法是否有我需要的。理想情況下,我想要一個可以自定義的auth方法(爲了在Crossbar中實現JWT身份驗證器),我可以將其應用於URI模式,但不能將整個模式授予訂閱用戶。這是部分地由動態AUTH方法解決,但缺少後半部分:
例如(我的理想工作流程):
- 用戶嘗試訂閱URI
com.example.user.23.notifications
。 - URI
com.example.user..notifications
(在http://crossbar.io/docs/Pattern-Based-Subscriptions/通配符模式) - 驗證令牌驗證,並且用戶被給予僅
com.example.user.23.notifications
訪問相匹配。
以上是否可以通過簡單的方式實現?從我所知道的情況來看,只有當我以某種方式生成一個包含所有用戶ID的URI排列的.crossbar/config.json
...併爲每個新用戶自動生成一個新配置時纔可能 - 這完全不是一個合理的解決方案。
任何幫助表示讚賞!
的確就是這樣。我其實曾嘗試過,但我沒有意識到這是多個事件被調用。在'session','uri'和'action'中提供的數據對於我的目的來說也是不夠的,所以我已經將URI數據傳入'authorize'。 – ineedtosleep