mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
FIX: Allow plugins to correctly extend API key scopes. (#12113)
Adding a scope from a plugin was broken. This commit fixes it and adds a test. It also documents the instance method and renames the serialized "id" attribute to "scope_id" to avoid a conflict when the scope also has a parameter with the same name.
This commit is contained in:
@ -791,6 +791,13 @@ class Plugin::Instance
|
||||
end
|
||||
end
|
||||
|
||||
# Register a new API key scope.
|
||||
#
|
||||
# Example:
|
||||
# add_api_key_scope(:groups, { delete: { actions: %w[groups#add_members], params: %i[id] } })
|
||||
#
|
||||
# This scope lets you add members to a group. Additionally, you can specify which group ids are allowed.
|
||||
# The delete action is added to the groups resource.
|
||||
def add_api_key_scope(resource, action)
|
||||
DiscoursePluginRegistry.register_api_key_scope_mapping({ resource => action }, self)
|
||||
end
|
||||
|
Reference in New Issue
Block a user