From d9c7d4d90b964313e582c551ce71e865b7d6f72a Mon Sep 17 00:00:00 2001 From: "juvenal.diaz" Date: Sat, 5 Dec 2026 08:18:22 -0600 Subject: [PATCH] Add OpsProof Dex sign-in page --- apps/opsproof/README.md | 4 +- .../handlers/authentication/authentication.go | 8 ++++ .../overlay/resources/js/pages/SignIn.tsx | 39 +++++++++++++++++++ apps/opsproof/overlay/routes/web.go | 1 + .../tests/feature/authentication_test.go | 2 + bootstrap/edge/templates/default.conf.tftpl | 2 +- .../jeannie/test_privacy_services_pipeline.py | 3 +- 7 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 apps/opsproof/overlay/resources/js/pages/SignIn.tsx diff --git a/apps/opsproof/README.md b/apps/opsproof/README.md index d484b57..1f27272 100644 --- a/apps/opsproof/README.md +++ b/apps/opsproof/README.md @@ -72,7 +72,9 @@ an authenticated operator supplies that rollback procedure. Operator mode uses a dedicated Dex OAuth client through Laravel Go's social provider support. The authorization-code flow uses PKCE and server-side -sessions. Only verified identities in `LAB_OPSPROOF_OPERATOR_EMAILS` may sign +sessions. `/login` presents the operator boundary before `/auth/dex` starts the +external authorization flow. Only verified identities in +`LAB_OPSPROOF_OPERATOR_EMAILS` may sign in; when the variable is omitted, the pipeline defaults to the committed Dex user identity. Incident and future mutation routes require both authentication and current membership in that allowlist. The overview remains a read-only diff --git a/apps/opsproof/overlay/handlers/authentication/authentication.go b/apps/opsproof/overlay/handlers/authentication/authentication.go index e235613..bb681d0 100644 --- a/apps/opsproof/overlay/handlers/authentication/authentication.go +++ b/apps/opsproof/overlay/handlers/authentication/authentication.go @@ -11,6 +11,7 @@ import ( "go.laravel.com/auth" "go.laravel.com/auth/social" "go.laravel.com/db" + "go.laravel.com/inertia" "go.laravel.com/model" "go.laravel.com/web" @@ -20,6 +21,13 @@ import ( const dexProvider social.Provider = "dex" func Login(request *web.Request) *web.Response { + return inertia.Render("SignIn", inertia.Props{ + "provider": "Dex", + "notice": "Operator access uses the homelab identity provider. OpsProof never receives or stores your Dex password.", + }) +} + +func Start(request *web.Request) *web.Response { return social.Redirect(request, dexProvider) } diff --git a/apps/opsproof/overlay/resources/js/pages/SignIn.tsx b/apps/opsproof/overlay/resources/js/pages/SignIn.tsx new file mode 100644 index 0000000..867a4ca --- /dev/null +++ b/apps/opsproof/overlay/resources/js/pages/SignIn.tsx @@ -0,0 +1,39 @@ +export default function SignInPage({ provider, notice }: { provider: string; notice: string }) { + return ( +
+
+
+
+ + ← Public demonstration + +
OP
+

OpsProof operator access

+

Sign in to the live workspace

+

{notice}

+
+ +
+
+

Authenticated capabilities

+
    +
  • • Read live status and focused Doctor evidence through Jeannie
  • +
  • • Review exact remediation, risk, preconditions, and rollback
  • +
  • • Approve one constrained execution and retain its validation report
  • +
+
+ + + Continue with {provider} + +

+ Access is restricted to verified identities in the server-side operator allowlist. +

+
+
+
+ ); +} diff --git a/apps/opsproof/overlay/routes/web.go b/apps/opsproof/overlay/routes/web.go index cde37a6..f7513e7 100644 --- a/apps/opsproof/overlay/routes/web.go +++ b/apps/opsproof/overlay/routes/web.go @@ -22,6 +22,7 @@ func Web(route *routing.Router, cfg *config.Config) { route.Get("/", welcome.Show) route.Get("/demo", demo.Show) route.Get("/login", authentication.Login).Name("login") + route.Get("/auth/dex", authentication.Start) route.Get("/auth/dex/callback", authentication.Callback) route.Post("/logout", authentication.Logout).Middleware(auth.Authenticate{}, appmiddleware.Operator{}) diff --git a/apps/opsproof/overlay/tests/feature/authentication_test.go b/apps/opsproof/overlay/tests/feature/authentication_test.go index 3068b5b..f18d1aa 100644 --- a/apps/opsproof/overlay/tests/feature/authentication_test.go +++ b/apps/opsproof/overlay/tests/feature/authentication_test.go @@ -18,6 +18,7 @@ func TestDexLoginRequiresAnAllowedVerifiedOperator(t *testing.T) { })) client.WithoutRedirects().Get("/incidents/cluster/n8n").AssertRedirect("/login") + client.Get("/login").AssertOK().AssertInertia("SignIn").AssertProp("provider", "Dex") allowed := client.FakeSocial("dex", &social.Profile{ ID: "dex-operator", @@ -25,6 +26,7 @@ func TestDexLoginRequiresAnAllowedVerifiedOperator(t *testing.T) { Email: "operator@example.test", EmailVerified: true, }) + allowed.WithoutRedirects().Get("/auth/dex").AssertRedirect() allowed.WithoutRedirects().Get("/auth/dex/callback").AssertRedirect("http://example.com/incidents/cluster/n8n") allowed.Get("/").AssertOK().AssertInertia("Welcome").AssertProp("operator.authenticated", true) } diff --git a/bootstrap/edge/templates/default.conf.tftpl b/bootstrap/edge/templates/default.conf.tftpl index ffb4f06..301f497 100644 --- a/bootstrap/edge/templates/default.conf.tftpl +++ b/bootstrap/edge/templates/default.conf.tftpl @@ -173,7 +173,7 @@ server { expires 1h; } - location ~ ^/(?:login|logout|auth/dex/callback|incidents(?:/|$)|proposals(?:/|$)|executions(?:/|$)|reports(?:/|$)) { + location ~ ^/(?:login|logout|auth/dex(?:/callback)?|incidents(?:/|$)|proposals(?:/|$)|executions(?:/|$)|reports(?:/|$)) { proxy_pass http://${opsproof_backend_host}:${opsproof_backend_port}; proxy_http_version 1.1; proxy_set_header Host $host; diff --git a/tests/jeannie/test_privacy_services_pipeline.py b/tests/jeannie/test_privacy_services_pipeline.py index 8879d51..3834b85 100644 --- a/tests/jeannie/test_privacy_services_pipeline.py +++ b/tests/jeannie/test_privacy_services_pipeline.py @@ -156,6 +156,7 @@ class OpsProofPipelineTests(unittest.TestCase): encoding="utf-8" ) self.assertIn('route.Get("/login"', routes) + self.assertIn('route.Get("/auth/dex", authentication.Start)', routes) self.assertIn('route.Get("/demo"', routes) self.assertIn("auth.Authenticate{}", routes) self.assertIn("appmiddleware.Operator{}", routes) @@ -213,7 +214,7 @@ class OpsProofPipelineTests(unittest.TestCase): self.assertIn("server_name ${opsproof_server_name}", edge) self.assertIn("location = /demo", edge) self.assertIn("location ^~ /build/", edge) - self.assertIn("auth/dex/callback", edge) + self.assertIn("auth/dex(?:/callback)?", edge) self.assertIn("incidents(?:/|$)", edge) welcome = (