doorkeeper-grants_assertion 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/Gemfile +12 -0
- data/MIT-LICENSE +21 -0
- data/README.md +30 -0
- data/Rakefile +18 -0
- data/config/locales/en.yml +5 -0
- data/doorkeeper-grants_assertion.gemspec +22 -0
- data/lib/doorkeeper/grants_assertion.rb +27 -0
- data/lib/doorkeeper/request/assertion.rb +29 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/controllers/custom_authorizations_controller.rb +7 -0
- data/spec/dummy/app/controllers/full_protected_resources_controller.rb +12 -0
- data/spec/dummy/app/controllers/home_controller.rb +17 -0
- data/spec/dummy/app/controllers/metal_controller.rb +11 -0
- data/spec/dummy/app/controllers/semi_protected_resources_controller.rb +11 -0
- data/spec/dummy/app/helpers/application_helper.rb +5 -0
- data/spec/dummy/app/models/user.rb +9 -0
- data/spec/dummy/app/views/home/index.html.erb +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +47 -0
- data/spec/dummy/config/boot.rb +4 -0
- data/spec/dummy/config/database.yml +15 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +29 -0
- data/spec/dummy/config/environments/production.rb +62 -0
- data/spec/dummy/config/environments/test.rb +51 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/doorkeeper.rb +92 -0
- data/spec/dummy/config/initializers/secret_token.rb +9 -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 +74 -0
- data/spec/dummy/config/routes.rb +52 -0
- data/spec/dummy/db/migrate/20111122132257_create_users.rb +10 -0
- data/spec/dummy/db/migrate/20130902165751_create_doorkeeper_tables.rb +41 -0
- data/spec/dummy/db/migrate/20130902175349_add_owner_to_application.rb +7 -0
- data/spec/dummy/db/schema.rb +66 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/factories/access_grant.rb +9 -0
- data/spec/factories/access_token.rb +11 -0
- data/spec/factories/application.rb +6 -0
- data/spec/requests/flows/assertion_spec.rb +74 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/spec_helper_integration.rb +29 -0
- data/spec/support/dependencies/factory_girl.rb +2 -0
- data/spec/support/helpers/config_helper.rb +9 -0
- data/spec/support/helpers/model_helper.rb +45 -0
- data/spec/support/helpers/request_spec_helper.rb +76 -0
- data/spec/support/helpers/url_helper.rb +19 -0
- data/spec/support/shared/controllers_shared_context.rb +60 -0
- data/spec/support/shared/models_shared_examples.rb +52 -0
- metadata +195 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 87bb84b4d2dda652ff143b5c6e8f532c7dcb875c
|
4
|
+
data.tar.gz: 82792c4551fb2938c4492b995e4a0e1c76a41728
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1f7410f081c0b09f24102ff531acc1b37eb7e753515657caa6e74c9c83ba4e4916b4e3d61ec9883275065eaef4b4f421d54294341d09c7653aca0b8336f0aca8
|
7
|
+
data.tar.gz: 91eaaeaa2c25ec48dde6b9ed544b079950dbb2de07cc0482d35c3b688ed4e05fdfc6dc841a51b17381b1e48f325ee020562d028620ce5588ef8ac893f35c8c80
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Doorkeeper Rubygem
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# Doorkeeper - Assertion Grant Extension
|
2
|
+
|
3
|
+
Assertion grant extension for Doorkeeper. Born from:
|
4
|
+
https://github.com/doorkeeper-gem/doorkeeper/pull/249
|
5
|
+
|
6
|
+
## Instalation
|
7
|
+
|
8
|
+
1. Add both gems to your `Gemfile`.
|
9
|
+
2. Add `assertion` as a `grant_flow` to your initializer.
|
10
|
+
|
11
|
+
___
|
12
|
+
|
13
|
+
Lets you define your own way of authenticating resource owners via 3rd Party
|
14
|
+
applications. For example, via Facebook:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
Doorkeeper.configure do
|
18
|
+
resource_owner_from_assertion do
|
19
|
+
facebook = URI.parse('https://graph.facebook.com/me?access_token=' +
|
20
|
+
params[:assertion])
|
21
|
+
response = Net::HTTP.get_response(facebook)
|
22
|
+
user_data = JSON.parse(response.body)
|
23
|
+
User.find_by_facebook_id(user_data['id'])
|
24
|
+
end
|
25
|
+
end
|
26
|
+
```
|
27
|
+
|
28
|
+
___
|
29
|
+
|
30
|
+
IETF standard: http://tools.ietf.org/html/draft-ietf-oauth-assertions-16
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
|
4
|
+
desc 'Default: run specs.'
|
5
|
+
task :default => :spec
|
6
|
+
|
7
|
+
desc "Run all specs"
|
8
|
+
RSpec::Core::RakeTask.new(:spec)
|
9
|
+
|
10
|
+
namespace :doorkeeper do
|
11
|
+
desc "Install doorkeeper in dummy app"
|
12
|
+
task :install do
|
13
|
+
cd 'spec/dummy'
|
14
|
+
system 'bundle exec rails g doorkeeper:install --force'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
Bundler::GemHelper.install_tasks
|
@@ -0,0 +1,22 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'doorkeeper-grants_assertion'
|
3
|
+
s.version = '0.0.1'
|
4
|
+
s.authors = ['Tute Costa']
|
5
|
+
s.email = ['tutecosta@gmail.com']
|
6
|
+
s.homepage = "https://github.com/doorkeeper-gem/doorkeeper/doorkeeper-grants-assertion"
|
7
|
+
s.summary = "Assertion grant extension for Doorkeeper."
|
8
|
+
s.description = "Assertion grant extension for Doorkeeper."
|
9
|
+
s.license = 'MIT'
|
10
|
+
|
11
|
+
s.files = `git ls-files`.split("\n")
|
12
|
+
s.test_files = `git ls-files -- test/*`.split("\n")
|
13
|
+
s.require_paths = ["lib"]
|
14
|
+
|
15
|
+
s.add_dependency "railties", ">= 3.1"
|
16
|
+
s.add_dependency "doorkeeper", ">= 1.3"
|
17
|
+
s.add_development_dependency "rspec-rails", ">= 2.11.4"
|
18
|
+
s.add_development_dependency "capybara", "~> 1.1.2"
|
19
|
+
s.add_development_dependency "factory_girl", "~> 2.6.4"
|
20
|
+
s.add_development_dependency "generator_spec", "~> 0.9.0"
|
21
|
+
s.add_development_dependency "database_cleaner", "~> 1.2.0"
|
22
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'doorkeeper/request/assertion'
|
2
|
+
|
3
|
+
# Should belong to Helpers::Controller?
|
4
|
+
module Doorkeeper
|
5
|
+
class ApplicationController < ActionController::Base
|
6
|
+
def resource_owner_from_assertion
|
7
|
+
instance_eval(&Doorkeeper.configuration.resource_owner_from_assertion)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
module Doorkeeper
|
13
|
+
class Server
|
14
|
+
def resource_owner_from_assertion
|
15
|
+
context.send :resource_owner_from_assertion
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
module Doorkeeper
|
21
|
+
class Config
|
22
|
+
option :resource_owner_from_assertion, default: (lambda do |routes|
|
23
|
+
warn(I18n.translate('doorkeeper.errors.messages.assertion_flow_not_configured'))
|
24
|
+
nil
|
25
|
+
end)
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Doorkeeper
|
2
|
+
module Request
|
3
|
+
class Assertion
|
4
|
+
def self.build(server)
|
5
|
+
new(server.credentials, server.resource_owner_from_assertion, server)
|
6
|
+
end
|
7
|
+
|
8
|
+
attr_accessor :credentials, :resource_owner, :server
|
9
|
+
|
10
|
+
def initialize(credentials, resource_owner, server)
|
11
|
+
@credentials = credentials
|
12
|
+
@resource_owner = resource_owner
|
13
|
+
@server = server
|
14
|
+
end
|
15
|
+
|
16
|
+
def request
|
17
|
+
@request ||= OAuth::PasswordAccessTokenRequest.new(
|
18
|
+
Doorkeeper.configuration,
|
19
|
+
credentials,
|
20
|
+
resource_owner,
|
21
|
+
server.parameters)
|
22
|
+
end
|
23
|
+
|
24
|
+
def authorize
|
25
|
+
request.authorize
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/spec/dummy/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
3
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
4
|
+
|
5
|
+
require File.expand_path('../config/application', __FILE__)
|
6
|
+
|
7
|
+
Dummy::Application.load_tasks
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class HomeController < ApplicationController
|
2
|
+
def index
|
3
|
+
end
|
4
|
+
|
5
|
+
def sign_in
|
6
|
+
session[:user_id] = if Rails.env.development?
|
7
|
+
User.first || User.create!(name: 'Joe', password: 'sekret')
|
8
|
+
else
|
9
|
+
User.first
|
10
|
+
end
|
11
|
+
redirect_to '/'
|
12
|
+
end
|
13
|
+
|
14
|
+
def callback
|
15
|
+
render text: 'ok'
|
16
|
+
end
|
17
|
+
end
|
File without changes
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'action_controller/railtie'
|
4
|
+
require 'sprockets/railtie'
|
5
|
+
|
6
|
+
Bundler.require :default
|
7
|
+
|
8
|
+
require "active_record/railtie"
|
9
|
+
|
10
|
+
module Dummy
|
11
|
+
class Application < Rails::Application
|
12
|
+
# Settings in config/environments/* take precedence over those specified here.
|
13
|
+
# Application configuration should go into files in config/initializers
|
14
|
+
# -- all .rb files in that directory are automatically loaded.
|
15
|
+
|
16
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
17
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
18
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
19
|
+
|
20
|
+
# Activate observers that should always be running.
|
21
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
22
|
+
|
23
|
+
if defined?(ActiveRecord) && Rails.version.to_i < 4
|
24
|
+
config.active_record.whitelist_attributes = true
|
25
|
+
end
|
26
|
+
|
27
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
28
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
29
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
30
|
+
|
31
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
32
|
+
config.i18n.load_path += Dir[Rails.root.join('../../', 'config/locales', '*.{rb,yml}').to_s]
|
33
|
+
# config.i18n.default_locale = :en
|
34
|
+
|
35
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
36
|
+
config.encoding = 'utf-8'
|
37
|
+
|
38
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
39
|
+
config.filter_parameters += [:password]
|
40
|
+
|
41
|
+
# Enable the asset pipeline
|
42
|
+
config.assets.enabled = true
|
43
|
+
|
44
|
+
# Version of your assets, change this if you want to expire all your assets
|
45
|
+
config.assets.version = '1.0'
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,29 @@
|
|
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
|
+
# Show full error reports and disable caching
|
10
|
+
config.consider_all_requests_local = true
|
11
|
+
config.action_controller.perform_caching = false
|
12
|
+
|
13
|
+
# Don't care if the mailer can't send
|
14
|
+
# config.action_mailer.raise_delivery_errors = false
|
15
|
+
|
16
|
+
# Print deprecation notices to the Rails logger
|
17
|
+
config.active_support.deprecation = :log
|
18
|
+
|
19
|
+
# Only use best-standards-support built into browsers
|
20
|
+
config.action_dispatch.best_standards_support = :builtin
|
21
|
+
|
22
|
+
# Do not compress assets
|
23
|
+
config.assets.compress = false
|
24
|
+
|
25
|
+
# Expands the lines which load the assets
|
26
|
+
config.assets.debug = true
|
27
|
+
|
28
|
+
config.eager_load = false
|
29
|
+
end
|
@@ -0,0 +1,62 @@
|
|
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
|
+
config.serve_static_assets = false
|
13
|
+
|
14
|
+
# Compress JavaScripts and CSS
|
15
|
+
config.assets.compress = true
|
16
|
+
|
17
|
+
# Don't fallback to assets pipeline if a precompiled asset is missed
|
18
|
+
config.assets.compile = false
|
19
|
+
|
20
|
+
# Generate digests for assets URLs
|
21
|
+
config.assets.digest = true
|
22
|
+
|
23
|
+
# Defaults to Rails.root.join("public/assets")
|
24
|
+
# config.assets.manifest = YOUR_PATH
|
25
|
+
|
26
|
+
# Specifies the header that your server uses for sending files
|
27
|
+
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
|
28
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
|
29
|
+
|
30
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
31
|
+
# config.force_ssl = true
|
32
|
+
|
33
|
+
# See everything in the log (default is :info)
|
34
|
+
# config.log_level = :debug
|
35
|
+
|
36
|
+
# Use a different logger for distributed setups
|
37
|
+
# config.logger = SyslogLogger.new
|
38
|
+
|
39
|
+
# Use a different cache store in production
|
40
|
+
# config.cache_store = :mem_cache_store
|
41
|
+
|
42
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server
|
43
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
44
|
+
|
45
|
+
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
|
46
|
+
# config.assets.precompile += %w( search.js )
|
47
|
+
|
48
|
+
# Disable delivery errors, bad email addresses will be ignored
|
49
|
+
# config.action_mailer.raise_delivery_errors = false
|
50
|
+
|
51
|
+
# Enable threaded mode
|
52
|
+
# config.threadsafe!
|
53
|
+
|
54
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
55
|
+
# the I18n.default_locale when a translation can not be found)
|
56
|
+
config.i18n.fallbacks = true
|
57
|
+
|
58
|
+
# Send deprecation notices to registered listeners
|
59
|
+
config.active_support.deprecation = :notify
|
60
|
+
|
61
|
+
config.eager_load = true
|
62
|
+
end
|