Skip to content

Commit 1dc5968

Browse files
committed
feat: create global enforce whitelist
1 parent 95d3da4 commit 1dc5968

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

front/lib/front_web/controllers/settings_controller.ex

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,28 @@ defmodule FrontWeb.SettingsController do
9090
)
9191
end
9292

93+
def confirm_enforce_workflow(conn, _params) do
94+
org_id = conn.assigns.organization_id
95+
96+
case Models.OrganizationSettings.modify(org_id, %{"enforce_whitelist" => "true"}) do
97+
{:ok, _updated_settings} ->
98+
conn
99+
|> put_flash(:notice, "Whitelist enforcement applied successfully.")
100+
|> redirect(to: settings_path(conn, :show))
101+
102+
{:error, changeset} ->
103+
errors =
104+
changeset.errors |> Enum.map(fn {field, {message, _}} -> "#{field}: #{message}" end)
105+
106+
conn
107+
|> put_flash(:errors, errors)
108+
|> put_flash(:alert, "Failed to apply whitelist enforcement.")
109+
|> redirect(to: settings_path(conn, :show))
110+
end
111+
112+
redirect(conn, to: settings_path(conn, :show))
113+
end
114+
93115
def confirm_delete(conn, _params) do
94116
org_id = conn.assigns.organization_id
95117

front/lib/front_web/router.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ defmodule FrontWeb.Router do
126126

127127
get("/settings/confirm_delete", SettingsController, :confirm_delete)
128128

129+
get("/settings/confirm_enforce", SettingsController, :confirm_enforce_workflow)
130+
129131
delete("/settings", SettingsController, :destroy)
130132

131133
get("/jwt_config", OrganizationJWTConfigController, :show)

front/lib/front_web/templates/settings/show.html.eex

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@
3737
</div>
3838
<% end %>
3939
</div>
40+
<div class="pv3 bt b--lighter-gray">
41+
<div class="db b">Whitelist Enforcement</div>
42+
<p class="measure mb2">Applies new Whitelist rules to old tags and branches</p>
43+
<div>
44+
<%= link "Enforce Whitelist", to: settings_path(@conn, :confirm_enforce_workflow), class: "btn btn-secondary danger" %>
45+
</div>
46+
</div>
4047
<%= if FeatureProvider.feature_enabled?(:multiple_organizations, param: @conn.assigns[:organization_id]) do %>
4148
<%= if @permissions["organization.delete"] do %>
4249
<div class="pt3 bt b--lighter-gray">

0 commit comments

Comments
 (0)