Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

CRM: Expose Team SSO Policy (#5681)

Adam Rutkowskib48463ca65a1
diff --git a/extra/lib/plausible/audit.ex b/extra/lib/plausible/audit.ex
index e29719e459..7c7c2e1efd 100644
--- a/extra/lib/plausible/audit.ex
+++ b/extra/lib/plausible/audit.ex
@@ -17,12 +17,12 @@ defmodule Plausible.Audit do
def list_entries_paginated(attrs, params \\ %{}) do
attrs
|> entries_query()
- |> Plausible.Pagination.paginate(params, cursor_fields: [{:datetime, :asc}])
+ |> Plausible.Pagination.paginate(params, cursor_fields: [{:datetime, :desc}])
end
defp entries_query(attrs) do
from ae in Plausible.Audit.Entry,
where: ^attrs,
- order_by: [asc: :datetime]
+ order_by: [desc: :datetime]
end
end
diff --git a/extra/lib/plausible_web/live/customer_support/team/components/sso.ex b/extra/lib/plausible_web/live/customer_support/team/components/sso.ex
index 6c321194ca..ed4d816dbb 100644
--- a/extra/lib/plausible_web/live/customer_support/team/components/sso.ex
+++ b/extra/lib/plausible_web/live/customer_support/team/components/sso.ex
@@ -13,29 +13,23 @@ defmodule PlausibleWeb.CustomerSupport.Team.Components.SSO do
def render(assigns) do
~H"""
- <div class="mt-4 mb-4 text-gray-900 dark:text-gray-400">
+ <div>
<div :if={@sso_integration}>
- <div class="flex gap-x-8 mb-4 justify-between items-start">
- <p>
- Configured?: <code>{SSO.Integration.configured?(@sso_integration)}</code>
- <br /> IDP Signin URL:
- <code>
- {@sso_integration.config.idp_signin_url}
- </code>
- <br />IDP Entity ID: <code>{@sso_integration.config.idp_entity_id}</code>
- </p>
- <div class="ml-auto">
- <.button
- data-confirm="Are you sure you want to remove this SSO team integration, including all its domains and users?"
- id="remove-sso-integration"
- phx-click="remove-sso-integration"
- phx-target={@myself}
- theme="danger"
- >
- Remove Integration
- </.button>
- </div>
+ <div class="mt-4 mb-4 text-gray-900 dark:text-gray-400">
+ <.table rows={
+ [
+ {"configured?", SSO.Integration.configured?(@sso_integration)},
+ {"IDP Sign-in URL", @sso_integration.config.idp_signin_url},
+ {"IDP Entity ID", @sso_integration.config.idp_entity_id}
+ ] ++ Enum.into(Map.from_struct(@team.policy), [])
+ }>
+ <:tbody :let={{k, v}}>
+ <.td>{k}</.td>
+ <.td>{v}</.td>
+ </:tbody>
+ </.table>
</div>
+
<.table rows={@sso_integration.sso_domains}>
<:thead>
<.th>Domain</.th>
@@ -67,6 +61,18 @@ defmodule PlausibleWeb.CustomerSupport.Team.Components.SSO do
</.td>
</:tbody>
</.table>
+
+ <div class="flex justify-end">
+ <.button
+ data-confirm="Are you sure you want to remove this SSO team integration, including all its domains and users?"
+ id="remove-sso-integration"
+ phx-click="remove-sso-integration"
+ phx-target={@myself}
+ theme="danger"
+ >
+ Remove Integration
+ </.button>
+ </div>
</div>
<div :if={!@sso_integration} class="text-center py-8 text-gray-500">
<p>No SSO integration configured for this team.</p>
diff --git a/test/plausible_web/live/customer_support/teams_test.exs b/test/plausible_web/live/customer_support/teams_test.exs
index 8f12c4fc8e..22258fd69f 100644
--- a/test/plausible_web/live/customer_support/teams_test.exs
+++ b/test/plausible_web/live/customer_support/teams_test.exs
@@ -592,7 +592,7 @@ defmodule PlausibleWeb.Live.CustomerSupport.TeamsTest do
assert element_exists?(html, ~s|a[href="?tab=sso"]|)
end
- test "sso tab displays domains", %{conn: conn, user: user} do
+ test "sso tab displays domains and policy/idp config", %{conn: conn, user: user} do
team = team_of(user)
integration = SSO.initiate_saml_integration(team)
@@ -602,10 +602,12 @@ defmodule PlausibleWeb.Live.CustomerSupport.TeamsTest do
{:ok, lv, _html} = live(conn, open_team(team.id, tab: :sso))
- html = render(lv)
+ text = lv |> render() |> text()
- assert html =~ "sso1.example.com"
- assert html =~ "sso2.example.com"
+ assert text =~ "sso1.example.com"
+ assert text =~ "sso2.example.com"
+ assert text =~ "configured? false"
+ assert text =~ "sso_session_timeout_minutes 360"
end
test "delete domain", %{conn: conn, user: user} do
@@ -735,7 +737,7 @@ defmodule PlausibleWeb.Live.CustomerSupport.TeamsTest do
entity: "Plausible.Teams.Team",
entity_id: to_string(team.id),
team_id: team.id,
- datetime: NaiveDateTime.shift(now, second: i)
+ datetime: NaiveDateTime.shift(now, second: 8 - i)
}
|> Plausible.Repo.insert!()
end