Skip to content

Commit

Permalink
Expose listing sites via Sites API to all API keys
Browse files Browse the repository at this point in the history
  • Loading branch information
zoldar committed Jul 1, 2024
1 parent f003173 commit 8433332
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/plausible_web/plugs/authorize_api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ defmodule PlausibleWeb.AuthorizeApiPlug do
alias PlausibleWeb.Api.Helpers, as: H

# Scopes permitted implicitly for every API key
@implicit_scopes ["stats:read:*"]
@implicit_scopes ["stats:read:*", "sites:read:*"]

def init(opts) do
opts
Expand Down
7 changes: 6 additions & 1 deletion lib/plausible_web/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,19 @@ defmodule PlausibleWeb.Router do
scope "/api/v1/sites", PlausibleWeb.Api do
pipe_through :public_api

scope assigns: %{api_scope: "sites:read:*"} do
pipe_through PlausibleWeb.AuthorizeApiPlug

get "/:site_id", ExternalSitesController, :get_site
end

scope assigns: %{api_scope: "sites:provision:*"} do
pipe_through PlausibleWeb.AuthorizeApiPlug

post "/", ExternalSitesController, :create_site
put "/shared-links", ExternalSitesController, :find_or_create_shared_link
put "/goals", ExternalSitesController, :find_or_create_goal
delete "/goals/:goal_id", ExternalSitesController, :delete_goal
get "/:site_id", ExternalSitesController, :get_site
put "/:site_id", ExternalSitesController, :update_site
delete "/:site_id", ExternalSitesController, :delete_site
end
Expand Down

0 comments on commit 8433332

Please sign in to comment.