Merge branch 'tusooa/3065-scopes' into 'develop'
OAuth scopes descriptions Closes #3065 See merge request pleroma/pleroma!3848
This commit is contained in:
commit
ce1c0f75cd
|
@ -0,0 +1 @@
|
||||||
|
Add OAuth scope descriptions
|
|
@ -0,0 +1,82 @@
|
||||||
|
# Pleroma: A lightweight social networking server
|
||||||
|
# Copyright © 2017-2023 Pleroma Authors <https://pleroma.social/>
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
defmodule Pleroma.Web.ApiSpec.Scopes.Compiler do
|
||||||
|
defmacro __before_compile__(_env) do
|
||||||
|
strings = __MODULE__.extract_all_scopes()
|
||||||
|
|
||||||
|
quote do
|
||||||
|
def placeholder do
|
||||||
|
unquote do
|
||||||
|
Enum.map(
|
||||||
|
strings,
|
||||||
|
fn string ->
|
||||||
|
quote do
|
||||||
|
Pleroma.Web.Gettext.dgettext_noop(
|
||||||
|
"oauth_scopes",
|
||||||
|
unquote(string)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def extract_all_scopes do
|
||||||
|
extract_all_scopes_from(Pleroma.Web.ApiSpec.spec())
|
||||||
|
end
|
||||||
|
|
||||||
|
def extract_all_scopes_from(specs) do
|
||||||
|
specs.paths
|
||||||
|
|> Enum.reduce([], fn
|
||||||
|
{_path, %{} = path_item}, acc ->
|
||||||
|
extract_routes(path_item)
|
||||||
|
|> Enum.flat_map(fn operation -> process_operation(operation) end)
|
||||||
|
|> Kernel.++(acc)
|
||||||
|
|
||||||
|
{_, _}, acc ->
|
||||||
|
acc
|
||||||
|
end)
|
||||||
|
|> Enum.uniq()
|
||||||
|
end
|
||||||
|
|
||||||
|
defp extract_routes(path_item) do
|
||||||
|
path_item
|
||||||
|
|> Map.from_struct()
|
||||||
|
|> Enum.map(fn {_method, path_item} -> path_item end)
|
||||||
|
|> Enum.filter(fn
|
||||||
|
%OpenApiSpex.Operation{} = _operation -> true
|
||||||
|
_ -> false
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
defp process_operation(operation) do
|
||||||
|
operation.security
|
||||||
|
|> Kernel.||([])
|
||||||
|
|> Enum.flat_map(fn
|
||||||
|
%{"oAuth" => scopes} -> process_scopes(scopes)
|
||||||
|
_ -> []
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
defp process_scopes(scopes) do
|
||||||
|
scopes
|
||||||
|
|> Enum.flat_map(fn scope ->
|
||||||
|
process_scope(scope)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
def process_scope(scope) do
|
||||||
|
hierarchy = String.split(scope, ":")
|
||||||
|
|
||||||
|
{_, list} =
|
||||||
|
Enum.reduce(hierarchy, {"", []}, fn comp, {cur, list} ->
|
||||||
|
{cur <> comp <> ":", [cur <> comp | list]}
|
||||||
|
end)
|
||||||
|
|
||||||
|
list
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,10 @@
|
||||||
|
# Pleroma: A lightweight social networking server
|
||||||
|
# Copyright © 2017-2023 Pleroma Authors <https://pleroma.social/>
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
defmodule Pleroma.Web.ApiSpec.Scopes.Translator do
|
||||||
|
require Pleroma.Web.ApiSpec.Scopes.Compiler
|
||||||
|
require Pleroma.Web.Gettext
|
||||||
|
|
||||||
|
@before_compile Pleroma.Web.ApiSpec.Scopes.Compiler
|
||||||
|
end
|
|
@ -8,7 +8,7 @@
|
||||||
<%= checkbox @form, :"scope_#{scope}", value: scope in @scopes && scope, checked_value: scope, unchecked_value: "", name: "authorization[scope][]" %>
|
<%= checkbox @form, :"scope_#{scope}", value: scope in @scopes && scope, checked_value: scope, unchecked_value: "", name: "authorization[scope][]" %>
|
||||||
<%= label @form, :"scope_#{scope}", String.capitalize(scope) %>
|
<%= label @form, :"scope_#{scope}", String.capitalize(scope) %>
|
||||||
<%= if scope in @scopes && scope do %>
|
<%= if scope in @scopes && scope do %>
|
||||||
<%= String.capitalize(scope) %>
|
<code><%= scope %></code> <%= :"Elixir.Gettext".dgettext(Gettext, "oauth_scopes", scope) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
|
|
@ -0,0 +1,264 @@
|
||||||
|
# SOME DESCRIPTIVE TITLE.
|
||||||
|
# Copyright (C) YEAR Free Software Foundation, Inc.
|
||||||
|
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||||
|
#
|
||||||
|
#, fuzzy
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
|
"PO-Revision-Date: 2023-05-02 17:02-0400\n"
|
||||||
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=CHARSET\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "admin"
|
||||||
|
msgstr "All admin access"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "admin:read"
|
||||||
|
msgstr "Read all using admin API"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "admin:write"
|
||||||
|
msgstr "Write all using admin API"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "follow"
|
||||||
|
msgstr "Read and write user relationships"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "push"
|
||||||
|
msgstr "Push notifications"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "read"
|
||||||
|
msgstr "Read everything"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "read:accounts"
|
||||||
|
msgstr "Read information of all accounts"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "read:backups"
|
||||||
|
msgstr "Read your backups"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "read:blocks"
|
||||||
|
msgstr "Read block relationships"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "read:bookmarks"
|
||||||
|
msgstr "Read your bookmarks"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "read:chats"
|
||||||
|
msgstr "Read your chats"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "read:favourites"
|
||||||
|
msgstr "Read your favourites"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "read:filters"
|
||||||
|
msgstr "Read your filtering settings"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "read:follows"
|
||||||
|
msgstr "Read follow relationships"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "read:lists"
|
||||||
|
msgstr "Read your lists"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "read:notifications"
|
||||||
|
msgstr "Read your notifications"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "read:reports"
|
||||||
|
msgstr "Read your reports"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "read:search"
|
||||||
|
msgstr "Perform searches"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "read:statuses"
|
||||||
|
msgstr "Read all statuses you can see"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "write"
|
||||||
|
msgstr "Write everything"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "write:accounts"
|
||||||
|
msgstr "Change your account information"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "write:blocks"
|
||||||
|
msgstr "Block or unblock someone"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "write:bookmarks"
|
||||||
|
msgstr "Add to or remove from your bookmarks"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "write:chats"
|
||||||
|
msgstr "Create or delete chats or chat messages, or mark them as read"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "write:conversations"
|
||||||
|
msgstr "Change recipients of, mark as read, or delete conversations"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "write:favourites"
|
||||||
|
msgstr "Favourite or unfavourite statuses"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "write:filters"
|
||||||
|
msgstr "Change your filtering settings"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "write:follow"
|
||||||
|
msgstr "Follow or unfollow someone"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "write:follows"
|
||||||
|
msgstr "Follow or unfollow someone"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "write:lists"
|
||||||
|
msgstr "Create, change or delete your lists"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "write:media"
|
||||||
|
msgstr "Upload media files or modify those you uploaded"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "write:mutes"
|
||||||
|
msgstr "Mute or unmute someone"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "write:notifications"
|
||||||
|
msgstr "Mark notifications as read"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "write:reports"
|
||||||
|
msgstr "Submit reports"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "write:statuses"
|
||||||
|
msgstr "Post, edit, reblog or react to statuses"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "admin:read:accounts"
|
||||||
|
msgstr "Read all accounts using admin API"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "admin:read:chats"
|
||||||
|
msgstr "Read all chats using admin API"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "admin:read:invites"
|
||||||
|
msgstr "Read all invites using admin API"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "admin:read:media_proxy_caches"
|
||||||
|
msgstr "Read media proxy caches using admin API"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "admin:read:reports"
|
||||||
|
msgstr "Read all reports using admin API"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "admin:read:statuses"
|
||||||
|
msgstr "Read all statuses using admin API"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "admin:write:accounts"
|
||||||
|
msgstr "Change all accounts using admin API"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "admin:write:chats"
|
||||||
|
msgstr "Change all chats using admin API"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "admin:write:follows"
|
||||||
|
msgstr "Change follow relationships using admin API"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "admin:write:invites"
|
||||||
|
msgstr "Invite or revoke an invite using admin API"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "admin:write:media_proxy_caches"
|
||||||
|
msgstr "Change media proxy caches using admin API"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "admin:write:reports"
|
||||||
|
msgstr "Handle reports using admin API"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "admin:write:statuses"
|
||||||
|
msgstr "Delete, change scope of, or mark as sensitive statuses using admin API"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "read:media"
|
||||||
|
msgstr "Read media attachments"
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "read:mutes"
|
||||||
|
msgstr "Read mute relationships"
|
|
@ -0,0 +1,261 @@
|
||||||
|
## This file is a PO Template file.
|
||||||
|
##
|
||||||
|
## "msgid"s here are often extracted from source code.
|
||||||
|
## Add new translations manually only if they're dynamic
|
||||||
|
## translations that can't be statically extracted.
|
||||||
|
##
|
||||||
|
## Run "mix gettext.extract" to bring this file up to
|
||||||
|
## date. Leave "msgstr"s empty as changing them here has no
|
||||||
|
## effect: edit them in PO (.po) files instead.
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "admin"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "admin:read"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "admin:write"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "follow"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "push"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "read"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "read:accounts"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "read:backups"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "read:blocks"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "read:bookmarks"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "read:chats"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "read:favourites"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "read:filters"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "read:follows"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "read:lists"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "read:notifications"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "read:reports"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "read:search"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "read:statuses"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "write"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "write:accounts"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "write:blocks"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "write:bookmarks"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "write:chats"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "write:conversations"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "write:favourites"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "write:filters"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "write:follow"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "write:follows"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "write:lists"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "write:media"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "write:mutes"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "write:notifications"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "write:reports"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "write:statuses"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "admin:read:accounts"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "admin:read:chats"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "admin:read:invites"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "admin:read:media_proxy_caches"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "admin:read:reports"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "admin:read:statuses"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "admin:write:accounts"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "admin:write:chats"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "admin:write:follows"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "admin:write:invites"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "admin:write:media_proxy_caches"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "admin:write:reports"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "admin:write:statuses"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "read:media"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
#: lib/pleroma/web/api_spec/scopes/translator.ex:5
|
||||||
|
msgid "read:mutes"
|
||||||
|
msgstr ""
|
|
@ -0,0 +1,56 @@
|
||||||
|
# Pleroma: A lightweight social networking server
|
||||||
|
# Copyright © 2017-2023 Pleroma Authors <https://pleroma.social/>
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
defmodule Pleroma.Web.ApiSpec.Scopes.CompilerTest do
|
||||||
|
use ExUnit.Case, async: true
|
||||||
|
|
||||||
|
alias Pleroma.Web.ApiSpec.Scopes.Compiler
|
||||||
|
|
||||||
|
@dummy_response %{}
|
||||||
|
|
||||||
|
@data %{
|
||||||
|
paths: %{
|
||||||
|
"/mew" => %OpenApiSpex.PathItem{
|
||||||
|
post: %OpenApiSpex.Operation{
|
||||||
|
security: [%{"oAuth" => ["a:b:c"]}],
|
||||||
|
responses: @dummy_response
|
||||||
|
},
|
||||||
|
get: %OpenApiSpex.Operation{security: nil, responses: @dummy_response}
|
||||||
|
},
|
||||||
|
"/mew2" => %OpenApiSpex.PathItem{
|
||||||
|
post: %OpenApiSpex.Operation{
|
||||||
|
security: [%{"oAuth" => ["d:e", "f:g"]}],
|
||||||
|
responses: @dummy_response
|
||||||
|
},
|
||||||
|
get: %OpenApiSpex.Operation{security: nil, responses: @dummy_response}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
describe "process_scope/1" do
|
||||||
|
test "gives all higher-level scopes" do
|
||||||
|
scopes = Compiler.process_scope("admin:read:accounts")
|
||||||
|
|
||||||
|
assert [_, _, _] = scopes
|
||||||
|
assert "admin" in scopes
|
||||||
|
assert "admin:read" in scopes
|
||||||
|
assert "admin:read:accounts" in scopes
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "extract_all_scopes_from/1" do
|
||||||
|
test "extracts scopes" do
|
||||||
|
scopes = Compiler.extract_all_scopes_from(@data)
|
||||||
|
|
||||||
|
assert [_, _, _, _, _, _, _] = scopes
|
||||||
|
assert "a" in scopes
|
||||||
|
assert "a:b" in scopes
|
||||||
|
assert "a:b:c" in scopes
|
||||||
|
assert "d" in scopes
|
||||||
|
assert "d:e" in scopes
|
||||||
|
assert "f" in scopes
|
||||||
|
assert "f:g" in scopes
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue