omniauth-empireavenue 0.0.1

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.
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ .rvmrc
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format=progress
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - ree
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in omniauth-empireavenue.gemspec
4
+ gemspec
5
+
6
+ group :development, :test do
7
+ gem 'rake'
8
+ gem 'rspec'
9
+ gem 'simplecov'
10
+ end
data/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # OmniAuth EmpireAvenue
2
+
3
+
4
+ `OmniAuth::Strategies::EmpireAvenue` is an OmniAuth strategy for authenticating to
5
+ empireavenue.com with OAuth2. Read detailed information about the empireavenue.com
6
+ implementation of OAuth2
7
+ [here](https://apidocs.empireavenue.com/v1/oauth2)
8
+
9
+ ## Installing
10
+
11
+ Add to your `Gemfile`:
12
+
13
+ ```ruby
14
+ gem 'omniauth-empireavenue'
15
+ ```
16
+
17
+ Then `bundle install`.
18
+
19
+ ## Usage
20
+
21
+ To get started you will need to register an OAuth Consumer in your
22
+ empireavenue.com account
23
+ [here](http://www.empireavenue.com/profile/developer)
24
+
25
+ Here's a quick example, adding the middleware to a Rails app in
26
+ `config/initializers/omniauth.rb`:
27
+
28
+ ```ruby
29
+ Rails.application.config.middleware.use OmniAuth::Builder do
30
+ provider :empireavenue, ENV['MEETUP_KEY'], ENV['MEETUP_SECRET']
31
+ end
32
+ ```
33
+ You can then implement your authentication as usual with OmniAuth as
34
+ shown in the excellent [Railscast
35
+ 241](http://railscasts.com/episodes/241-simple-omniauth)
36
+
37
+ ##Authentication Hash
38
+
39
+ Here's an example *Authentication Hash* available in
40
+ `request.env['omniauth.auth']`:
41
+
42
+ ```ruby
43
+ ```
44
+
45
+ ## License
46
+
47
+ Copyright (c) 2011 by Ralph Janke
48
+
49
+ Permission is hereby granted, free of charge, to any person obtaining a
50
+ copy of this software and associated documentation files (the
51
+ "Software"), to deal in the Software without restriction, including
52
+ without limitation the rights to use, copy, modify, merge, publish,
53
+ distribute, sublicense, and/or sell copies of the Software, and to
54
+ permit persons to whom the Software is furnished to do so, subject to
55
+ the following conditions:
56
+
57
+ The above copyright notice and this permission notice shall be included
58
+ in all copies or substantial portions of the Software.
59
+
60
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
61
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
62
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
63
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
64
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
65
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
66
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require "rspec/core/rake_task"
4
+
5
+ RSpec::Core::RakeTask.new do |t|
6
+ end
7
+
8
+ task :default => :spec
@@ -0,0 +1,2 @@
1
+ require "omniauth-empireavenue/version"
2
+ require "omniauth/strategies/empireavenue"
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module EmpireAvenue
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,46 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class EmpireAvenue < OmniAuth::Strategies::OAuth2
6
+
7
+ # Possible scopes: noauth, profile_read, market_data_read, missions_read
8
+ DEFAULT_SCOPE = "noauth, profile_read, market_data_read, missions_read"
9
+
10
+ option :name, "empireavenue"
11
+ option :authorize_options, [:scope, :approval_prompt, :access_type, :state, :hd]
12
+
13
+ option :client_options, {
14
+ :site => "https://www.empireavenue.com",
15
+ :authorize_url => 'https://www.empireavenue.com/profile/developer/authorize',
16
+ :token_url => 'https://api.empireavenue.com/oauth/token'
17
+ }
18
+
19
+ def request_phase
20
+ super
21
+ end
22
+
23
+ uid{ raw_info['ticker'] }
24
+
25
+ info do
26
+ {
27
+ :ticker => raw_info['ticker'],
28
+ :first_name => raw_info['first_name'],
29
+ :last_name => raw_info['last_name'],
30
+ :full_name => raw_info['full_name'],
31
+ :ticker => raw_info['ticker'],
32
+ :location => [raw_info['location'], raw_info['country']].reject{|v| !v || v.empty?}.join(', ')
33
+ }
34
+ end
35
+
36
+ extra do
37
+ { 'raw_info' => raw_info }
38
+ end
39
+
40
+ def raw_info
41
+ @raw_info ||= JSON.parse(access_token.get("https://api.empireavenue.com/profile/info?access_token=#{access_token.token}&client_id=#{client_id}").body)
42
+ end
43
+
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "omniauth-empireavenue/version"
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "omniauth-empireavenue"
7
+ gem.version = Omniauth::EmpireAvenue::VERSION
8
+ gem.authors = ["Ralph Janke"]
9
+ gem.email = ["txwikinger@ubuntu.com"]
10
+ gem.homepage = "http://github.com/txwikinger/omniauth-empireavenue"
11
+ gem.description = %q{EmpireAvenue.com authentication handler for OmniAuth}
12
+ gem.summary = gem.description
13
+
14
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
15
+ gem.files = `git ls-files`.split("\n")
16
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ gem.require_paths = ["lib"]
18
+
19
+ # specify any dependencies here; for example:
20
+ gem.add_dependency 'omniauth', '~> 1.0'
21
+ gem.add_dependency 'omniauth-oauth2', '~> 1.0'
22
+ gem.add_development_dependency 'rspec', '~> 2.7'
23
+ gem.add_development_dependency 'rack-test'
24
+ gem.add_development_dependency 'simplecov'
25
+ gem.add_development_dependency 'webmock'
26
+ end
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::EmpireAvenue do
4
+ subject do
5
+ OmniAuth::Strategies::EmpireAvenue.new(nil, @options || {})
6
+ end
7
+
8
+ describe '#client' do
9
+ it 'should have the correct Empire Avenue site' do
10
+ subject.client.site.should eq("https://www.empireavenue.com")
11
+ end
12
+
13
+ it 'should have the correct authorization url' do
14
+ subject.client.options[:authorize_url].should eq("https://www.empireavenue.com/profile/developer/authorize")
15
+ end
16
+
17
+ it 'should have the correct token url' do
18
+ subject.client.options[:token_url].should eq('https://api.empireavenue.com/oauth/token')
19
+ end
20
+ end
21
+
22
+ describe '#callback_path' do
23
+ it 'should have the correct callback path' do
24
+ subject.callback_path.should eq('/auth/empireavenue/callback')
25
+ end
26
+ end
27
+
28
+ describe '#uid' do
29
+ it 'returns the uid from raw_info' do
30
+ subject.stub(:raw_info) { { 'ticker' => 'txwikinger' } }
31
+ subject.uid.should == 'txwikinger'
32
+ end
33
+ end
34
+
35
+ describe '#first_name' do
36
+ it 'returns the name from raw_info' do
37
+ subject.stub(:raw_info) { { 'first_name' => 'Bert' }}
38
+ subject.info[:first_name].should == 'Bert'
39
+ end
40
+
41
+ it 'returns the last_name from raw_info' do
42
+ subject.stub(:raw_info) { { 'last_name' => 'Vogts' }}
43
+ subject.info[:last_name].should == 'Vogts'
44
+ end
45
+
46
+ it 'returns the full name from raw_info' do
47
+ subject.stub(:raw_info) { { 'full_name' => 'Berti Vogts' }}
48
+ subject.info[:full_name].should == 'Berti Vogts'
49
+ end
50
+
51
+ end
52
+ end
@@ -0,0 +1,13 @@
1
+ Dir[File.expand_path('../support/**/*', __FILE__)].each { |f| require f }
2
+ require 'bundler/setup'
3
+ require 'rspec'
4
+ require 'rack/test'
5
+ require 'webmock/rspec'
6
+ require 'omniauth'
7
+ require 'omniauth-empireavenue'
8
+
9
+ RSpec.configure do |config|
10
+ config.include WebMock::API
11
+ config.include Rack::Test::Methods
12
+ config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
13
+ end
metadata ADDED
@@ -0,0 +1,154 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-empireavenue
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Ralph Janke
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-03 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.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: '1.0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '2.7'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.7'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rack-test
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: simplecov
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: webmock
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ description: EmpireAvenue.com authentication handler for OmniAuth
111
+ email:
112
+ - txwikinger@ubuntu.com
113
+ executables: []
114
+ extensions: []
115
+ extra_rdoc_files: []
116
+ files:
117
+ - .gitignore
118
+ - .rspec
119
+ - .travis.yml
120
+ - Gemfile
121
+ - README.md
122
+ - Rakefile
123
+ - lib/omniauth-empireavenue.rb
124
+ - lib/omniauth-empireavenue/version.rb
125
+ - lib/omniauth/strategies/empireavenue.rb
126
+ - omniauth-empireavenue.gemspec
127
+ - spec/omniauth/strategies/.empireavenue_spec.rb.swp
128
+ - spec/omniauth/strategies/empireavenue_spec.rb
129
+ - spec/spec_helper.rb
130
+ homepage: http://github.com/txwikinger/omniauth-empireavenue
131
+ licenses: []
132
+ post_install_message:
133
+ rdoc_options: []
134
+ require_paths:
135
+ - lib
136
+ required_ruby_version: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ required_rubygems_version: !ruby/object:Gem::Requirement
143
+ none: false
144
+ requirements:
145
+ - - ! '>='
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ requirements: []
149
+ rubyforge_project:
150
+ rubygems_version: 1.8.24
151
+ signing_key:
152
+ specification_version: 3
153
+ summary: EmpireAvenue.com authentication handler for OmniAuth
154
+ test_files: []