garage-doorkeeper 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/CHANGELOG.md +2 -0
- data/Gemfile +24 -0
- data/LICENSE.txt +22 -0
- data/README.md +52 -0
- data/Rakefile +2 -0
- data/garage-doorkeeper.gemspec +22 -0
- data/lib/garage/doorkeeper/version.rb +5 -0
- data/lib/garage/doorkeeper.rb +4 -0
- data/lib/garage/strategy/doorkeeper.rb +28 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/api_controller.rb +11 -0
- data/spec/dummy/app/controllers/application_controller.rb +10 -0
- data/spec/dummy/app/controllers/echos_controller.rb +5 -0
- data/spec/dummy/app/controllers/posts_controller.rb +101 -0
- data/spec/dummy/app/controllers/sessions_controller.rb +19 -0
- data/spec/dummy/app/controllers/users_controller.rb +6 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/helpers/current_user_helper.rb +5 -0
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/models/comment.rb +17 -0
- data/spec/dummy/app/models/namespaced_post.rb +7 -0
- data/spec/dummy/app/models/post.rb +43 -0
- data/spec/dummy/app/models/post_body.rb +3 -0
- data/spec/dummy/app/models/post_stream.rb +2 -0
- data/spec/dummy/app/models/private_post.rb +7 -0
- data/spec/dummy/app/models/user.rb +17 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/sessions/create.html.erb +1 -0
- data/spec/dummy/app/views/sessions/destroy.html.erb +1 -0
- data/spec/dummy/app/views/sessions/new.html.erb +4 -0
- data/spec/dummy/app/views/sessions/show.html.erb +7 -0
- data/spec/dummy/config/application.rb +59 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +39 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +72 -0
- data/spec/dummy/config/environments/test.rb +34 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/doorkeeper.rb +1 -0
- data/spec/dummy/config/initializers/garage.rb +53 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/doorkeeper.en.yml +68 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +30 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/migrate/20130501215002_create_doorkeeper_tables.rb +42 -0
- data/spec/dummy/db/migrate/20130501215033_create_users.rb +10 -0
- data/spec/dummy/db/migrate/20130501215056_create_posts.rb +11 -0
- data/spec/dummy/db/migrate/20130508032709_create_comments.rb +11 -0
- data/spec/dummy/db/schema.rb +78 -0
- data/spec/dummy/doc/garage/overview.ja.md +3 -0
- data/spec/dummy/doc/garage/overview.md +1 -0
- data/spec/dummy/doc/garage/resources/post.md +1 -0
- data/spec/dummy/doc/garage/resources/user.md +90 -0
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/factories/comment.rb +7 -0
- data/spec/factories/doorkeeper.rb +24 -0
- data/spec/factories/post.rb +7 -0
- data/spec/factories/user.rb +6 -0
- data/spec/requests/authentication_spec.rb +35 -0
- data/spec/requests/authorization_spec.rb +197 -0
- data/spec/spec_helper.rb +20 -0
- data/spec/support/authenticated_context.rb +33 -0
- data/spec/support/database_cleaner.rb +16 -0
- data/spec/support/rest_api_spec_helper.rb +46 -0
- metadata +217 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
class Comment < ActiveRecord::Base
|
2
|
+
belongs_to :user
|
3
|
+
belongs_to :post
|
4
|
+
|
5
|
+
alias :commenter :user
|
6
|
+
|
7
|
+
def post_owner
|
8
|
+
post.user
|
9
|
+
end
|
10
|
+
|
11
|
+
include Garage::Representer
|
12
|
+
|
13
|
+
property :id
|
14
|
+
property :body
|
15
|
+
property :commenter # no :selectable here!
|
16
|
+
property :post_owner, selectable: true
|
17
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
class Post < ActiveRecord::Base
|
2
|
+
belongs_to :user, :touch => true
|
3
|
+
has_many :comments
|
4
|
+
|
5
|
+
include Garage::Representer
|
6
|
+
include Garage::Authorizable
|
7
|
+
|
8
|
+
property :id
|
9
|
+
property :title
|
10
|
+
property :body, selectable: accessible(PostBody)
|
11
|
+
property :tag, as: :label, selectable: true
|
12
|
+
property :user, selectable: true
|
13
|
+
|
14
|
+
collection :comments, selectable: true
|
15
|
+
|
16
|
+
link(:self) { post_path(self) }
|
17
|
+
|
18
|
+
def tag
|
19
|
+
'cat'
|
20
|
+
end
|
21
|
+
|
22
|
+
def owner
|
23
|
+
user
|
24
|
+
end
|
25
|
+
|
26
|
+
def build_permissions(perms, other)
|
27
|
+
perms.permits! :read
|
28
|
+
perms.permits! :write if owner == other
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.build_permissions(perms, other, target)
|
32
|
+
if target[:user]
|
33
|
+
perms.permits! :read, :write if target[:user] == other
|
34
|
+
else
|
35
|
+
# public resource i.e. /posts
|
36
|
+
perms.permits! :read, :write
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.garage_examples(user)
|
41
|
+
[:posts_path, Post.first]
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class User < ActiveRecord::Base
|
2
|
+
has_many :posts
|
3
|
+
|
4
|
+
include Garage::Representer
|
5
|
+
|
6
|
+
property :id
|
7
|
+
property :name
|
8
|
+
property :email
|
9
|
+
|
10
|
+
link(:self) { user_path(self) }
|
11
|
+
link(:canonical) { user_path(self) }
|
12
|
+
link(:posts) { user_posts_path(self) }
|
13
|
+
|
14
|
+
def self.garage_examples(user)
|
15
|
+
[:users_path, user]
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Done!
|
@@ -0,0 +1 @@
|
|
1
|
+
Signed out.
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
# Pick the frameworks you want:
|
4
|
+
require "active_record/railtie"
|
5
|
+
require "action_controller/railtie"
|
6
|
+
require "action_mailer/railtie"
|
7
|
+
require "sprockets/railtie"
|
8
|
+
|
9
|
+
Bundler.require(*Rails.groups)
|
10
|
+
require "garage"
|
11
|
+
require "garage/docs"
|
12
|
+
require "garage/meta"
|
13
|
+
|
14
|
+
module Dummy
|
15
|
+
class Application < Rails::Application
|
16
|
+
# Settings in config/environments/* take precedence over those specified here.
|
17
|
+
# Application configuration should go into files in config/initializers
|
18
|
+
# -- all .rb files in that directory are automatically loaded.
|
19
|
+
|
20
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
21
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
22
|
+
|
23
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
24
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
25
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
26
|
+
|
27
|
+
# Activate observers that should always be running.
|
28
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
29
|
+
|
30
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
31
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
32
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
33
|
+
|
34
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
35
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
36
|
+
# config.i18n.default_locale = :de
|
37
|
+
|
38
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
39
|
+
config.encoding = "utf-8"
|
40
|
+
|
41
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
42
|
+
config.filter_parameters += [:password]
|
43
|
+
|
44
|
+
# Enable escaping HTML in JSON.
|
45
|
+
config.active_support.escape_html_entities_in_json = true
|
46
|
+
|
47
|
+
# Use SQL instead of Active Record's schema dumper when creating the database.
|
48
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
49
|
+
# like if you have constraints or database-specific column types
|
50
|
+
# config.active_record.schema_format = :sql
|
51
|
+
|
52
|
+
# Enable the asset pipeline
|
53
|
+
config.assets.enabled = true
|
54
|
+
|
55
|
+
# Version of your assets, change this if you want to expire all your assets
|
56
|
+
config.assets.version = '1.0'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# MySQL. Versions 4.1 and 5.0 are recommended.
|
2
|
+
#
|
3
|
+
# Install the MYSQL driver
|
4
|
+
# gem install mysql2
|
5
|
+
#
|
6
|
+
# Ensure the MySQL gem is defined in your Gemfile
|
7
|
+
# gem 'mysql2'
|
8
|
+
#
|
9
|
+
# And be sure to use new-style password hashing:
|
10
|
+
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
|
11
|
+
development:
|
12
|
+
adapter: mysql2
|
13
|
+
encoding: utf8
|
14
|
+
database: garage_dummy_development
|
15
|
+
pool: 5
|
16
|
+
username: root
|
17
|
+
password:
|
18
|
+
host: localhost
|
19
|
+
|
20
|
+
# Warning: The database defined as "test" will be erased and
|
21
|
+
# re-generated from your development database when you run "rake".
|
22
|
+
# Do not set this db to the same as development or production.
|
23
|
+
test:
|
24
|
+
adapter: mysql2
|
25
|
+
encoding: utf8
|
26
|
+
database: garage_dummy_test
|
27
|
+
pool: 5
|
28
|
+
username: root
|
29
|
+
password:
|
30
|
+
host: localhost
|
31
|
+
|
32
|
+
production:
|
33
|
+
adapter: mysql2
|
34
|
+
encoding: utf8
|
35
|
+
database: garage_dummy_production
|
36
|
+
pool: 5
|
37
|
+
username: root
|
38
|
+
password:
|
39
|
+
host: localhost
|
@@ -0,0 +1,37 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the web server when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Log error messages when you accidentally call methods on nil.
|
10
|
+
config.whiny_nils = true
|
11
|
+
|
12
|
+
# Show full error reports and disable caching
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
config.action_controller.perform_caching = false
|
15
|
+
|
16
|
+
# Don't care if the mailer can't send
|
17
|
+
config.action_mailer.raise_delivery_errors = false
|
18
|
+
|
19
|
+
# Print deprecation notices to the Rails logger
|
20
|
+
config.active_support.deprecation = :log
|
21
|
+
|
22
|
+
# Only use best-standards-support built into browsers
|
23
|
+
config.action_dispatch.best_standards_support = :builtin
|
24
|
+
|
25
|
+
# Raise exception on mass assignment protection for Active Record models
|
26
|
+
config.active_record.mass_assignment_sanitizer = :strict
|
27
|
+
|
28
|
+
# Log the query plan for queries taking more than this (works
|
29
|
+
# with SQLite, MySQL, and PostgreSQL)
|
30
|
+
config.active_record.auto_explain_threshold_in_seconds = 0.5
|
31
|
+
|
32
|
+
# Do not compress assets
|
33
|
+
config.assets.compress = false
|
34
|
+
|
35
|
+
# Expands the lines which load the assets
|
36
|
+
config.assets.debug = true
|
37
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# Code is not reloaded between requests
|
5
|
+
config.cache_classes = true
|
6
|
+
|
7
|
+
# Full error reports are disabled and caching is turned on
|
8
|
+
config.consider_all_requests_local = false
|
9
|
+
config.action_controller.perform_caching = true
|
10
|
+
|
11
|
+
# Disable Rails's static asset server (Apache or nginx will already do this)
|
12
|
+
if Rails::VERSION::MAJOR > 4 ||
|
13
|
+
(Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2)
|
14
|
+
config.serve_static_files = false
|
15
|
+
else
|
16
|
+
config.serve_static_assets = false
|
17
|
+
end
|
18
|
+
|
19
|
+
# Compress JavaScripts and CSS
|
20
|
+
config.assets.compress = true
|
21
|
+
|
22
|
+
# Don't fallback to assets pipeline if a precompiled asset is missed
|
23
|
+
config.assets.compile = false
|
24
|
+
|
25
|
+
# Generate digests for assets URLs
|
26
|
+
config.assets.digest = true
|
27
|
+
|
28
|
+
# Defaults to nil and saved in location specified by config.assets.prefix
|
29
|
+
# config.assets.manifest = YOUR_PATH
|
30
|
+
|
31
|
+
# Specifies the header that your server uses for sending files
|
32
|
+
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
|
33
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
|
34
|
+
|
35
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
36
|
+
# config.force_ssl = true
|
37
|
+
|
38
|
+
# See everything in the log (default is :info)
|
39
|
+
# config.log_level = :debug
|
40
|
+
|
41
|
+
# Prepend all log lines with the following tags
|
42
|
+
# config.log_tags = [ :subdomain, :uuid ]
|
43
|
+
|
44
|
+
# Use a different logger for distributed setups
|
45
|
+
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
|
46
|
+
|
47
|
+
# Use a different cache store in production
|
48
|
+
# config.cache_store = :mem_cache_store
|
49
|
+
|
50
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server
|
51
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
52
|
+
|
53
|
+
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
|
54
|
+
# config.assets.precompile += %w( search.js )
|
55
|
+
|
56
|
+
# Disable delivery errors, bad email addresses will be ignored
|
57
|
+
# config.action_mailer.raise_delivery_errors = false
|
58
|
+
|
59
|
+
# Enable threaded mode
|
60
|
+
# config.threadsafe!
|
61
|
+
|
62
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
63
|
+
# the I18n.default_locale when a translation can not be found)
|
64
|
+
config.i18n.fallbacks = true
|
65
|
+
|
66
|
+
# Send deprecation notices to registered listeners
|
67
|
+
config.active_support.deprecation = :notify
|
68
|
+
|
69
|
+
# Log the query plan for queries taking more than this (works
|
70
|
+
# with SQLite, MySQL, and PostgreSQL)
|
71
|
+
# config.active_record.auto_explain_threshold_in_seconds = 0.5
|
72
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# The test environment is used exclusively to run your application's
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
6
|
+
# your test database is "scratch space" for the test suite and is wiped
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
8
|
+
config.cache_classes = true
|
9
|
+
|
10
|
+
config.static_cache_control = "public, max-age=3600"
|
11
|
+
|
12
|
+
config.cache_store = :memory_store
|
13
|
+
|
14
|
+
config.eager_load = false
|
15
|
+
config.i18n.enforce_available_locales = true
|
16
|
+
|
17
|
+
# Show full error reports and disable caching
|
18
|
+
config.consider_all_requests_local = true
|
19
|
+
config.action_controller.perform_caching = false
|
20
|
+
|
21
|
+
# Raise exceptions instead of rendering exception templates
|
22
|
+
config.action_dispatch.show_exceptions = false
|
23
|
+
|
24
|
+
# Disable request forgery protection in test environment
|
25
|
+
config.action_controller.allow_forgery_protection = false
|
26
|
+
|
27
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
28
|
+
# The :test delivery method accumulates sent emails in the
|
29
|
+
# ActionMailer::Base.deliveries array.
|
30
|
+
config.action_mailer.delivery_method = :test
|
31
|
+
|
32
|
+
# Print deprecation notices to the stderr
|
33
|
+
config.active_support.deprecation = :stderr
|
34
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
4
|
+
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
5
|
+
|
6
|
+
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
7
|
+
# Rails.backtrace_cleaner.remove_silencers!
|
@@ -0,0 +1 @@
|
|
1
|
+
# Doorkeeper configuration is merged into garage.rb
|
@@ -0,0 +1,53 @@
|
|
1
|
+
Garage.configure {}
|
2
|
+
Garage.configuration.strategy = Garage::Strategy::Doorkeeper
|
3
|
+
|
4
|
+
Garage::TokenScope.configure do
|
5
|
+
register :public do
|
6
|
+
access :read, Post
|
7
|
+
end
|
8
|
+
|
9
|
+
register :read_private_post do
|
10
|
+
access :read, PrivatePost
|
11
|
+
end
|
12
|
+
|
13
|
+
register :write_post do
|
14
|
+
access :write, Post
|
15
|
+
end
|
16
|
+
|
17
|
+
register :read_post_body do
|
18
|
+
access :read, PostBody
|
19
|
+
end
|
20
|
+
|
21
|
+
register :sudo, hidden: true do
|
22
|
+
access :read, PrivatePost
|
23
|
+
access :read, PostStream
|
24
|
+
end
|
25
|
+
|
26
|
+
register :meta do
|
27
|
+
access :read, Garage::Meta::RemoteService
|
28
|
+
access :read, Garage::Docs::Document
|
29
|
+
end
|
30
|
+
|
31
|
+
namespace :foobar do
|
32
|
+
register :read_post do
|
33
|
+
access :read, NamespacedPost
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
Doorkeeper.configure do
|
39
|
+
orm :active_record
|
40
|
+
|
41
|
+
resource_owner_authenticator do
|
42
|
+
User.find_by_id(session[:user_id]) || redirect_to(new_session_url)
|
43
|
+
end
|
44
|
+
|
45
|
+
default_scopes(:public)
|
46
|
+
optional_scopes(*Garage::TokenScope.optional_scopes)
|
47
|
+
end
|
48
|
+
|
49
|
+
ActiveSupport::Notifications.subscribe "garage.request" do |name, start, finish, id, payload|
|
50
|
+
if payload[:token].application_id
|
51
|
+
payload[:controller].response.headers['Application-Id'] = payload[:token].application_id
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Add new inflection rules using the following format
|
4
|
+
# (all these examples are active by default):
|
5
|
+
# ActiveSupport::Inflector.inflections do |inflect|
|
6
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
7
|
+
# inflect.singular /^(ox)en/i, '\1'
|
8
|
+
# inflect.irregular 'person', 'people'
|
9
|
+
# inflect.uncountable %w( fish sheep )
|
10
|
+
# end
|
11
|
+
#
|
12
|
+
# These inflection rules are supported but not enabled by default:
|
13
|
+
# ActiveSupport::Inflector.inflections do |inflect|
|
14
|
+
# inflect.acronym 'RESTful'
|
15
|
+
# end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
# Make sure the secret is at least 30 characters and all random,
|
6
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
7
|
+
Dummy::Application.config.secret_key_base = '2f58fac7dbe443eb880bfa77f0ce9ed78e1def41da1feb2017e9eb44577c7b0e3b555b604c87563f137440fbe8ebef1e3356af2186c7d87b71cc809c33618fdf'
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
|
4
|
+
|
5
|
+
# Use the database for sessions instead of the cookie-based default,
|
6
|
+
# which shouldn't be used to store highly confidential information
|
7
|
+
# (create the session table with "rails generate session_migration")
|
8
|
+
# Dummy::Application.config.session_store :active_record_store
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
#
|
3
|
+
# This file contains settings for ActionController::ParamsWrapper which
|
4
|
+
# is enabled by default.
|
5
|
+
|
6
|
+
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
7
|
+
ActiveSupport.on_load(:action_controller) do
|
8
|
+
wrap_parameters format: [:json]
|
9
|
+
end
|
10
|
+
|
11
|
+
# Disable root element in JSON by default.
|
12
|
+
ActiveSupport.on_load(:active_record) do
|
13
|
+
self.include_root_in_json = false
|
14
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
en:
|
2
|
+
activerecord:
|
3
|
+
errors:
|
4
|
+
models:
|
5
|
+
application:
|
6
|
+
attributes:
|
7
|
+
redirect_uri:
|
8
|
+
fragment_present: 'cannot contain a fragment.'
|
9
|
+
has_query_parameter: 'cannot contain a query parameter.'
|
10
|
+
invalid_uri: 'must be a valid URI.'
|
11
|
+
relative_uri: 'must be an absolute URI.'
|
12
|
+
mongoid:
|
13
|
+
errors:
|
14
|
+
models:
|
15
|
+
application:
|
16
|
+
attributes:
|
17
|
+
redirect_uri:
|
18
|
+
fragment_present: 'cannot contain a fragment.'
|
19
|
+
has_query_parameter: 'cannot contain a query parameter.'
|
20
|
+
invalid_uri: 'must be a valid URI.'
|
21
|
+
relative_uri: 'must be an absolute URI.'
|
22
|
+
mongo_mapper:
|
23
|
+
errors:
|
24
|
+
models:
|
25
|
+
application:
|
26
|
+
attributes:
|
27
|
+
redirect_uri:
|
28
|
+
fragment_present: 'cannot contain a fragment.'
|
29
|
+
has_query_parameter: 'cannot contain a query parameter.'
|
30
|
+
invalid_uri: 'must be a valid URI.'
|
31
|
+
relative_uri: 'must be an absolute URI.'
|
32
|
+
doorkeeper:
|
33
|
+
errors:
|
34
|
+
messages:
|
35
|
+
# Common error messages
|
36
|
+
invalid_request: 'The request is missing a required parameter, includes an unsupported parameter value, or is otherwise malformed.'
|
37
|
+
invalid_redirect_uri: 'The redirect uri included is not valid.'
|
38
|
+
unauthorized_client: 'The client is not authorized to perform this request using this method.'
|
39
|
+
access_denied: 'The resource owner or authorization server denied the request.'
|
40
|
+
invalid_scope: 'The requested scope is invalid, unknown, or malformed.'
|
41
|
+
server_error: 'The authorization server encountered an unexpected condition which prevented it from fulfilling the request.'
|
42
|
+
temporarily_unavailable: 'The authorization server is currently unable to handle the request due to a temporary overloading or maintenance of the server.'
|
43
|
+
|
44
|
+
#configuration error messages
|
45
|
+
credential_flow_not_configured: 'Resource Owner Password Credentials flow failed due to Doorkeeper.configure.resource_owner_from_credentials being unconfigured.'
|
46
|
+
resource_owner_authenticator_not_configured: 'Resource Owner find failed due to Doorkeeper.configure.resource_owner_authenticator being unconfiged.'
|
47
|
+
|
48
|
+
# Access grant errors
|
49
|
+
unsupported_response_type: 'The authorization server does not support this response type.'
|
50
|
+
|
51
|
+
# Access token errors
|
52
|
+
invalid_client: 'Client authentication failed due to unknown client, no client authentication included, or unsupported authentication method.'
|
53
|
+
invalid_grant: 'The provided authorization grant is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client.'
|
54
|
+
unsupported_grant_type: 'The authorization grant type is not supported by the authorization server.'
|
55
|
+
|
56
|
+
# Password Access token errors
|
57
|
+
invalid_resource_owner: 'The provided resource owner credentials are not valid, or resource owner cannot be found'
|
58
|
+
flash:
|
59
|
+
applications:
|
60
|
+
create:
|
61
|
+
notice: 'Application created.'
|
62
|
+
destroy:
|
63
|
+
notice: 'Application deleted.'
|
64
|
+
update:
|
65
|
+
notice: 'Application updated.'
|
66
|
+
authorized_applications:
|
67
|
+
destroy:
|
68
|
+
notice: 'Application revoked.'
|
@@ -0,0 +1,30 @@
|
|
1
|
+
Rails.application.routes.draw do
|
2
|
+
use_doorkeeper
|
3
|
+
|
4
|
+
mount Garage::Docs::Engine => '/docs'
|
5
|
+
mount Garage::Meta::Engine => '/meta'
|
6
|
+
|
7
|
+
resources :posts do
|
8
|
+
collection do
|
9
|
+
get :hide
|
10
|
+
get :capped
|
11
|
+
get :namespaced
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
resources :users do
|
16
|
+
resources :posts do
|
17
|
+
collection do
|
18
|
+
get :private
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
resources :public_posts, only: :index
|
23
|
+
end
|
24
|
+
|
25
|
+
resource :session
|
26
|
+
resource :echo
|
27
|
+
resource :ping
|
28
|
+
|
29
|
+
get :mine, to: 'public_posts#my'
|
30
|
+
end
|