Add OpsProof Dex sign-in page
This commit is contained in:
parent
238aa4049f
commit
d9c7d4d90b
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
export default function SignInPage({ provider, notice }: { provider: string; notice: string }) {
|
||||
return (
|
||||
<main className="grid min-h-screen place-items-center bg-[#071019] px-5 py-10 text-slate-100">
|
||||
<div className="pointer-events-none fixed inset-0 bg-[radial-gradient(circle_at_20%_10%,rgba(34,211,238,0.12),transparent_30%),radial-gradient(circle_at_80%_80%,rgba(99,102,241,0.10),transparent_30%)]" />
|
||||
<section className="relative w-full max-w-lg overflow-hidden rounded-3xl border border-white/10 bg-[#0a141e]/95 shadow-2xl shadow-black/40">
|
||||
<div className="border-b border-white/10 p-7">
|
||||
<a href="/demo" className="text-xs text-cyan-300 hover:text-cyan-200">
|
||||
← Public demonstration
|
||||
</a>
|
||||
<div className="mt-8 grid size-11 place-items-center rounded-xl bg-cyan-300 font-black text-slate-950">OP</div>
|
||||
<p className="mt-6 text-xs uppercase tracking-[0.22em] text-cyan-300">OpsProof operator access</p>
|
||||
<h1 className="mt-3 text-3xl font-semibold tracking-tight text-white">Sign in to the live workspace</h1>
|
||||
<p className="mt-4 text-sm leading-6 text-slate-400">{notice}</p>
|
||||
</div>
|
||||
|
||||
<div className="space-y-5 p-7">
|
||||
<div className="rounded-2xl border border-white/10 bg-white/[0.025] p-5">
|
||||
<p className="text-sm font-medium text-white">Authenticated capabilities</p>
|
||||
<ul className="mt-3 space-y-2 text-sm leading-6 text-slate-400">
|
||||
<li>• Read live status and focused Doctor evidence through Jeannie</li>
|
||||
<li>• Review exact remediation, risk, preconditions, and rollback</li>
|
||||
<li>• Approve one constrained execution and retain its validation report</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<a
|
||||
href="/auth/dex"
|
||||
className="flex w-full items-center justify-center rounded-xl bg-cyan-300 px-4 py-3 font-semibold text-slate-950 hover:bg-cyan-200"
|
||||
>
|
||||
Continue with {provider}
|
||||
</a>
|
||||
<p className="text-center text-[11px] leading-5 text-slate-600">
|
||||
Access is restricted to verified identities in the server-side operator allowlist.
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
|
@ -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{})
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 = (
|
||||
|
|
|
|||
Loading…
Reference in New Issue