Files
firezone/elixir/apps/api/lib/api/router.ex
Brian Manifold 79c815fbbc feat(portal): Add REST API (#5579)
Why:

* In order to manage a large number of Firezone Sites, Resources,
Policies, etc... a REST API is needed as clicking through the UI is too
time consuming, as well as prone to error. By providing a REST API
Firezone customers will be able to manage things within their Firezone
accounts with code.
2024-07-20 04:20:43 +00:00

73 lines
2.0 KiB
Elixir

defmodule API.Router do
use API, :router
pipeline :api do
plug Plug.Parsers,
parsers: [:json],
pass: ["*/*"],
json_decoder: Phoenix.json_library()
plug :accepts, ["json"]
plug API.Plugs.Auth
end
pipeline :public do
plug :accepts, ["html", "xml", "json"]
end
pipeline :openapi do
plug OpenApiSpex.Plug.PutApiSpec, module: API.ApiSpec
end
scope "/openapi" do
pipe_through :openapi
get "/", OpenApiSpex.Plug.RenderSpec, []
end
scope "/swaggerui" do
pipe_through :public
get "/", OpenApiSpex.Plug.SwaggerUI, path: "/openapi"
end
scope "/", API do
pipe_through :public
get "/healthz", HealthController, :healthz
end
scope "/", API do
pipe_through :api
resources "/resources", ResourceController, except: [:new, :edit]
resources "/policies", PolicyController, except: [:new, :edit]
resources "/gateway_groups", GatewayGroupController, except: [:new, :edit] do
post "/tokens", GatewayGroupController, :create_token
delete "/tokens", GatewayGroupController, :delete_all_tokens
delete "/tokens/:id", GatewayGroupController, :delete_token
resources "/gateways", GatewayController, except: [:new, :edit, :create, :update]
end
resources "/actors", ActorController, except: [:new, :edit] do
resources "/identities", IdentityController, except: [:new, :edit, :update]
post "/providers/:provider_id/identities/", IdentityController, :create
end
resources "/actor_groups", ActorGroupController, except: [:new, :edit] do
get "/memberships", ActorGroupMembershipController, :index
put "/memberships", ActorGroupMembershipController, :update_put
patch "/memberships", ActorGroupMembershipController, :update_patch
end
resources "/identity_providers", IdentityProviderController, only: [:index, :show, :delete]
end
scope "/integrations", API.Integrations do
scope "/stripe", Stripe do
post "/webhooks", WebhookController, :handle_webhook
end
end
end