mirror of
https://github.com/mastodon/mastodon.git
synced 2025-05-13 05:01:10 +00:00
Add offline_access scope
This commit is contained in:
parent
7898619d74
commit
1af6ae19b9
|
@ -14,6 +14,8 @@ class ScopeTransformer < Parslet::Transform
|
||||||
|
|
||||||
# # override for profile scope which is read only
|
# # override for profile scope which is read only
|
||||||
@access = %w(read) if @term == 'profile'
|
@access = %w(read) if @term == 'profile'
|
||||||
|
# Override offline_access since it doesn't imply read or write access:
|
||||||
|
@access = %w(offline) if @term == 'offline_access'
|
||||||
end
|
end
|
||||||
|
|
||||||
def key
|
def key
|
||||||
|
|
|
@ -35,10 +35,10 @@ Doorkeeper.configure do
|
||||||
# context.client for client (Doorkeeper::Application)
|
# context.client for client (Doorkeeper::Application)
|
||||||
# context.scopes for scopes
|
# context.scopes for scopes
|
||||||
custom_access_token_expires_in do |context|
|
custom_access_token_expires_in do |context|
|
||||||
# If the client is confidential (all clients pre 4.3), then we don't want to
|
# If the client is confidential (all clients pre 4.3) and it hasn't
|
||||||
# expire access tokens. Applications created by users are also considered
|
# requested offline_access, then we don't want to expire access tokens.
|
||||||
# confidential.
|
# Applications created by users are also considered confidential.
|
||||||
if context.client.confidential?
|
if context.client.confidential? && !context.scopes.exists?('offline_access')
|
||||||
nil
|
nil
|
||||||
else
|
else
|
||||||
15.minutes.to_i
|
15.minutes.to_i
|
||||||
|
@ -80,6 +80,7 @@ Doorkeeper.configure do
|
||||||
# https://github.com/doorkeeper-gem/doorkeeper/wiki/Using-Scopes
|
# https://github.com/doorkeeper-gem/doorkeeper/wiki/Using-Scopes
|
||||||
default_scopes :read
|
default_scopes :read
|
||||||
optional_scopes :profile,
|
optional_scopes :profile,
|
||||||
|
:offline_access,
|
||||||
:write,
|
:write,
|
||||||
:'write:accounts',
|
:'write:accounts',
|
||||||
:'write:blocks',
|
:'write:blocks',
|
||||||
|
|
|
@ -89,6 +89,7 @@ en:
|
||||||
invalid_request:
|
invalid_request:
|
||||||
missing_param: 'Missing required parameter: %{value}.'
|
missing_param: 'Missing required parameter: %{value}.'
|
||||||
request_not_authorized: Request need to be authorized. Required parameter for authorizing request is missing or invalid.
|
request_not_authorized: Request need to be authorized. Required parameter for authorizing request is missing or invalid.
|
||||||
|
offline_access_only: The offline_access scope can only be used with other scopes.
|
||||||
unknown: The request is missing a required parameter, includes an unsupported parameter value, or is otherwise malformed.
|
unknown: The request is missing a required parameter, includes an unsupported parameter value, or is otherwise malformed.
|
||||||
invalid_resource_owner: The provided resource owner credentials are not valid, or resource owner cannot be found
|
invalid_resource_owner: The provided resource owner credentials are not valid, or resource owner cannot be found
|
||||||
invalid_scope: The requested scope is invalid, unknown, or malformed.
|
invalid_scope: The requested scope is invalid, unknown, or malformed.
|
||||||
|
@ -118,6 +119,7 @@ en:
|
||||||
read: Read-only access
|
read: Read-only access
|
||||||
read/write: Read and write access
|
read/write: Read and write access
|
||||||
write: Write-only access
|
write: Write-only access
|
||||||
|
offline: Access for an extended period of time
|
||||||
title:
|
title:
|
||||||
accounts: Accounts
|
accounts: Accounts
|
||||||
admin/accounts: Administration of accounts
|
admin/accounts: Administration of accounts
|
||||||
|
@ -138,6 +140,7 @@ en:
|
||||||
notifications: Notifications
|
notifications: Notifications
|
||||||
profile: Your Mastodon profile
|
profile: Your Mastodon profile
|
||||||
push: Push notifications
|
push: Push notifications
|
||||||
|
offline_access: Offline access
|
||||||
reports: Reports
|
reports: Reports
|
||||||
search: Search
|
search: Search
|
||||||
statuses: Posts
|
statuses: Posts
|
||||||
|
|
|
@ -23,6 +23,12 @@ RSpec.describe ScopeTransformer do
|
||||||
it_behaves_like 'a scope', nil, 'profile', 'read'
|
it_behaves_like 'a scope', nil, 'profile', 'read'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with scope "offline_access"' do
|
||||||
|
let(:input) { 'offline_access' }
|
||||||
|
|
||||||
|
it_behaves_like 'a scope', nil, 'offline_access', 'offline'
|
||||||
|
end
|
||||||
|
|
||||||
context 'with scope "read"' do
|
context 'with scope "read"' do
|
||||||
let(:input) { 'read' }
|
let(:input) { 'read' }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user