@@ -8,31 +8,38 @@ import (
88 "github.com/openziti/sdk-golang/ziti/edge"
99)
1010
11+ // Submitter handles transmission of posture response data to authentication and policy
12+ // enforcement endpoints.
1113type Submitter interface {
1214 SendPostureResponse (response rest_model.PostureResponseCreate ) error
1315 SendPostureResponseBulk (responses []rest_model.PostureResponseCreate ) error
1416}
1517
18+ // RouterConnectionProvider supplies active router connections for submitting posture data
19+ // directly to edge routers in high-availability deployments.
1620type RouterConnectionProvider interface {
1721 GetRouterConnections () []edge.RouterConn
1822}
1923
24+ // ApiSessionProvider supplies the current API session, enabling submitters to determine
25+ // the appropriate destination for posture responses based on authentication type.
2026type ApiSessionProvider interface {
2127 GetCurrentApiSession () edge_apis.ApiSession
2228}
2329
2430var _ Submitter = (* MultiSubmitter )(nil )
2531
26- // MultiSubmitter submits posture responses to multiple destinations. Those destinations are determined by the
27- // nature of the API Session and router connections. Legacy, non-HA, API Sessions will always send to the controller.
28- // HA API Sessions will send to the controller if the router does not support posture checks. HA API Sessions must
29- // send to routers that support posture checks.
32+ // MultiSubmitter routes posture responses to appropriate destinations based on session type
33+ // and router capabilities. Legacy sessions always submit to the controller, while OIDC sessions
34+ // submit to routers that support posture checks and fall back to the controller for older routers.
3035type MultiSubmitter struct {
3136 ApiSessionProvider ApiSessionProvider
3237 LegacySubmitter Submitter
3338 RouterConnectionProvider RouterConnectionProvider
3439}
3540
41+ // NewMultiSubmitter creates a submitter that intelligently routes posture responses based on
42+ // session authentication method and router capabilities.
3643func NewMultiSubmitter (apiSessionProvider ApiSessionProvider , legacySubmitter Submitter , routerConnectionProvider RouterConnectionProvider ) * MultiSubmitter {
3744 return & MultiSubmitter {
3845 ApiSessionProvider : apiSessionProvider ,
@@ -108,11 +115,15 @@ func filterToLegacyPostureResponses(responses []rest_model.PostureResponseCreate
108115 return legacyResponse
109116}
110117
118+ // MultiDestinationError aggregates errors from posture response submission attempts
119+ // to multiple destinations (controller and routers), providing detailed failure information.
111120type MultiDestinationError struct {
112121 routerErrors map [edge.RouterConn ]error
113122 controllerError error
114123}
115124
125+ // Error formats all submission failures into a comprehensive error message identifying
126+ // which destinations failed and why.
116127func (e * MultiDestinationError ) Error () string {
117128 result := ""
118129
@@ -148,6 +159,8 @@ func (e *MultiDestinationError) Error() string {
148159 return result
149160}
150161
162+ // HasErrors returns true if any submission attempts failed, either to the controller
163+ // or to any routers.
151164func (e * MultiDestinationError ) HasErrors () bool {
152165 return len (e .routerErrors ) > 0 || e .controllerError != nil
153166}
0 commit comments