בדיקת כותרת של הגבלות ארגוניות לפני הגדרת שרת proxy ליציאה

לפני שמגדירים שרת proxy לתעבורת נתונים יוצאת (egress), אפשר לבדוק את הכותרת של ההגבלות על ארגון ישירות באמצעות כלי כמו curl. הבדיקות האלה עוזרות לוודא שהבקשות לארגונים מורשים ב-Cloud de Confiance by S3NS מצליחות, ושהבקשות לארגונים לא מורשים נחסמות.

בדיקת הכותרת של ההגבלות על הארגון

כדי ליצור ולבדוק את הכותרת של ההגבלות על הארגון, מבצעים את הפעולות הבאות:

  1. כדי לקבל את מזהה הארגון ( Cloud de Confiance by S3NS ), משתמשים בפקודה gcloud organizations list:

        gcloud organizations list
    

    הפלט לדוגמה:

        DISPLAY_NAME: Organization A
        ID: 123456789
        DIRECTORY_CUSTOMER_ID: a1b2c3d4
    
  2. אחרי שמקבלים את מזהה הארגון, יוצרים את הייצוג של JSON לערך הכותרת בפורמט הבא:

     {
     "resources": ["organizations/123456789"],
      "options": "strict"
     }
    
  3. מקודדים את הערך של request header לפי המפרטים של RFC 4648, סעיף 5.

    לדוגמה, אם הייצוג ב-JSON של ערך הכותרת מאוחסן בקובץ authorized_orgs.json, הקידוד באמצעות basenc הוא:

     $ OR_HEADER=`cat authorized_orgs.json | basenc --base64url -w0`
     $ echo $OR_HEADER
    ewogInJlc291cmNlcyI6IFsib3JnYW5pemF0aW9ucy8xMjM0NTY3ODkiXQogIm9wdGlvbnMiOiAic3RyaWN0Igp9Cgo=
    
  4. כדי לבדוק אם הגדרת הכותרת מאפשרת גישה למשאב בארגוןCloud de Confiance by S3NS מורשה, יוצרים בקשת curl למשאב בארגוןCloud de Confiance by S3NS מורשה. הנה דוגמה לבקשת curl:

    # Get auth token
    $ TOKEN=$(gcloud auth print-access-token)
    
    # Make a request that includes the organization restriction header; this call makes a request to the logging API for a project within the same organization listed in the header
    $ curl -H "X-Goog-Allowed-Resources: ${OR_HEADER}" -X POST -d '{"projectIds":
    ["my-project-123"]}' -H 'Content-Type: application/json' -H "Authorization: Bearer ${TOKEN}" "https://logging.googleapis.com/v2/entries:list"
    # A successful request returns log entries in this project
    
  5. כדי לבדוק אם הגדרת הכותרת מונעת גישה למשאב שנמצא מחוץ לארגון המורשה ב-Cloud de Confiance by S3NS , יוצרים בקשת curl למשאב שנמצא מחוץ לארגון המורשה ב-Cloud de Confiance by S3NS . הנה דוגמה לבקשת curl:

    # Get auth token
    $ TOKEN=$(gcloud auth print-access-token)
    
    # Make a request that includes the organization restriction header; this call makes a request to the logging API for a project not within the same organization listed in the header
    $ curl -H "X-Goog-Allowed-Resources: ${OR_HEADER}" -X POST -d '{"projectIds": ["other-project-123"]}' -H 'Content-Type: application/json' -H "Authorization: Bearer ${TOKEN}" "https://logging.googleapis.com/v2/entries:list" 
    {
      "error": {
     "code": 403,
        "message": "Access denied by organization restriction. Contact your administrator for additional information.",
        "status": "PERMISSION_DENIED",
        "details": [
          {
            "@type": "type.googleapis.com/google.rpc.ErrorInfo",
            "reason": "ORG_RESTRICTION_VIOLATION",
            "domain": "googleapis.com",
            "metadata": {
              "service": "logging.googleapis.com",
              "consumer": "other-project-123"
            }
          }
        ]
      }
    }
    
    

    הודעת השגיאה "הגישה נדחתה" מציינת שהבקשה למשאב נדחתה.

המאמרים הבאים