مواصفات مفاتيح API للمستخدم

ما رأيك في إنشاء نطاق جديد محدد، مع معلمة ثالثة للإشارة إلى “معامل GET مسموح به”. بهذه الطريقة، لا يمكن للأشخاص إساءة استخدامه لأغراض أخرى (مثل تجاوز CORS وطلب واجهة برمجة تطبيقات Discourse من موقع آخر).

(من هنا)

SCOPES = {
    read: [:get],
    write: [:get, :post, :patch, :put, :delete],
    message_bus: [[:post, 'message_bus']],
    push: nil,
    one_time_password: nil,
    notifications: [[:post, 'message_bus'], [:get, 'notifications#index'], [:put, 'notifications#mark_read']],
    session_info: [
      [:get, 'session#current'],
      [:get, 'users#topic_tracking_state'],
      [:get, 'list#unread'],
      [:get, 'list#new'],
      [:get, 'list#latest']
    ],
+   calendar: [ [:get, 'users#bookmarks_cal', true ] ],
  }

(ملاحظة جانبية: لماذا نستخدم مصفوفات متداخلة هنا…)

10 إعجابات