← Back to Pull requests

mobile sso login flow #51

Open
brad-defined opened this pull request with 189 lines diff across 4 files
View on GitHub
brad-defined brad-defined commented on Sep 29, 2026 18:53 UTC
Author

Support the SSO login flow that breaks the single call into separate authenticate & add host calls (which are feature flagged in the API now.)

Diff: 189 lines (+187 / -2) across 4 files Reviewer: jasikpark Review duration: 50992m
All Vouch review confidence checks passed
Residual risk 0.05 = Change Risk (0.46) × (1 − Review Confidence (0.89)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.46 · 189 lines diff across 4 files
0.46
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.94 · 3 substantive comment(s)
0.94
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
89%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.314
Real PR Conversation Timeline
5 items
jasikpark jasikpark commented on code on Oct 06, 2026 17:05 UTC
Code Review
dnapitest/dnapitest.go:1
@@ -79,12 +80,30 @@ func (s *Server) handler(w http.ResponseWriter, r *http.Request) {
 		s.expectedRequests = s.expectedRequests[1:]
 		w.WriteHeader(expected.StatusCode())
 		_, _ = w.Write(expected.Respond(nil))
+	case message.PreAuthEndpointV2, message.EndpointAuthHostsEndpoint:
+		s.handlerQueued(w, r)
+	case message.AuthPollEndpointV2:
+		s.handlerDoOidcPoll(w, r)
 	default:
+		// The renew path embeds the host ID (/v2/endpoint-auth/hosts/{hostID}/renew).
+		if strings.HasPrefix(r.URL.Path, message.EndpointAuthHostsEndpoint+"/") && strings.HasSuffix(r.URL.Path, "/renew") {
+			s.handlerQueued(w, r)
+			return
+		}
 		s.errors = append(s.errors, fmt.Errorf("invalid request path %s", r.URL.Path))
 		http.NotFound(w, r)
 	}
 }
 
+// handlerQueued responds with the next queued mock response, regardless of request contents. Used
+// for endpoints whose requests carry no fields the mock needs to validate.
+func (s *Server) handlerQueued(w http.ResponseWriter, _ *http.Request) {

This ignores the request, so nothing checks what makes the v2 calls different from v1: the Authorization: Bearer header, the method (GET list vs POST create share a path), and which host ID the renew path carries. Could the queued entry record the method, path, and Authorization header it expects, and fail on a mismatch? That would also let a test assert that Enroll after CreateEndpointHost sends no token.

jasikpark jasikpark commented on Oct 06, 2026 17:05 UTC
Reviewer

The client side looks right to me; nebula-apple#13 builds its SSO login on this commit. My one real ask is in the test mock: as written, the suite would still pass if the Bearer header were missing, sent on Enroll, or if list and create were swapped.

— Caleb + Cache

jasikpark jasikpark commented on code on Oct 06, 2026 17:05 UTC
Code Review
message/message.go:1
@@ -269,6 +269,58 @@ type EndpointAuthPollData struct {
 	EnrollmentCode string            `json:"enrollmentCode"`
 }
 
+// PreAuthEndpointV2 begins the v2 (token flow) endpoint auth. Unlike v1, a completed auth yields an
+// endpoint OIDC user auth token rather than an enrollment code.
+const PreAuthEndpointV2 = "/v2/endpoint-auth/preauth"
+
+// AuthPollEndpointV2 is polled during the v2 flow. On completion it returns an AuthToken.
+const AuthPollEndpointV2 = "/v2/endpoint-auth/poll"
+
+// EndpointAuthPollDataV2 is returned by AuthPollEndpointV2.
+type EndpointAuthPollDataV2 struct {
+	Status EndpointAuthState `json:"state"`
+	// AuthToken is set once Status is COMPLETED. It is an endpoint OIDC user auth token used to
+	// authenticate the host-management endpoints below.
+	AuthToken string `json:"authToken"`
+}
+
+// EndpointAuthHostsEndpoint lists the hosts owned by the authenticated endpoint OIDC user, and
+// (via POST) creates a new host. Requires an endpoint OIDC user auth token.
+const EndpointAuthHostsEndpoint = "/v2/endpoint-auth/hosts"
+
+// EndpointAuthHost summarizes a host owned by the authenticated endpoint OIDC user.
+type EndpointAuthHost struct {
+	ID                 string     `json:"id"`
+	Name               string     `json:"name"`
+	NetworkID          string     `json:"networkID"`
+	IsBlocked          bool       `json:"isBlocked"`

What should a client do with a blocked host here: skip it when choosing one to renew, or renew it and expect the server to refuse? A line in the doc comment would keep the clients consistent.

jasikpark jasikpark commented on Oct 19, 2026 21:37 UTC
Contributor

A small request while this is open. nebula-apple decides whether a failed Enroll already spent its code by checking whether the APIError wraps anything: request failures wrap an error, and failures reading an accepted response (unsupported curve, a trusted-key bundle it can't load) are built with %s and wrap nothing. That works, but it relies on formatting, and a %s → %w refactor would flip it silently. Could Enroll export a sentinel (e.g. ErrCodeSpent, or wrap those two in one) that callers can errors.Is? We'd switch to it and drop the inference.

— Caleb + Cache

Reviewers
Assignees
brad-defined brad-defined
Labels
risk: low confidence: 89.2% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 45.8% (MEDIUM) · Higher = larger blast radius
45.8%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 89.2% · Lower = rushed or shallow review
89.2%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 4.9% · Safe to merge
4.9%