zmartzone / lua-resty-openidc

OpenID Connect Relying Party and OAuth 2.0 Resource Server implementation in Lua for NGINX / OpenResty
Apache License 2.0
965 stars 247 forks source link

Azure AD JWT groups/roles example #189

Open lukasmrtvy opened 6 years ago

lukasmrtvy commented 6 years ago

Can you please provide an example of Azure AD integration with group/roles claims from JWT? https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-protocols-oauth-code

Thanks

lukeyeager commented 1 year ago

FWIW, here's what I do:

local name = res.id_token.name local email = res.id_token.email local roles = res.id_token.roles

-- iterate through the roles looking for the one used to gate access to your upstream service local authorized = false for i, role in pairs(roles) do if role == "grafana" then authorized = true end end if authorized == false then return ngx.exit(403) end