omniauth-flowdock 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dcdce5ae5ea73899c2933fef64613f98195d8d09
4
+ data.tar.gz: d1b9810190b40317ed5be4b8e11b386c213863ce
5
+ SHA512:
6
+ metadata.gz: 882333535dc370287e5015fb67af7b42158d0efb68edc0e62d02f1f14e61968a02d28a82273a3311ce81999c137cd023564ff71f0e08399d085ae0f479b8233f
7
+ data.tar.gz: aacc831d8caf2426d741ef90682c5dfae1ae33092f36a83bbd4005399ee925cdbe0e9f83700271038c2d53e8d21473e9cfbd1db0cd6eba5d7878ec4d5d6b7777
@@ -0,0 +1,17 @@
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
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-flowdock.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Rally Software Development Corp.
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,53 @@
1
+ # OmniAuth Flowdock Strategy [![Build Status](https://travis-ci.org/flowdock/omniauth-flowdock.png)](https://travis-ci.org/flowdock/omniauth-flowdock)
2
+
3
+ Flowdock OAuth 2.0 Strategy for OmniAuth.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'omniauth-flowdock'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install omniauth-flowdock
18
+
19
+ ## Usage
20
+
21
+ You should have already installed OmniAuth into your app; if not, read the
22
+ [OmniAuth README](https://github.com/intridea/omniauth) to get started.
23
+
24
+ Then, you need to [create an Flowdock OAuth 2.0 application](https://www.flowdock.com/account/authorized_applications).
25
+ The application ID and consumer secret are needed. Ensure that your callback URL
26
+ is properly configured, e.g. `https://example.com/auth/flowdock/callback`.
27
+
28
+ Then, register the Flowdock provider. For example, your
29
+ `config/initializers/omniauth.rb` might look like following:
30
+
31
+ ```ruby
32
+ Rails.application.config.middleware.use OmniAuth::Builder do
33
+ provider :flowdock, ENV['FLOWDOCK_CLIENT_ID'], ENV['FLOWDOCK_CLIENT_SECRET']
34
+ end
35
+ ```
36
+
37
+ If you need more access than just user profile, change the scope field accordingly.
38
+ For example, to post to user's flows
39
+
40
+ ```ruby
41
+ Rails.application.config.middleware.use OmniAuth::Builder do
42
+ provider :flowdock, ENV['FLOWDOCK_CLIENT_ID'], ENV['FLOWDOCK_CLIENT_SECRET'], scope: 'flow'
43
+ end
44
+ ```
45
+
46
+
47
+ ## Contributing
48
+
49
+ 1. Fork it
50
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
51
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
52
+ 4. Push to the branch (`git push origin my-new-feature`)
53
+ 5. Create new Pull Request
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ desc "Run specs"
5
+ RSpec::Core::RakeTask.new
6
+
7
+ desc 'Default: run specs.'
8
+ task default: :spec
@@ -0,0 +1 @@
1
+ require 'omniauth/flowdock'
@@ -0,0 +1,8 @@
1
+ require "omniauth/flowdock/version"
2
+ require "omniauth/strategies/flowdock"
3
+
4
+ module Omniauth
5
+ module Flowdock
6
+ # Your code goes here...
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Flowdock
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,30 @@
1
+ require 'omniauth/strategies/oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Flowdock < OmniAuth::Strategies::OAuth2
6
+ option :name, :flowdock
7
+
8
+ option :client_options, {
9
+ site: "https://api.flowdock.com",
10
+ authorize_url: "/oauth/authorize"
11
+ }
12
+
13
+ option :scope, 'profile'
14
+
15
+ uid { raw_info["id"].to_s }
16
+
17
+ info do
18
+ {
19
+ email: raw_info["email"],
20
+ name: raw_info["name"],
21
+ nickname: raw_info["nick"]
22
+ }
23
+ end
24
+
25
+ def raw_info
26
+ @raw_info ||= access_token.get('user').parsed
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omniauth/flowdock/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "omniauth-flowdock"
8
+ spec.version = Omniauth::Flowdock::VERSION
9
+ spec.authors = ["Ville Lautanala"]
10
+ spec.email = ["lautis@gmail.com"]
11
+ spec.summary = %q{Flowdock OAuth 2.0 Strategy for OmniAuth}
12
+ spec.description = %q{Flowdock OAuth 2.0 Strategy for OmniAuth}
13
+ spec.homepage = "https://github.com/flowdock/omniauth-flowdock"
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 "omniauth-oauth2", "~> 1.1"
22
+ spec.add_development_dependency "bundler", "~> 1.3"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "rspec", "~> 2.14"
25
+ end
@@ -0,0 +1,82 @@
1
+ require 'spec_helper'
2
+
3
+
4
+ describe OmniAuth::Strategies::Flowdock do
5
+ let(:access_token) { double('AccessToken', options: {}) }
6
+ let(:request) { double('Request', params: {}, cookies: {}, env: {}) }
7
+ let(:parsed_response) { double('ParsedResponse') }
8
+ let(:response) { double('Response', parsed: parsed_response) }
9
+
10
+ subject do
11
+ args = ['client-id', 'client-secret', {}].compact
12
+ OmniAuth::Strategies::Flowdock.new(*args).tap do |strategy|
13
+ allow(strategy).to receive(:request).and_return(request)
14
+ end
15
+ end
16
+
17
+ describe 'client options' do
18
+ it 'has correct name' do
19
+ expect(subject.options.name).to eq(:flowdock)
20
+ end
21
+
22
+ it 'has correct site' do
23
+ expect(subject.options.client_options.site).to eq('https://api.flowdock.com')
24
+ end
25
+
26
+ it 'has correct authorize url' do
27
+ expect(subject.options.client_options.authorize_url).to eq('/oauth/authorize')
28
+ end
29
+ end
30
+
31
+ describe '#uid' do
32
+ before do
33
+ allow(subject).to receive(:raw_info).and_return({'id' => 123 })
34
+ end
35
+
36
+ it "stringifies user id" do
37
+ expect(subject.uid).to eq("123")
38
+ end
39
+ end
40
+
41
+ describe '#user_info' do
42
+ before do
43
+ allow(subject).to receive(:raw_info).and_return(
44
+ {
45
+ 'name' => 'John Doe',
46
+ 'email' => 'jdoe@example.com',
47
+ 'nick' => 'John'
48
+ }
49
+ )
50
+ end
51
+
52
+ it 'has name' do
53
+ expect(subject.info[:name]).to eq('John Doe')
54
+ end
55
+
56
+ it 'has nickname' do
57
+ expect(subject.info[:nickname]).to eq('John')
58
+ end
59
+
60
+ it 'has email' do
61
+ expect(subject.info[:email]).to eq('jdoe@example.com')
62
+ end
63
+ end
64
+
65
+ context "#raw_info" do
66
+ it "requests raw info from /user" do
67
+ allow(subject).to receive(:access_token).and_return(access_token)
68
+ access_token.should_receive(:get).with('user').and_return(response)
69
+ expect(subject.raw_info).to eq(parsed_response)
70
+ end
71
+ end
72
+
73
+ describe '#authorize_params' do
74
+ before :each do
75
+ allow(subject).to receive(:session).and_return({})
76
+ end
77
+
78
+ it 'sets default scope' do
79
+ expect(subject.authorize_params['scope']).to eq('profile')
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,9 @@
1
+ require 'rspec'
2
+ require 'omniauth'
3
+ require 'omniauth-flowdock'
4
+
5
+ RSpec.configure do |config|
6
+ config.expect_with :rspec do |c|
7
+ c.syntax = :expect
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-flowdock
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ville Lautanala
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth-oauth2
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.1'
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: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.14'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '2.14'
69
+ description: Flowdock OAuth 2.0 Strategy for OmniAuth
70
+ email:
71
+ - lautis@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - .travis.yml
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - lib/omniauth-flowdock.rb
83
+ - lib/omniauth/flowdock.rb
84
+ - lib/omniauth/flowdock/version.rb
85
+ - lib/omniauth/strategies/flowdock.rb
86
+ - omniauth-flowdock.gemspec
87
+ - spec/omniauth/strategies/flowdock_spec.rb
88
+ - spec/spec_helper.rb
89
+ homepage: https://github.com/flowdock/omniauth-flowdock
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.1.11
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: Flowdock OAuth 2.0 Strategy for OmniAuth
113
+ test_files:
114
+ - spec/omniauth/strategies/flowdock_spec.rb
115
+ - spec/spec_helper.rb