doorkeeper-logout_redirect 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e09d33940016de81c291541fab84ee4dc3591d1c
4
+ data.tar.gz: 2d8f86dd8072c47843a5ad94efb4fdfcc4d9dec9
5
+ SHA512:
6
+ metadata.gz: a70c1a41213b309685d2ac79d2a111b8f05419ce15a7e222ce88cd01deafcd6e85a5ae4fdeec79a7ffc50d8c5f77850648561de9cb492258feaf5f34f7ed0846
7
+ data.tar.gz: 7047bd7f1aa4c00ae43a3a6be1613fcddfad6ba70e9f4a44b991c95e15866b49254dbbbdfe164ccaa9315126c553060a5b3a30b61dc405e6c67e75b4eb83719d
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ vendor
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --require spec_helper
3
+ --format documentation
@@ -0,0 +1 @@
1
+ 2.0.0-p0
@@ -0,0 +1,4 @@
1
+ SimpleCov.start do
2
+ SimpleCov.minimum_coverage 100.0
3
+ add_filter "/vendor"
4
+ end
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in doorkeeper-logout_redirect.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Michael van den Beuken
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,39 @@
1
+ # Doorkeeper::LogoutRedirect
2
+
3
+ Some OAuth providers may not want to keep a user persistently logged in to their provider app
4
+ when a user is logging in to an authorized consumer application.
5
+
6
+
7
+ This gem allows an application using Doorkeeper to log users out before redirecting after a successful
8
+ authentication, if the login was on behalf of a registered OAuth application.
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ gem 'doorkeeper-logout_redirect'
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install doorkeeper-logout_redirect
23
+
24
+ ## Usage
25
+
26
+ In your app, add the following to config/application.rb:
27
+
28
+ config.to_prepare do
29
+ Doorkeeper::AuthorizationsController.send(:include, Doorkeeper::LogoutRedirect)
30
+ end
31
+
32
+ ## Contributing
33
+
34
+ 1. Fork it
35
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
36
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
37
+ 4. Run bundle exec rake and ensure that tests pass
38
+ 5. Push to the branch (`git push origin my-new-feature`)
39
+ 6. Create new Pull Request
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ desc "Run all tests"
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task default: :spec
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'doorkeeper/logout_redirect/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "doorkeeper-logout_redirect"
8
+ spec.version = Doorkeeper::LogoutRedirect::VERSION
9
+ spec.authors = ["Michael van den Beuken"]
10
+ spec.email = ["michael.beuken@ama.ab.ca"]
11
+ spec.description = %q{Logout before redirecting to authorized applications}
12
+ spec.summary = %q{Logout before redirection to OAuth consumer applications}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "doorkeeper", ">= 0.7.2"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "pry"
26
+ spec.add_development_dependency "rspec"
27
+ spec.add_development_dependency "simplecov"
28
+ end
@@ -0,0 +1,18 @@
1
+ require "doorkeeper/logout_redirect/version"
2
+
3
+ module Doorkeeper
4
+ module LogoutRedirect
5
+ def redirect_to(options = {}, response_status = {})
6
+ logout if matches_application_redirect_uri?(options)
7
+ super
8
+ end
9
+
10
+ private
11
+ def matches_application_redirect_uri?(redirect_uri)
12
+ Doorkeeper::Application.pluck(:redirect_uri).each do |uri|
13
+ return true if (redirect_uri =~ /^#{Regexp.escape(uri)}/) == 0
14
+ end
15
+ return false
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,5 @@
1
+ module Doorkeeper
2
+ module LogoutRedirect
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,57 @@
1
+ describe Doorkeeper::LogoutRedirect do
2
+
3
+ class ApplicationController
4
+ def redirect_to(options = {}, response_status = {})
5
+ puts "--> redirecting to #{options}"
6
+ end
7
+ end
8
+
9
+ class AuthorizationsController < ApplicationController
10
+ attr_accessor :redirect_uri
11
+
12
+ def initialize(attributes = {})
13
+ self.redirect_uri = attributes[:redirect_uri]
14
+ end
15
+
16
+ def authorize
17
+ redirect_to redirect_uri
18
+ end
19
+ end
20
+
21
+ class Doorkeeper::Application
22
+ def self.pluck(key = nil)
23
+ ['https://testapplication.com/test/endpoint', 'https://testapplication2.com/test/endpoint2']
24
+ end
25
+ end
26
+
27
+ before(:each) do
28
+ AuthorizationsController.send(:include, subject)
29
+ end
30
+
31
+ context 'a login request for an oauth application' do
32
+ let(:auth_controller) { AuthorizationsController.new(redirect_uri: Doorkeeper::Application.pluck.first) }
33
+
34
+ it 'logs out before redirecting to the oauth application' do
35
+ expect(auth_controller).to receive(:logout)
36
+ auth_controller.authorize
37
+ end
38
+ end
39
+
40
+ context 'a login request for another oauth application' do
41
+ let(:auth_controller) { AuthorizationsController.new(redirect_uri: Doorkeeper::Application.pluck.last) }
42
+
43
+ it 'logs out before redirecting to the oauth application' do
44
+ expect(auth_controller).to receive(:logout)
45
+ auth_controller.authorize
46
+ end
47
+ end
48
+
49
+ context 'a login request for a non-oauth application' do
50
+ let(:auth_controller) { AuthorizationsController.new(redirect_uri: 'https://notatestapp.com/test/endpoint') }
51
+
52
+ it 'does not log out before redirecting' do
53
+ expect(ApplicationController.any_instance).to_not receive(:logout)
54
+ auth_controller.authorize
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,5 @@
1
+ require "simplecov"
2
+ require "doorkeeper/logout_redirect"
3
+ require "pry"
4
+
5
+ ENV["RAILS_ENV"] ||= "test"
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: doorkeeper-logout_redirect
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Michael van den Beuken
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: doorkeeper
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.7.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.7.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Logout before redirecting to authorized applications
98
+ email:
99
+ - michael.beuken@ama.ab.ca
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - .gitignore
105
+ - .rspec
106
+ - .ruby-version
107
+ - .simplecov
108
+ - Gemfile
109
+ - LICENSE.txt
110
+ - README.md
111
+ - Rakefile
112
+ - doorkeeper-logout_redirect.gemspec
113
+ - lib/doorkeeper/logout_redirect.rb
114
+ - lib/doorkeeper/logout_redirect/version.rb
115
+ - spec/doorkeeper/logout_redirect_spec.rb
116
+ - spec/spec_helper.rb
117
+ homepage: ''
118
+ licenses:
119
+ - MIT
120
+ metadata: {}
121
+ post_install_message:
122
+ rdoc_options: []
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - '>='
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - '>='
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ requirements: []
136
+ rubyforge_project:
137
+ rubygems_version: 2.0.0
138
+ signing_key:
139
+ specification_version: 4
140
+ summary: Logout before redirection to OAuth consumer applications
141
+ test_files:
142
+ - spec/doorkeeper/logout_redirect_spec.rb
143
+ - spec/spec_helper.rb