تقييم سياسة MAIP
curl --request POST \
--url https://api.truthlocks.com/v1/maip/policies/evaluate \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"agent_id": "<string>",
"scope": "<string>"
}
'const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({agent_id: '<string>', scope: '<string>'})
};
fetch('https://api.truthlocks.com/v1/maip/policies/evaluate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.truthlocks.com/v1/maip/policies/evaluate"
payload = {
"agent_id": "<string>",
"scope": "<string>"
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.truthlocks.com/v1/maip/policies/evaluate"
payload := strings.NewReader("{\n \"agent_id\": \"<string>\",\n \"scope\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"allowed": true,
"denied_by": [
"<string>"
],
"reason": "<string>",
"requires_approval": true
}{
"code": "AUTH_REQUIRED",
"message": "Authentication required",
"http_status": 401
}{
"code": "AUTH_REQUIRED",
"message": "Authentication required",
"http_status": 401
}{
"code": "AUTH_REQUIRED",
"message": "Authentication required",
"http_status": 401
}سياسات MAIP
تقييم سياسة MAIP
تقييم جميع سياسات الوكيل النشطة مقابل وكيل محدد ونطاق مطلوب
POST
/
v1
/
maip
/
policies
/
evaluate
تقييم سياسة MAIP
curl --request POST \
--url https://api.truthlocks.com/v1/maip/policies/evaluate \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"agent_id": "<string>",
"scope": "<string>"
}
'const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({agent_id: '<string>', scope: '<string>'})
};
fetch('https://api.truthlocks.com/v1/maip/policies/evaluate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.truthlocks.com/v1/maip/policies/evaluate"
payload = {
"agent_id": "<string>",
"scope": "<string>"
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.truthlocks.com/v1/maip/policies/evaluate"
payload := strings.NewReader("{\n \"agent_id\": \"<string>\",\n \"scope\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"allowed": true,
"denied_by": [
"<string>"
],
"reason": "<string>",
"requires_approval": true
}{
"code": "AUTH_REQUIRED",
"message": "Authentication required",
"http_status": 401
}{
"code": "AUTH_REQUIRED",
"message": "Authentication required",
"http_status": 401
}{
"code": "AUTH_REQUIRED",
"message": "Authentication required",
"http_status": 401
}تقييم سياسة MAIP
POST /v1/maip/policies/evaluate
تقييم جميع سياسات MAIP النشطة للمستأجر المصادق عليه مقابل وكيل محدد ونطاق مطلوب. يُرجع ما إذا كان الإجراء مسموحًا به أو مرفوضًا أو يتطلب موافقة بشرية. هذه هي نقطة تفتيش التنفيذ في وقت التشغيل التي تستدعيها الوكلاء قبل تنفيذ العمليات الحساسة.
يستخدم تقييم السياسة نموذج الرفض يتجاوز: إذا كانت أي سياسة نشطة ذات
تطابق مشغلات قاعدة
deny، يتم حظر الإجراء بغض النظر عن أي allow
القواعد. علامة requires_approval إضافية — يمكن تعيينها حتى عندما تكون
الإجراء مسموح به.المصادقة
يتطلب رأسX-API-Key أو رمز Bearer JWT. نطاق المستأجر عبر ملف تعريف الارتباط أو مطالبة JWT.
منطق التقييم
يقوم التقييم بثلاثة فحوصات متسلسلة:- فحص حالة الوكيل — يجب أن يكون الوكيل
status: "active". يتم رفض الوكلاء المعلقين أو الملغاة دائمًا. - فحص الوصول إلى النطاق — يجب أن يكون النطاق المطلوب موجودًا في النطاقات الممنوحة للوكيل. النطاقات المرفوضة صراحةً (المسبوقة بـ
!) تمنع الوصول دائمًا. - فحص قواعد السياسة — يتم تقييم جميع سياسات المستأجر النشطة بترتيب الأولوية. يتم ربط شروط كل قاعدة بـ AND. إذا تطابقت أي قاعدة
deny، يتم حظر الإجراء.
الاستجابة
سبب الرفض المقروء بشريًا. أحد الأسباب التالية: -
"agent is not active" — الوكيل
معلق أو ملغى - "scope not granted to agent" — النطاق ليس في
النطاقات الممنوحة للوكيل - "denied by policy" — سياسة واحدة أو أكثر محظورة
العملtrue إذا كان أي قاعدة سياسة مطابقة تحتوي على requires_approval: true، حتى لو كان
الإجراء مسموح به بخلاف ذلك. يجب على المتصل تقديم موافقة بشرية
سير العمل قبل المتابعة.مثال
curl -X POST https://api.truthlocks.com/v1/maip/policies/evaluate \
-H "X-API-Key: tl_live_..." \
-H "Content-Type: application/json" \
-d '{
"agent_id": "maip:t1234567:01HYX3KPZQ7RJGBN0WFMV8SDEH",
"scope": "data:write",
"action": "update_customer_record",
"resource": "customers/cust_12345"
}'
const response = await fetch(
"https://api.truthlocks.com/v1/maip/policies/evaluate",
{
method: "POST",
headers: {
"X-API-Key": "tl_live_...",
"Content-Type": "application/json",
},
body: JSON.stringify({
agent_id: "maip:t1234567:01HYX3KPZQ7RJGBN0WFMV8SDEH",
scope: "data:write",
action: "update_customer_record",
resource: "customers/cust_12345",
}),
},
);
const result = await response.json();
if (!result.allowed) {
console.error(`Denied by: ${result.denied_by.join(", ")}`);
} else if (result.requires_approval) {
// Route to human approval workflow
}
import requests
response = requests.post(
"https://api.truthlocks.com/v1/maip/policies/evaluate",
headers={
"X-API-Key": "tl_live_...",
"Content-Type": "application/json",
},
json={
"agent_id": "maip:t1234567:01HYX3KPZQ7RJGBN0WFMV8SDEH",
"scope": "data:write",
"action": "update_customer_record",
"resource": "customers/cust_12345",
},
)
result = response.json()
الجسم
application/json

