@@ -418,16 +418,16 @@ func (s *Server) evaluateOPA(ctx context.Context, claims map[string]any, deviceI
418418
419419 start := time .Now ()
420420 var resp * http.Response
421- var callErr error
422421 retryErr := retry .Do (ctx , s .retryCfg , func () error {
423- resp , callErr = s .client .Do (req )
424- if callErr != nil {
425- return callErr
422+ r , err : = s .client .Do (req )
423+ if err != nil {
424+ return err
426425 }
427- if resp .StatusCode >= 500 {
428- _ = resp .Body .Close ()
429- return fmt .Errorf ("opa temporary error: %d" , resp .StatusCode )
426+ if r .StatusCode >= 500 {
427+ _ = r .Body .Close ()
428+ return fmt .Errorf ("opa temporary error: %d" , r .StatusCode )
430429 }
430+ resp = r
431431 return nil
432432 })
433433 if retryErr != nil {
@@ -516,61 +516,61 @@ func parseXFCC(xfcc string) string {
516516
517517func (s * Server ) lookupDevice (ctx context.Context , deviceID string ) map [string ]any {
518518 if deviceID == "" || s .cfg .InventoryAPI == "" {
519- return map [string ]any {"id" : deviceID , "posture" : "unknown" }
519+ return map [string ]any {"id" : deviceID , "posture" : statusUnknown }
520520 }
521521
522522 req , err := http .NewRequestWithContext (ctx , http .MethodGet , fmt .Sprintf ("%s/v1/devices/%s" , s .cfg .InventoryAPI , deviceID ), nil )
523523 if err != nil {
524524 log .Printf ("inventory request build failed: %v" , err )
525- return map [string ]any {"id" : deviceID , "posture" : "unknown" }
525+ return map [string ]any {"id" : deviceID , "posture" : statusUnknown }
526526 }
527527
528528 start := time .Now ()
529529 var resp * http.Response
530- var callErr error
531530 retryErr := retry .Do (ctx , s .retryCfg , func () error {
532- resp , callErr = s .invClient .Do (req )
533- if callErr != nil {
534- return callErr
531+ r , err : = s .invClient .Do (req )
532+ if err != nil {
533+ return err
535534 }
536- if resp .StatusCode >= 500 {
537- _ = resp .Body .Close ()
538- return fmt .Errorf ("inventory temporary error: %d" , resp .StatusCode )
535+ if r .StatusCode >= 500 {
536+ _ = r .Body .Close ()
537+ return fmt .Errorf ("inventory temporary error: %d" , r .StatusCode )
539538 }
539+ resp = r
540540 return nil
541541 })
542542 if retryErr != nil {
543543 telemetry .RecordDependencyRequest (ctx , "authz" , "inventory" , "lookup" , time .Since (start ), "error" )
544544 log .Printf ("inventory request failed: %v" , retryErr )
545- return map [string ]any {"id" : deviceID , "posture" : "unknown" }
545+ return map [string ]any {"id" : deviceID , "posture" : statusUnknown }
546546 }
547547 defer resp .Body .Close ()
548548
549549 if resp .StatusCode == http .StatusNotFound {
550550 telemetry .RecordDependencyRequest (ctx , "authz" , "inventory" , "lookup" , time .Since (start ), "404" )
551- return map [string ]any {"id" : deviceID , "posture" : "unregistered" }
551+ return map [string ]any {"id" : deviceID , "posture" : statusUnregistered }
552552 }
553553 if resp .StatusCode != http .StatusOK {
554554 b , readErr := io .ReadAll (resp .Body )
555555 if readErr != nil {
556556 telemetry .RecordDependencyRequest (ctx , "authz" , "inventory" , "lookup" , time .Since (start ), fmt .Sprintf ("%d" , resp .StatusCode ))
557557 log .Printf ("inventory error %d: failed to read body: %v" , resp .StatusCode , readErr )
558- return map [string ]any {"id" : deviceID , "posture" : "unknown" }
558+ return map [string ]any {"id" : deviceID , "posture" : statusUnknown }
559559 }
560560 telemetry .RecordDependencyRequest (ctx , "authz" , "inventory" , "lookup" , time .Since (start ), fmt .Sprintf ("%d" , resp .StatusCode ))
561561 log .Printf ("inventory error %d: %s" , resp .StatusCode , string (b ))
562- return map [string ]any {"id" : deviceID , "posture" : "unknown" }
562+ return map [string ]any {"id" : deviceID , "posture" : statusUnknown }
563563 }
564564
565565 var device inventoryDevice
566566 if err := json .NewDecoder (resp .Body ).Decode (& device ); err != nil {
567567 telemetry .RecordDependencyRequest (ctx , "authz" , "inventory" , "lookup" , time .Since (start ), "decode_error" )
568568 log .Printf ("inventory decode failed: %v" , err )
569- return map [string ]any {"id" : deviceID , "posture" : "unknown" }
569+ return map [string ]any {"id" : deviceID , "posture" : statusUnknown }
570570 }
571571
572572 if device .Posture == "" {
573- device .Posture = "unknown"
573+ device .Posture = statusUnknown
574574 }
575575
576576 // Parse posture JSON to extract trust score
@@ -913,16 +913,16 @@ func (s *Server) verifyMFACode(ctx context.Context, sessionID, code string) (boo
913913
914914 start := time .Now ()
915915 var resp * http.Response
916- var callErr error
917916 retryErr := retry .Do (ctx , s .retryCfg , func () error {
918- resp , callErr = s .client .Do (req )
919- if callErr != nil {
920- return callErr
917+ r , err : = s .client .Do (req )
918+ if err != nil {
919+ return err
921920 }
922- if resp .StatusCode >= 500 {
923- _ = resp .Body .Close ()
924- return fmt .Errorf ("mfa temporary error: %d" , resp .StatusCode )
921+ if r .StatusCode >= 500 {
922+ _ = r .Body .Close ()
923+ return fmt .Errorf ("mfa temporary error: %d" , r .StatusCode )
925924 }
925+ resp = r
926926 return nil
927927 })
928928 if retryErr != nil {
0 commit comments