omniauth-trello 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +49 -0
- data/Rakefile +1 -0
- data/lib/omniauth-trello.rb +2 -0
- data/lib/omniauth-trello/version.rb +5 -0
- data/lib/omniauth/strategies/trello.rb +47 -0
- data/omniauth-trello.gemspec +23 -0
- data/spec/omniauth/strategies/trello_spec.rb +26 -0
- data/spec/spec_helper.rb +15 -0
- metadata +106 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Josh Rowley
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Omniauth::Trello
|
2
|
+
|
3
|
+
An Omniauth strategy for Trello's OAuth 1.0 authentication.
|
4
|
+
|
5
|
+
Read the [Trello API documentation](https://trello.com/docs/) for more information on obtaining an application key and secret.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'omniauth-trello'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install omniauth-trello
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
`OmniAuth::Strategies::Trello` is a Rack middleware strategy for the OmniAuth gem. Look at the [OmniAuth](https://github.com/intridea/omniauth) project page for more information on how to use OmniAuth.
|
24
|
+
|
25
|
+
###Rails Example
|
26
|
+
|
27
|
+
Place this into `config/initializers/omniauth.rb`:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
31
|
+
provider :trello, ENV['TRELLO_KEY'], ENV['TRELLO_SECRET'],
|
32
|
+
app_name: "APP_NAME"
|
33
|
+
end
|
34
|
+
```
|
35
|
+
|
36
|
+
## Known Issues
|
37
|
+
|
38
|
+
Any help with these would be appreciated:
|
39
|
+
|
40
|
+
* For some user authentications, the raw info returned from Trello has a null value for email
|
41
|
+
* The `app_name` authorization is correctly showing up at the Trello authorization page as the `name` parameter per the documentation, however Trello still displays "An Unknown Application"
|
42
|
+
|
43
|
+
## Contributing
|
44
|
+
|
45
|
+
1. Fork it
|
46
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
47
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
48
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
49
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'omniauth-oauth'
|
2
|
+
require 'multi_json'
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
class Trello < OmniAuth::Strategies::OAuth
|
7
|
+
option :name, "trello"
|
8
|
+
option :client_options, { :site => "https://trello.com",
|
9
|
+
:request_token_path => "/1/OAuthGetRequestToken",
|
10
|
+
:access_token_path => "/1/OAuthGetAccessToken",
|
11
|
+
:authorize_path => "/1/OAuthAuthorizeToken" }
|
12
|
+
|
13
|
+
uid do
|
14
|
+
raw_info['id']
|
15
|
+
end
|
16
|
+
|
17
|
+
info do
|
18
|
+
{
|
19
|
+
:name => raw_info['fullName'],
|
20
|
+
:email => raw_info['email'],
|
21
|
+
:nickname => raw_info['username'],
|
22
|
+
:urls => {
|
23
|
+
:profile => raw_info['url']
|
24
|
+
}
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
extra do
|
30
|
+
{
|
31
|
+
'raw_info' => raw_info
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
def request_phase
|
36
|
+
options[:authorize_params] = {
|
37
|
+
:name => options['app_name']
|
38
|
+
}
|
39
|
+
super
|
40
|
+
end
|
41
|
+
|
42
|
+
def raw_info
|
43
|
+
@raw_info ||= MultiJson.decode(access_token.get('/1/members/me').body)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'omniauth-trello/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "omniauth-trello"
|
8
|
+
gem.version = Omniauth::Trello::VERSION
|
9
|
+
gem.authors = ["Josh Rowley"]
|
10
|
+
gem.email = ["joshua.f.rowley@gmail.com"]
|
11
|
+
gem.description = %q{OAuth 1.0 Strategy for Trello}
|
12
|
+
gem.summary = %q{OAuth 1.0 Strategy for Trello}
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.add_runtime_dependency 'omniauth'
|
16
|
+
gem.add_runtime_dependency 'omniauth-oauth'
|
17
|
+
gem.add_runtime_dependency 'oauth'
|
18
|
+
|
19
|
+
gem.files = `git ls-files`.split($/)
|
20
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
21
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
22
|
+
gem.require_paths = ["lib"]
|
23
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative '../../../lib/omniauth/strategies/trello'
|
3
|
+
|
4
|
+
describe OmniAuth::Strategies::Trello do
|
5
|
+
subject do
|
6
|
+
OmniAuth::Strategies::Trello.new({})
|
7
|
+
end
|
8
|
+
|
9
|
+
context "client options" do
|
10
|
+
it "should have correct site" do
|
11
|
+
subject.options.client_options.site.should eq("https://trello.com")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should have correct authorize path" do
|
15
|
+
subject.options.client_options.authorize_path.should eq("/1/OAuthAuthorizeToken")
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should have the correct request token path" do
|
19
|
+
subject.options.client_options.request_token_path.should eq("/1/OAuthGetRequestToken")
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should have the correct access token path" do
|
23
|
+
subject.options.client_options.access_token_path.should eq("/1/OAuthGetAccessToken")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
$:.unshift File.expand_path('..', __FILE__)
|
2
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
3
|
+
require 'simplecov'
|
4
|
+
SimpleCov.start
|
5
|
+
require 'rspec'
|
6
|
+
require 'rack/test'
|
7
|
+
require 'webmock/rspec'
|
8
|
+
require 'omniauth'
|
9
|
+
require 'omniauth-trello'
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.include WebMock::API
|
13
|
+
config.include Rack::Test::Methods
|
14
|
+
config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-trello
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Josh Rowley
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-01-09 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: omniauth
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: omniauth-oauth
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: oauth
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
description: OAuth 1.0 Strategy for Trello
|
63
|
+
email:
|
64
|
+
- joshua.f.rowley@gmail.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- Gemfile
|
71
|
+
- LICENSE.txt
|
72
|
+
- README.md
|
73
|
+
- Rakefile
|
74
|
+
- lib/omniauth-trello.rb
|
75
|
+
- lib/omniauth-trello/version.rb
|
76
|
+
- lib/omniauth/strategies/trello.rb
|
77
|
+
- omniauth-trello.gemspec
|
78
|
+
- spec/omniauth/strategies/trello_spec.rb
|
79
|
+
- spec/spec_helper.rb
|
80
|
+
homepage: ''
|
81
|
+
licenses: []
|
82
|
+
post_install_message:
|
83
|
+
rdoc_options: []
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
88
|
+
requirements:
|
89
|
+
- - ! '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
94
|
+
requirements:
|
95
|
+
- - ! '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
requirements: []
|
99
|
+
rubyforge_project:
|
100
|
+
rubygems_version: 1.8.24
|
101
|
+
signing_key:
|
102
|
+
specification_version: 3
|
103
|
+
summary: OAuth 1.0 Strategy for Trello
|
104
|
+
test_files:
|
105
|
+
- spec/omniauth/strategies/trello_spec.rb
|
106
|
+
- spec/spec_helper.rb
|