omniauth-asana 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 +11 -0
- data/LICENSE.txt +22 -0
- data/README.md +49 -0
- data/Rakefile +7 -0
- data/lib/omniauth-asana.rb +2 -0
- data/lib/omniauth-asana/version.rb +5 -0
- data/lib/omniauth/strategies/asana.rb +42 -0
- data/omniauth-asana.gemspec +22 -0
- data/spec/omniauth/strategies/asana_spec.rb +36 -0
- data/spec/spec_helper.rb +15 -0
- metadata +91 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Asana, Inc.
|
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 Asana
|
2
|
+
|
3
|
+
This is the official OmniAuth strategy for authenticating against [Asana][]. To
|
4
|
+
use it, you'll need to create an Application and copy the Client ID and Client
|
5
|
+
Secret. You can create and manage applications from the "Apps" tab of your user
|
6
|
+
settings in Asana.
|
7
|
+
|
8
|
+
> Credit: Much of this gem has been based off the [OmniAuth strategy for
|
9
|
+
Github][omniauth-github].
|
10
|
+
|
11
|
+
## Basic Usage
|
12
|
+
|
13
|
+
use OmniAuth::Builder do
|
14
|
+
provider :asana, ENV['ASANA_CLIENT_ID'], ENV['ASANA_CLIENT_SECRET']
|
15
|
+
end
|
16
|
+
|
17
|
+
## Further API usage
|
18
|
+
|
19
|
+
For more information about using the Asana API and OAuth, please refer to the
|
20
|
+
[Asana Developer Documentation][].
|
21
|
+
|
22
|
+
## MIT License
|
23
|
+
|
24
|
+
Copyright (c) 2013 Asana, Inc.
|
25
|
+
|
26
|
+
MIT License
|
27
|
+
|
28
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
29
|
+
a copy of this software and associated documentation files (the
|
30
|
+
"Software"), to deal in the Software without restriction, including
|
31
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
32
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
33
|
+
permit persons to whom the Software is furnished to do so, subject to
|
34
|
+
the following conditions:
|
35
|
+
|
36
|
+
The above copyright notice and this permission notice shall be
|
37
|
+
included in all copies or substantial portions of the Software.
|
38
|
+
|
39
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
40
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
41
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
42
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
43
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
44
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
45
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
46
|
+
|
47
|
+
[Asana]: http://asana.com/
|
48
|
+
[Asana Developer Documentation]: http://developer.asana.com/documentation/
|
49
|
+
[omniauth-github]: https://github.com/intridea/omniauth-github
|
data/Rakefile
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class Asana < OmniAuth::Strategies::OAuth2
|
6
|
+
option :client_options, {
|
7
|
+
:site => 'https://app.asana.com',
|
8
|
+
:authorize_url => 'https://app.asana.com/-/oauth_authorize',
|
9
|
+
:token_url => 'https://app.asana.com/-/oauth_token'
|
10
|
+
}
|
11
|
+
|
12
|
+
def request_phase
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
def authorize_params
|
17
|
+
super.tap do |params|
|
18
|
+
if request.params['client_options']
|
19
|
+
params[:client_options] = request.params['client_options']
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
uid { raw_info['id'].to_s }
|
25
|
+
|
26
|
+
info do
|
27
|
+
{
|
28
|
+
'name' => raw_info['name'],
|
29
|
+
'email' => raw_info['email']
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
extra do
|
34
|
+
{ :raw_info => raw_info }
|
35
|
+
end
|
36
|
+
|
37
|
+
def raw_info
|
38
|
+
@raw_info ||= access_token.params['data']
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'omniauth-asana/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "omniauth-asana"
|
8
|
+
gem.version = Omniauth::Asana::VERSION
|
9
|
+
gem.authors = ["Isaac Wolkerstorfer"]
|
10
|
+
gem.email = ["isaac@asana.com"]
|
11
|
+
gem.description = %q{Official OmniAuth strategy for Asana.}
|
12
|
+
gem.summary = %q{Official OmniAuth strategy for Asana. Based on the OmniAuth strategy for GitHub.}
|
13
|
+
gem.homepage = "https://github.com/asana/omniauth-asana"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_dependency 'omniauth', '~> 1.0'
|
21
|
+
gem.add_dependency 'omniauth-oauth2', '~> 1.1'
|
22
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OmniAuth::Strategies::Asana do
|
4
|
+
let(:access_token) { stub('AccessToken', :options => {}) }
|
5
|
+
let(:parsed_response) { stub('ParsedResponse') }
|
6
|
+
let(:response) { stub('Response', :parsed => parsed_response) }
|
7
|
+
|
8
|
+
subject do
|
9
|
+
OmniAuth::Strategies::Asana.new({})
|
10
|
+
end
|
11
|
+
|
12
|
+
before(:each) do
|
13
|
+
subject.stub!(:access_token).and_return(access_token)
|
14
|
+
end
|
15
|
+
|
16
|
+
context "client options" do
|
17
|
+
it 'should have correct site' do
|
18
|
+
subject.options.client_options.site.should eq("https://app.asana.com")
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should have correct authorize url' do
|
22
|
+
subject.options.client_options.authorize_url.should eq('https://app.asana.com/-/oauth_authorize')
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should have correct token url' do
|
26
|
+
subject.options.client_options.token_url.should eq('https://app.asana.com/-/oauth_token')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "#raw_info" do
|
31
|
+
it "should use relative paths" do
|
32
|
+
access_token.should_receive(:get).with('user').and_return(response)
|
33
|
+
subject.raw_info.should eq(parsed_response)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
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-asana'
|
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,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-asana
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Isaac Wolkerstorfer
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-03-01 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: '1.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: '1.0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: omniauth-oauth2
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '1.1'
|
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: '1.1'
|
46
|
+
description: Official OmniAuth strategy for Asana.
|
47
|
+
email:
|
48
|
+
- isaac@asana.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- .gitignore
|
54
|
+
- Gemfile
|
55
|
+
- LICENSE.txt
|
56
|
+
- README.md
|
57
|
+
- Rakefile
|
58
|
+
- lib/omniauth-asana.rb
|
59
|
+
- lib/omniauth-asana/version.rb
|
60
|
+
- lib/omniauth/strategies/asana.rb
|
61
|
+
- omniauth-asana.gemspec
|
62
|
+
- spec/omniauth/strategies/asana_spec.rb
|
63
|
+
- spec/spec_helper.rb
|
64
|
+
homepage: https://github.com/asana/omniauth-asana
|
65
|
+
licenses: []
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - ! '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
requirements: []
|
83
|
+
rubyforge_project:
|
84
|
+
rubygems_version: 1.8.23
|
85
|
+
signing_key:
|
86
|
+
specification_version: 3
|
87
|
+
summary: Official OmniAuth strategy for Asana. Based on the OmniAuth strategy for
|
88
|
+
GitHub.
|
89
|
+
test_files:
|
90
|
+
- spec/omniauth/strategies/asana_spec.rb
|
91
|
+
- spec/spec_helper.rb
|