Skip to content

Commit

Permalink
feat: use config roles and add permissions for publish_notice and db_…
Browse files Browse the repository at this point in the history
…dump
  • Loading branch information
meagharty committed Feb 8, 2024
1 parent 4df9f91 commit bd1c055
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ config :arrow,
update_disruption: ["admin"],
delete_disruption: ["admin"],
create_note: ["admin"],
view_change_feed: ["admin"]
view_change_feed: ["admin"],
publish_notice: ["admin"],
db_dump: ["admin"]
},
time_zone: "America/New_York",
ex_aws_requester: {Fake.ExAws, :admin_group_request},
Expand Down
2 changes: 2 additions & 0 deletions lib/arrow/permissions.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ defmodule Arrow.Permissions do
| :update_disruption
| :delete_disruption
| :view_change_feed
| :publish_notice
| :db_dump

@spec authorize(action(), User.t()) :: :ok | {:error, :unauthorized}
def authorize(action, user) do
Expand Down
3 changes: 3 additions & 0 deletions lib/arrow_web/controllers/api/db_dump_controller.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
defmodule ArrowWeb.API.DBDumpController do
alias ArrowWeb.Plug.Authorize
use ArrowWeb, :controller

plug(Authorize, :db_dump)

@spec show(Plug.Conn.t(), map()) :: Plug.Conn.t()
def show(conn, _params) do
json(conn, Arrow.DBStructure.dump_data())
Expand Down
3 changes: 3 additions & 0 deletions lib/arrow_web/controllers/api/notice_controller.ex
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
defmodule ArrowWeb.API.NoticeController do
alias ArrowWeb.Plug.Authorize
use ArrowWeb, :controller
require Logger

plug(Authorize, :publish_notice)

@spec publish(Plug.Conn.t(), map()) :: Plug.Conn.t()
def publish(conn, params) do
revision_ids = params["revision_ids"] |> String.split(",") |> Enum.map(&String.to_integer/1)
Expand Down

0 comments on commit bd1c055

Please sign in to comment.