# Auth.md

## المصادقة — درب (Darb)

https://usedarb.com

## الخلاصة
| السطح | المصادقة |
|---|---|
| البيانات العامّة (`/api/agent/*` · `/mcp` · ملفّات الاكتشاف) | **لا شيء** — مفتوحة للقراءة |
| ما يخصّ حساب طالبٍ بعينه | **OAuth 2.0 عبر Google** (Firebase Authentication) |

## السطح العامّ
اقرأ مباشرةً بلا رمزٍ ولا مفتاح:

- `GET https://usedarb.com/api/agent/universities`
- `GET https://usedarb.com/api/agent/exams`
- `GET https://usedarb.com/api/agent/calendar`
- `GET https://usedarb.com/api/agent/faq`
- `POST https://usedarb.com/mcp` (JSON-RPC 2.0)

الحدُّ ستّون طلباً في الدقيقة لكل عنوان. الترويسة `Access-Control-Allow-Origin: *`.

## السطح المحميّ
بيانات الطالب — خطّته وأخطاؤه وتقدّمه — لا تخرج من درب إلى وكيلٍ إطلاقاً.
**لا توجد واجهةٌ تُخرجها، ولن توجد.** ما خلف الدخول هو تطبيق الطالب نفسه:
يفتحه هو بهويّته من Google، ولا يُفوَّض وكيلٌ ثالث بقراءته.

- خادم التفويض: `https://accounts.google.com`
- بيانُ الخادم: [`/.well-known/oauth-authorization-server`](https://usedarb.com/.well-known/oauth-authorization-server) (RFC 8414)
- بيانُ المورد المحميّ: [`/.well-known/oauth-protected-resource`](https://usedarb.com/.well-known/oauth-protected-resource) (RFC 9728)
- الرمز يُرسَل: `Authorization: Bearer <Google ID token>`
- النطاقات: `openid` · `email` · `profile`

## تسجيلُ الوكلاء (Agent Registration)
درب **لا تُصدر** رموزاً ولا تملك سجلَّ عملاء خاصاً بها؛ الهويّةُ من Google.
فليس عندنا `register_uri`: التسجيلُ الديناميكي (RFC 7591) غير مدعوم، ويُنشئ
المطوّرُ عميلَه في Google Cloud Console ثم يستعمل خادم تفويض Google أعلاه.

```json
{
  "agent_auth": {
    "public_api": { "auth_required": false },
    "authorization_servers": ["https://accounts.google.com"],
    "protected_resource_metadata": "https://usedarb.com/.well-known/oauth-protected-resource",
    "authorization_server_metadata": "https://usedarb.com/.well-known/oauth-authorization-server",
    "identity_types": ["human"],
    "credential_types": ["oauth2_access_token", "oidc_id_token"],
    "token_endpoint_auth_methods": ["client_secret_post", "client_secret_basic"],
    "dynamic_client_registration": false,
    "register_uri": null,
    "claims_uri": "https://openidconnect.googleapis.com/v1/userinfo",
    "revocation_uri": "https://oauth2.googleapis.com/revoke",
    "delegated_agent_access": false
  }
}
```

`identity_types` بشريٌّ وحده و`delegated_agent_access` مُطفأ عن قصد: لا يدخل
وكيلٌ نيابةً عن طالبٍ إلى بياناته في درب.

## التواصل
support@usedarb.com · [توثيق الواجهة](https://usedarb.com/docs/api)
