get config add runtime
All checks were successful
Build and Publish / build-release (push) Successful in 1m11s
All checks were successful
Build and Publish / build-release (push) Successful in 1m11s
This commit is contained in:
@@ -3,8 +3,6 @@ defmodule PolicyService.Application do
|
|||||||
# for more information on OTP Applications
|
# for more information on OTP Applications
|
||||||
@moduledoc false
|
@moduledoc false
|
||||||
|
|
||||||
@zitadel Application.get_env(:policy_service, :zitadel)
|
|
||||||
|
|
||||||
use Application
|
use Application
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
|
|||||||
@@ -71,9 +71,6 @@ defmodule PolicyServiceWeb.Plugs.AuthorizeRoles do
|
|||||||
role = Map.get(roles_map, roles_claim, %{})
|
role = Map.get(roles_map, roles_claim, %{})
|
||||||
role
|
role
|
||||||
|
|
||||||
%{claims: claims} when is_map(claims) ->
|
|
||||||
Map.get(claims, roles_claim, %{})
|
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
%{}
|
%{}
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,13 +15,8 @@ defmodule PolicyServiceWeb.Router do
|
|||||||
plug PolicyServiceWeb.Plugs.RequireOrganizationId
|
plug PolicyServiceWeb.Plugs.RequireOrganizationId
|
||||||
plug PolicyServiceWeb.Plugs.ExtractOrganizationId
|
plug PolicyServiceWeb.Plugs.ExtractOrganizationId
|
||||||
|
|
||||||
plug Oidcc.Plug.IntrospectToken,
|
plug :introspect
|
||||||
provider: PolicyService.ZitadelProvider,
|
plug :authorize_roles
|
||||||
client_id: Application.get_env(:policy_service, :zitadel)[:client_id],
|
|
||||||
client_secret: Application.get_env(:policy_service, :zitadel)[:client_secret]
|
|
||||||
|
|
||||||
plug PolicyServiceWeb.Plugs.AuthorizeRoles,
|
|
||||||
roles_claim: Application.get_env(:policy_service, :zitadel)[:roles_claim]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
get "/health", HealthController, :health
|
get "/health", HealthController, :health
|
||||||
@@ -50,4 +45,18 @@ defmodule PolicyServiceWeb.Router do
|
|||||||
scope "/swaggerui" do
|
scope "/swaggerui" do
|
||||||
get "/", OpenApiSpex.Plug.SwaggerUI, path: "/api/openapi"
|
get "/", OpenApiSpex.Plug.SwaggerUI, path: "/api/openapi"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def introspect(conn, _opts) do
|
||||||
|
zitadel = Application.get_env(:policy_service, :zitadel)
|
||||||
|
|
||||||
|
{Oidcc.Plug.IntrospectToken,
|
||||||
|
provider: PolicyService.ZitadelProvider,
|
||||||
|
client_id: zitadel[:client_id],
|
||||||
|
client_secret: zitadel[:client_secret]}
|
||||||
|
end
|
||||||
|
|
||||||
|
def authorize_roles(conn, _opts) do
|
||||||
|
zitadel = Application.get_env(:policy_service, :zitadel)
|
||||||
|
{PolicyServiceWeb.Plugs.AuthorizeRoles, roles_claim: zitadel[:roles_claim]}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user