]> git.openstreetmap.org Git - rails.git/blob - lib/oauth.rb
Merge pull request #4316 from AntonKhorev/block-reason-max-length
[rails.git] / lib / oauth.rb
1 module Oauth
2   SCOPES = %w[
3     read_prefs write_prefs write_diary
4     write_api read_gpx write_gpx write_notes write_redactions
5     consume_messages send_messages openid
6   ].freeze
7   PRIVILEGED_SCOPES = %w[read_email skip_authorization].freeze
8   MODERATOR_SCOPES = %w[write_redactions].freeze
9
10   class Scope
11     attr_reader :name
12
13     def initialize(name)
14       @name = name
15     end
16
17     def description
18       I18n.t("oauth.scopes.#{name}")
19     end
20   end
21
22   def self.scopes(privileged: false)
23     scopes = SCOPES
24     scopes += PRIVILEGED_SCOPES if privileged
25     scopes.collect { |s| Scope.new(s) }
26   end
27 end