mirror of
https://github.com/discourse/discourse.git
synced 2025-03-22 02:35:51 +08:00
FEATURE: More API scopes (#10493)
This commit is contained in:
parent
b6dd3eca9a
commit
dd13304b81
@ -39,17 +39,23 @@
|
|||||||
{{#unless useGlobalKey}}
|
{{#unless useGlobalKey}}
|
||||||
<div class="scopes-title">{{i18n "admin.api.scopes.title"}}</div>
|
<div class="scopes-title">{{i18n "admin.api.scopes.title"}}</div>
|
||||||
<p>{{i18n "admin.api.scopes.description"}}</p>
|
<p>{{i18n "admin.api.scopes.description"}}</p>
|
||||||
{{#each-in scopes as |resource actions|}}
|
<table class="scopes-table">
|
||||||
<table class="scopes-table">
|
<thead>
|
||||||
<thead>
|
<tr>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td>{{i18n "admin.api.scopes.allowed_urls"}}</td>
|
||||||
|
<td>{{i18n "admin.api.scopes.optional_allowed_parameters"}}</td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{{#each-in scopes as |resource actions|}}
|
||||||
<tr>
|
<tr>
|
||||||
<td><b>{{resource}}</b></td>
|
<td class="scope-resource-name"><b>{{resource}}</b></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>{{i18n "admin.api.scopes.allowed_urls"}}</td>
|
|
||||||
<td>{{i18n "admin.api.scopes.optional_allowed_parameters"}}</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{{#each actions as |act|}}
|
{{#each actions as |act|}}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{input type="checkbox" checked=act.selected}}</td>
|
<td>{{input type="checkbox" checked=act.selected}}</td>
|
||||||
@ -71,9 +77,9 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</tbody>
|
{{/each-in}}
|
||||||
</table>
|
</tbody>
|
||||||
{{/each-in}}
|
</table>
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
|
|
||||||
{{d-button icon="check" label="admin.api.save" action=(action "save") class="btn-primary" disabled=saveDisabled}}
|
{{d-button icon="check" label="admin.api.save" action=(action "save") class="btn-primary" disabled=saveDisabled}}
|
||||||
|
@ -143,6 +143,10 @@ table.api-keys {
|
|||||||
.scopes-table {
|
.scopes-table {
|
||||||
margin: 20px 0 20px 0;
|
margin: 20px 0 20px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.scope-resource-name {
|
||||||
|
font-size: $font-up-1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Webhook
|
// Webhook
|
||||||
|
@ -18,22 +18,36 @@ class ApiKeyScope < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def default_mappings
|
def default_mappings
|
||||||
write_actions = %w[posts#create]
|
return @default_mappings unless @default_mappings.nil?
|
||||||
read_actions = %w[topics#show topics#feed]
|
|
||||||
|
|
||||||
@default_mappings ||= {
|
mappings = {
|
||||||
topics: {
|
topics: {
|
||||||
write: { actions: write_actions, params: %i[topic_id], urls: find_urls(write_actions) },
|
write: { actions: %w[posts#create], params: %i[topic_id] },
|
||||||
read: {
|
read: {
|
||||||
actions: read_actions, params: %i[topic_id],
|
actions: %w[topics#show topics#feed topics#posts],
|
||||||
aliases: { topic_id: :id }, urls: find_urls(read_actions)
|
params: %i[topic_id], aliases: { topic_id: :id }
|
||||||
},
|
},
|
||||||
read_lists: {
|
read_lists: {
|
||||||
actions: list_actions, params: %i[category_id],
|
actions: list_actions, params: %i[category_id],
|
||||||
aliases: { category_id: :category_slug_path_with_id }, urls: find_urls(list_actions)
|
aliases: { category_id: :category_slug_path_with_id }
|
||||||
}
|
},
|
||||||
|
wordpress: { actions: %w[topics#wordpress], params: %i[topic_id] }
|
||||||
|
},
|
||||||
|
users: {
|
||||||
|
bookmarks: { actions: %w[users#bookmarks], params: %i[username] },
|
||||||
|
sync_sso: { actions: %w[admin/users#sync_sso], params: %i[sso sig] },
|
||||||
|
show: { actions: %w[users#show], params: %i[username external_id] },
|
||||||
|
check_emails: { actions: %w[users#check_emails], params: %i[username] }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mappings.each_value do |resource_actions|
|
||||||
|
resource_actions.each_value do |action_data|
|
||||||
|
action_data[:urls] = find_urls(action_data[:actions])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
@default_mappings = mappings
|
||||||
end
|
end
|
||||||
|
|
||||||
def scope_mappings
|
def scope_mappings
|
||||||
|
@ -3662,12 +3662,15 @@ en:
|
|||||||
allowed_urls: Allowed URLs
|
allowed_urls: Allowed URLs
|
||||||
descriptions:
|
descriptions:
|
||||||
topics:
|
topics:
|
||||||
read: |
|
read: Read a topic or a specific post in it. RSS is also supported.
|
||||||
Read a topic or a specific post in it. RSS is also supported.
|
write: Create a new topic or post to an existing one.
|
||||||
write: |
|
read_lists: Read topic lists like top, new, latest, etc. RSS is also supported.
|
||||||
Create a new topic or post to an existing one.
|
wordpress: Necessary for the WordPress wp-discourse plugin to work.
|
||||||
read_lists: |
|
users:
|
||||||
Read topic lists like top, new, latest, etc. RSS is also supported.
|
bookmarks: List user bookmarks. It returns bookmark reminders when using the ICS format.
|
||||||
|
sync_sso: Synchronize a user using SSO.
|
||||||
|
show: Obtain information about an user.
|
||||||
|
check_emails: List user emails.
|
||||||
|
|
||||||
web_hooks:
|
web_hooks:
|
||||||
title: "Webhooks"
|
title: "Webhooks"
|
||||||
|
@ -222,7 +222,7 @@ describe Admin::ApiController do
|
|||||||
|
|
||||||
scopes = response.parsed_body['scopes']
|
scopes = response.parsed_body['scopes']
|
||||||
|
|
||||||
expect(scopes.keys).to contain_exactly('topics')
|
expect(scopes.keys).to contain_exactly('topics', 'users')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user