用户API密钥规范

不如创建一个特定的新作用域,并添加第三个参数来指示“允许获取参数”。这样,人们就无法将其误用于其他用途(例如绕过 CORS 并从其他站点请求 Discourse API)。

来源

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 个赞