mirror of
https://github.com/mastodon/mastodon.git
synced 2026-04-24 15:18:46 -05:00
Some checks are pending
Check i18n / check-i18n (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
Ruby Linting / lint (push) Waiting to run
Historical data migration test / test (14-alpine) (push) Waiting to run
Historical data migration test / test (15-alpine) (push) Waiting to run
Historical data migration test / test (16-alpine) (push) Waiting to run
Historical data migration test / test (17-alpine) (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.1) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / Libvips tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / Libvips tests (3.1) (push) Blocked by required conditions
Ruby Testing / Libvips tests (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.1) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.1, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
77 lines
1.8 KiB
Ruby
77 lines
1.8 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class OauthMetadataPresenter < ActiveModelSerializers::Model
|
|
include RoutingHelper
|
|
|
|
attributes :issuer, :authorization_endpoint, :token_endpoint,
|
|
:revocation_endpoint, :scopes_supported,
|
|
:response_types_supported, :response_modes_supported,
|
|
:grant_types_supported, :token_endpoint_auth_methods_supported,
|
|
:code_challenge_methods_supported,
|
|
:service_documentation, :app_registration_endpoint
|
|
|
|
def issuer
|
|
root_url
|
|
end
|
|
|
|
def service_documentation
|
|
'https://docs.joinmastodon.org/'
|
|
end
|
|
|
|
def authorization_endpoint
|
|
oauth_authorization_url
|
|
end
|
|
|
|
def token_endpoint
|
|
oauth_token_url
|
|
end
|
|
|
|
def userinfo_endpoint
|
|
oauth_userinfo_url
|
|
end
|
|
|
|
# As the api_v1_apps route doesn't technically conform to the specification
|
|
# for OAuth 2.0 Dynamic Client Registration defined in RFC 7591 we use a
|
|
# non-standard property for now to indicate the mastodon specific registration
|
|
# endpoint. See: https://datatracker.ietf.org/doc/html/rfc7591
|
|
def app_registration_endpoint
|
|
api_v1_apps_url
|
|
end
|
|
|
|
def revocation_endpoint
|
|
oauth_revoke_url
|
|
end
|
|
|
|
def scopes_supported
|
|
doorkeeper.scopes
|
|
end
|
|
|
|
def response_types_supported
|
|
doorkeeper.authorization_response_types
|
|
end
|
|
|
|
def response_modes_supported
|
|
doorkeeper.authorization_response_flows.flat_map(&:response_mode_matches).uniq
|
|
end
|
|
|
|
def grant_types_supported
|
|
grant_types_supported = doorkeeper.grant_flows.dup
|
|
grant_types_supported << 'refresh_token' if doorkeeper.refresh_token_enabled?
|
|
grant_types_supported
|
|
end
|
|
|
|
def token_endpoint_auth_methods_supported
|
|
%w(client_secret_basic client_secret_post)
|
|
end
|
|
|
|
def code_challenge_methods_supported
|
|
%w(S256)
|
|
end
|
|
|
|
private
|
|
|
|
def doorkeeper
|
|
@doorkeeper ||= Doorkeeper.configuration
|
|
end
|
|
end
|