分类

链接

2025 年 8 月
 123
45678910
11121314151617
18192021222324
25262728293031

近期文章

热门标签

新人福利,免费薅羊毛

authentic如何把roles返回给sso客户端

在 authentik 中,Role 并不是直接挂在 User 对象上的,而是: User → Group → Role。 所以要想拿到“用户真正拥有的所有 Role”,必须先遍历用户所在的 Group,再把每个 Group 关联的 Role 收集起来并去重。 把你的映射改成下面这样即可(已用你当前可用的变量名 user 和 request.user 做了兼容): # 取用户所在的所有组的所有角色,去重后返回 roles = set() for group in request.user.ak_groups.all(): roles.update(group.roles.all()) return { "_debug_all_attrs": list(user.attributes.ke...

Python 暂无评论 阅读(3)