Mercurial > prosody-modules
annotate mod_groups_oidc/mod_groups_oidc.lua @ 5748:dfbced5e54b9
mod_audit_auth: Ignore FAST authentication events by default
FAST is more like a cookie that allows linking new connections to a previous
(e.g. password) authentication. Since we assume that FAST tokens are secure
(not user generated) and not shareable, it reduces a lot of noise by filtering
out uninteresting authentication events.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 01 Dec 2023 11:34:52 +0000 |
parents | 7d9dce4e7dd0 |
children |
rev | line source |
---|---|
5504
7d9dce4e7dd0
mod_groups_oidc: Expose groups to OAuth clients
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
1 local array = require "util.array"; |
7d9dce4e7dd0
mod_groups_oidc: Expose groups to OAuth clients
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
2 |
7d9dce4e7dd0
mod_groups_oidc: Expose groups to OAuth clients
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
3 module:add_item("openid-claim", "groups"); |
7d9dce4e7dd0
mod_groups_oidc: Expose groups to OAuth clients
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
4 |
7d9dce4e7dd0
mod_groups_oidc: Expose groups to OAuth clients
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
5 local group_memberships = module:open_store("groups", "map"); |
7d9dce4e7dd0
mod_groups_oidc: Expose groups to OAuth clients
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
6 local function user_groups(username) |
7d9dce4e7dd0
mod_groups_oidc: Expose groups to OAuth clients
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
7 return pairs(group_memberships:get_all(username) or {}); |
7d9dce4e7dd0
mod_groups_oidc: Expose groups to OAuth clients
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
8 end |
7d9dce4e7dd0
mod_groups_oidc: Expose groups to OAuth clients
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
9 |
7d9dce4e7dd0
mod_groups_oidc: Expose groups to OAuth clients
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
10 module:hook("token/userinfo", function(event) |
7d9dce4e7dd0
mod_groups_oidc: Expose groups to OAuth clients
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
11 local userinfo = event.userinfo; |
7d9dce4e7dd0
mod_groups_oidc: Expose groups to OAuth clients
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
12 if event.claims:contains("groups") then |
7d9dce4e7dd0
mod_groups_oidc: Expose groups to OAuth clients
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
13 userinfo.groups = array(user_groups(event.username)); |
7d9dce4e7dd0
mod_groups_oidc: Expose groups to OAuth clients
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
14 end |
7d9dce4e7dd0
mod_groups_oidc: Expose groups to OAuth clients
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
15 end); |