omniauth-freeagent 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,19 @@
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
+ *.swp
19
+ .rvmrc
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --colour
2
+ --format=progress
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.2
5
+ - 1.9.3
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Gem dependencies in omniauth-freeagent.gemspec
4
+ gemspec
5
+
6
+ group :development, :test do
7
+ gem 'rake'
8
+ gem 'rdoc'
9
+ gem 'guard'
10
+ gem 'guard-rspec'
11
+ end
data/Guardfile ADDED
@@ -0,0 +1,5 @@
1
+ guard 'rspec', :version => 2 do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec" }
5
+ end
data/README.rdoc ADDED
@@ -0,0 +1,62 @@
1
+ = omniauth-freeagent
2
+
3
+ {<img src="https://secure.travis-ci.org/kickcode/omniauth-freeagent.png" />}[http://travis-ci.org/kickcode/omniauth-freeagent]
4
+
5
+ * http://github.com/kickcode/omniauth-freeagent
6
+
7
+ == DESCRIPTION:
8
+
9
+ OmniAuth OAuth2 strategy for FreeAgent (https://dev.freeagent.com).
10
+
11
+ == FEATURES:
12
+
13
+ Allow authentication via the FreeAgent API using OmniAuth, and if it takes your fancy, Devise too.
14
+
15
+ == SYNOPSIS:
16
+
17
+ To use with OmniAuth:
18
+
19
+ use OmniAuth::Builder do
20
+ provider "freeagent", FREEAGENT_CLIENT_ID, FREEAGENT_CLIENT_SECRET
21
+ end
22
+
23
+ And with Devise:
24
+
25
+ config.omniauth :freeagent, FREEAGENT_CLIENT_ID, FREEAGENT_CLIENT_SECRET
26
+
27
+ == REQUIREMENTS:
28
+
29
+ omniauth-freeagent depends upon omniauth, and the base strategy provided in omniauth-oauth2.
30
+
31
+ == INSTALL:
32
+
33
+ It's best to add the gem to your Gemfile, but if needed you can install it manually:
34
+
35
+ gem install omniauth-freeagent
36
+
37
+ == CONTRIBUTORS:
38
+
39
+ Elliott Draper
40
+
41
+ == LICENSE:
42
+
43
+ Copyright 2012 Elliott Draper <el@kickcode.com>
44
+
45
+ Permission is hereby granted, free of charge, to any person obtaining
46
+ a copy of this software and associated documentation files (the
47
+ "Software"), to deal in the Software without restriction, including
48
+ without limitation the rights to use, copy, modify, merge, publish,
49
+ distribute, sublicense, and/or sell copies of the Software, and to
50
+ permit persons to whom the Software is furnished to do so, subject to
51
+ the following conditions:
52
+
53
+ The above copyright notice and this permission notice shall be
54
+ included in all copies or substantial portions of the Software.
55
+
56
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
57
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
58
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
59
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
60
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
61
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
62
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require "rspec/core/rake_task"
4
+
5
+ desc 'Default: run specs.'
6
+ task :default => :spec
7
+
8
+ desc "Run specs"
9
+ RSpec::Core::RakeTask.new
@@ -0,0 +1,2 @@
1
+ require 'omniauth-freeagent/version'
2
+ require 'omniauth/strategies/freeagent'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module FreeAgent
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,40 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class FreeAgent < OmniAuth::Strategies::OAuth2
6
+ option :name, 'freeagent'
7
+
8
+ option :client_options, {
9
+ :site => 'https://api.freeagent.com',
10
+ :authorize_url => '/v2/approve_app',
11
+ :token_url => '/v2/token_endpoint'
12
+ }
13
+
14
+ uid do
15
+ raw_info['url'].split('/').last.to_i
16
+ end
17
+
18
+ info do
19
+ {
20
+ 'email' => raw_info['email'],
21
+ 'first_name' => raw_info['first_name'],
22
+ 'last_name' => raw_info['last_name'],
23
+ 'url' => raw_info['url']
24
+ }
25
+ end
26
+
27
+ extra do
28
+ {
29
+ "raw_info" => raw_info
30
+ }
31
+ end
32
+
33
+ def raw_info
34
+ @raw_info ||= access_token.get('/v2/users/me').parsed['user']
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+ OmniAuth.config.add_camelization 'freeagent', 'FreeAgent'
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/omniauth-freeagent/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.add_dependency 'omniauth', '~> 1.0'
6
+ gem.add_dependency 'omniauth-oauth2', '~> 1.0'
7
+
8
+ gem.add_development_dependency 'rspec', '~> 2.7'
9
+ gem.add_development_dependency 'rack-test'
10
+ gem.add_development_dependency 'webmock'
11
+ gem.add_development_dependency 'simplecov'
12
+
13
+ gem.authors = ["Elliott Draper"]
14
+ gem.email = ["el@kickcode.com"]
15
+ gem.description = %q{OmniAuth OAuth2 strategy for FreeAgent.}
16
+ gem.summary = %q{OmniAuth OAuth2 strategy for FreeAgent.}
17
+ gem.homepage = "http://kickcode.com/playground/omniauth-freeagent"
18
+
19
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ gem.files = `git ls-files`.split("\n")
21
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
22
+ gem.name = "omniauth-freeagent"
23
+ gem.require_paths = ["lib"]
24
+ gem.version = OmniAuth::FreeAgent::VERSION
25
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+ require 'omniauth-freeagent'
3
+
4
+ describe OmniAuth::Strategies::FreeAgent do
5
+ subject do
6
+ OmniAuth::Strategies::FreeAgent.new(nil, @options || {})
7
+ end
8
+
9
+ describe '#client' do
10
+ it 'should have the correct site' do
11
+ subject.client.site.should == 'https://api.freeagent.com'
12
+ end
13
+
14
+ it 'should have the correct auth URL' do
15
+ subject.client.options[:authorize_url].should == '/v2/approve_app'
16
+ end
17
+
18
+ it 'should have the correct token URL' do
19
+ subject.client.options[:token_url].should == '/v2/token_endpoint'
20
+ end
21
+ end
22
+
23
+ describe '#callback_path' do
24
+ it 'should have the correct callback path' do
25
+ subject.callback_path.should == '/auth/freeagent/callback'
26
+ end
27
+ end
28
+ end
@@ -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-freeagent'
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,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-freeagent
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Elliott Draper
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2012-04-26 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: omniauth
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: "1.0"
24
+ type: :runtime
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: omniauth-oauth2
28
+ prerelease: false
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: "1.0"
35
+ type: :runtime
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
38
+ name: rspec
39
+ prerelease: false
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: "2.7"
46
+ type: :development
47
+ version_requirements: *id003
48
+ - !ruby/object:Gem::Dependency
49
+ name: rack-test
50
+ prerelease: false
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
57
+ type: :development
58
+ version_requirements: *id004
59
+ - !ruby/object:Gem::Dependency
60
+ name: webmock
61
+ prerelease: false
62
+ requirement: &id005 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: "0"
68
+ type: :development
69
+ version_requirements: *id005
70
+ - !ruby/object:Gem::Dependency
71
+ name: simplecov
72
+ prerelease: false
73
+ requirement: &id006 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: "0"
79
+ type: :development
80
+ version_requirements: *id006
81
+ description: OmniAuth OAuth2 strategy for FreeAgent.
82
+ email:
83
+ - el@kickcode.com
84
+ executables: []
85
+
86
+ extensions: []
87
+
88
+ extra_rdoc_files: []
89
+
90
+ files:
91
+ - .gitignore
92
+ - .rspec
93
+ - .travis.yml
94
+ - Gemfile
95
+ - Guardfile
96
+ - README.rdoc
97
+ - Rakefile
98
+ - lib/omniauth-freeagent.rb
99
+ - lib/omniauth-freeagent/version.rb
100
+ - lib/omniauth/strategies/freeagent.rb
101
+ - omniauth-freeagent.gemspec
102
+ - spec/omniauth/strategies/freeagent_spec.rb
103
+ - spec/spec_helper.rb
104
+ homepage: http://kickcode.com/playground/omniauth-freeagent
105
+ licenses: []
106
+
107
+ post_install_message:
108
+ rdoc_options: []
109
+
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: "0"
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ none: false
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: "0"
124
+ requirements: []
125
+
126
+ rubyforge_project:
127
+ rubygems_version: 1.8.21
128
+ signing_key:
129
+ specification_version: 3
130
+ summary: OmniAuth OAuth2 strategy for FreeAgent.
131
+ test_files:
132
+ - spec/omniauth/strategies/freeagent_spec.rb
133
+ - spec/spec_helper.rb