configure introspection correctly
Some checks failed
Build and Publish / build-release (push) Failing after 28s
Some checks failed
Build and Publish / build-release (push) Failing after 28s
This commit is contained in:
@@ -67,8 +67,8 @@ defmodule PolicyServiceWeb.Plugs.AuthorizeRoles do
|
||||
|
||||
defp get_roles_map(conn, roles_claim) do
|
||||
case conn.private[Oidcc.Plug.IntrospectToken] do
|
||||
%{claims: %{^roles_claim => %{} = roles_map}} ->
|
||||
role = Map.get(roles_map, roles_claim, %{})
|
||||
%{extra: %{^roles_claim => %{} = roles_map}} ->
|
||||
Map.get(roles_map, roles_claim, %{})
|
||||
role
|
||||
|
||||
_ ->
|
||||
|
||||
@@ -15,7 +15,7 @@ defmodule PolicyServiceWeb.Router do
|
||||
plug PolicyServiceWeb.Plugs.RequireOrganizationId
|
||||
plug PolicyServiceWeb.Plugs.ExtractOrganizationId
|
||||
|
||||
plug :validate
|
||||
plug :introspect
|
||||
plug :authorize_roles
|
||||
end
|
||||
|
||||
@@ -46,17 +46,18 @@ defmodule PolicyServiceWeb.Router do
|
||||
get "/", OpenApiSpex.Plug.SwaggerUI, path: "/api/openapi"
|
||||
end
|
||||
|
||||
def validate(conn, _opts) do
|
||||
def introspect(conn, _opts) do
|
||||
zitadel = Application.get_env(:policy_service, :zitadel)
|
||||
|
||||
opts =
|
||||
Oidcc.Plug.ValidateJwtToken.init(
|
||||
Oidcc.Plug.IntrospectToken.init(
|
||||
provider: PolicyService.ZitadelProvider,
|
||||
client_id: zitadel[:client_id],
|
||||
client_secret: zitadel[:client_secret]
|
||||
client_secret: zitadel[:client_secret],
|
||||
token_introspection_opts: %{client_self_only: false}
|
||||
)
|
||||
|
||||
Oidcc.Plug.ValidateJwtToken.call(
|
||||
Oidcc.Plug.IntrospectToken.call(
|
||||
conn,
|
||||
opts
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user