warden-doorkeeper 0.1.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/LICENSE +20 -0
- data/README.md +34 -0
- data/lib/warden/strategies/doorkeeper.rb +37 -0
- metadata +60 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 21e48453c9904fbdef7a324cf1d422a3e41b1452
|
4
|
+
data.tar.gz: 86d39618c5e05034a4895d35a9a0ff96b54a6a69
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b353ff2fd05392fca43b333e7e8c7592b5f455816be561d8bc09db862a50f630cbcb5b0b59448e853a7452200ca88101a67ea9e696f8d92c7ab85bad0df85e01
|
7
|
+
data.tar.gz: c35cc0a1d9a95ef32c2c98361815a5cd5ce0f6f6bf3c4d7cc83f280b8df4c483b99de6d18e076a32d4fef2bd16bbfb55bbf7ff410bf3685c141c035b191ff170
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2014 Tyler Margison
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# Warden Doorkeeper Strategy
|
2
|
+
|
3
|
+
## Introduction
|
4
|
+
|
5
|
+
This is an authentication strategy for
|
6
|
+
[Warden](https://github.com/hassox/warden) that integrates with
|
7
|
+
[Doorkeeper](https://github.com/doorkeeper-gem/doorkeeper).
|
8
|
+
|
9
|
+
Doorkeeper does not natively play well with Warden and Devise. The goal of this
|
10
|
+
gem is to provide better support for those running Doorkeeper alongside
|
11
|
+
Devise/Warden. Instead of protecting controllers using `doorkeeper_authorize!`
|
12
|
+
you may use your Devise and Warden protection methods,
|
13
|
+
e.g. `authenitcate_user!`, to achieve the same effect but have your usual
|
14
|
+
bindings work, e.g. `current_user`.
|
15
|
+
|
16
|
+
## Setup
|
17
|
+
|
18
|
+
Pretty easy if you use bundler:
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
gem "warden-doorkeeper"
|
22
|
+
```
|
23
|
+
|
24
|
+
Or if you use RubyGems:
|
25
|
+
|
26
|
+
gem install warden-doorkeeper
|
27
|
+
|
28
|
+
Then `require "warden/strategies/doorkeeper"` in your project code (or your
|
29
|
+
Gemfile) and add it to the Warden strategies collection as such:
|
30
|
+
|
31
|
+
Warden::Strategies.add(:doorkeeper, Warden::Strategies::Doorkeeper)
|
32
|
+
|
33
|
+
Now you may authenticate using the strategy name `:doorkeeper`, but you can
|
34
|
+
change that part to whatever you'd like.
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "warden"
|
2
|
+
|
3
|
+
class Warden::Strategies::Doorkeeper < ::Warden::Strategies::Base
|
4
|
+
VERSION = "0.1.0"
|
5
|
+
|
6
|
+
attr_reader :token, :scope
|
7
|
+
|
8
|
+
def initialize(env, scope=nil)
|
9
|
+
super
|
10
|
+
|
11
|
+
@token = OAuth::Token.authenticate request, *Doorkeeper.configuration.access_token_methods
|
12
|
+
@scope = scope
|
13
|
+
end
|
14
|
+
|
15
|
+
def valid?
|
16
|
+
@token && @token.accessible? && @token.acceptable?(@scope)
|
17
|
+
end
|
18
|
+
|
19
|
+
def authenticate!
|
20
|
+
user = User.where(id: @token.resource_owner_id).first
|
21
|
+
if user
|
22
|
+
success!(user)
|
23
|
+
else
|
24
|
+
fail!("No such user")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Returns the configuration data for the default user scope.
|
29
|
+
def config
|
30
|
+
scopes = env["warden"].config[:scope_defaults]
|
31
|
+
if scopes && scopes[:user]
|
32
|
+
scopes[:user][:config]
|
33
|
+
else
|
34
|
+
{}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: warden-doorkeeper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tyler Margison
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: warden
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.2'
|
27
|
+
description: Integration with Doorkeeper.
|
28
|
+
email: kolorahl@gmail.com
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- LICENSE
|
34
|
+
- README.md
|
35
|
+
- lib/warden/strategies/doorkeeper.rb
|
36
|
+
homepage: https://github.com/kolorahl/warden-doorkeeper
|
37
|
+
licenses: []
|
38
|
+
metadata: {}
|
39
|
+
post_install_message:
|
40
|
+
rdoc_options: []
|
41
|
+
require_paths:
|
42
|
+
- lib
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
requirements: []
|
54
|
+
rubyforge_project:
|
55
|
+
rubygems_version: 2.3.0
|
56
|
+
signing_key:
|
57
|
+
specification_version: 4
|
58
|
+
summary: Integration with Doorkeeper.
|
59
|
+
test_files: []
|
60
|
+
has_rdoc:
|