omniauth-nuwe 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3a8715c8bdc1cb19f8d592f72ad42c1bf9ef2d55
4
+ data.tar.gz: 377c0b223e155f219a95abb3ea2fa9394fdf5ee5
5
+ SHA512:
6
+ metadata.gz: ffc69d283d8c82343ddc0b935b2f5c97c1d019591aa77d30da22f8cb2fc85f21e32f65c9c81c7c9e6c31e1b190dafd5f09815f2a42d7ab72aeead2e49c305204
7
+ data.tar.gz: f0b62bc10fd1ab306b99c640a7adfb8dc1adf277373173939207562d40f1de7ad9e564c9dcf7958457d36142f75e2cac95fee5f4c17f8578fe44a150544951bb
data/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ .DS_Store
16
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-nuwe.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Stephanie Nemeth
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,34 @@
1
+
2
+ ![build status](https://codeship.com/projects/90ad4cf0-c028-0132-c8c4-12477713df02/status?branch=master)
3
+
4
+ # OmniAuth Nuwe
5
+
6
+ This gem contains the Nuwe strategy for OmniAuth.
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'omniauth-nuwe'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install omniauth-nuwe
23
+
24
+ ## Usage
25
+
26
+ TODO: Write usage instructions here
27
+
28
+ ## Contributing
29
+
30
+ 1. Fork it ( https://github.com/[my-github-username]/omniauth-nuwe/fork )
31
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
32
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
33
+ 4. Push to the branch (`git push origin my-new-feature`)
34
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new('spec')
5
+
6
+ task :default => :spec
@@ -0,0 +1,36 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Nuwe < OmniAuth::Strategies::OAuth2
6
+
7
+ option :name, "nuwe"
8
+
9
+ # do we need the access_token and request_token paths here as well?
10
+ option :client_options, {
11
+ :site => "https://api.nuwe.co",
12
+ :authorize_url => "https://api.nuapi.co/oauth/authorize"
13
+ }
14
+
15
+ uid { raw_info["user"]["id"] }
16
+
17
+ # need to decide which user info we want to pass to client initially
18
+ info do
19
+ {
20
+ :last_name => raw_info["profile"]["last_name"],
21
+ :first_name => raw_info["profile"]["first_name"],
22
+ :email => raw_info["user"]["email"],
23
+ :sex => raw_info["profile"]["sex"],
24
+ :birth_date => raw_info["profile"]["birth_date"],
25
+ :activity => raw_info["profile"]["activity"]
26
+
27
+ }
28
+ end
29
+
30
+ # not sure about this. Are getting the raw info from the user's profile?
31
+ def raw_info
32
+ @raw_info ||= access_token.get('/v3/profile.json').body
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Nuwe
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require 'omniauth-nuwe/version'
2
+ require 'omniauth/strategies/nuwe'
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ require File.expand_path('../lib/omniauth-nuwe/version', __FILE__)
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = "omniauth-nuwe"
6
+ spec.version = Omniauth::Nuwe::VERSION
7
+ spec.authors = ["Stephanie Nemeth"]
8
+ spec.email = ["stephanie@spacebabies.nl"]
9
+ spec.summary = %q{OmniAuth strategy for Nuwe.}
10
+ spec.description = %q{OmniAuth strategy for Nuwe.}
11
+ spec.homepage = ""
12
+ spec.license = "MIT"
13
+
14
+ spec.files = `git ls-files`.split("\n")
15
+ spec.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
16
+ spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ spec.require_paths = ["lib"]
18
+
19
+
20
+ spec.add_dependency 'omniauth', '~> 1.0'
21
+ # Nothing lower than omniauth-oauth2 1.1.1
22
+ # http://www.rubysec.com/advisories/CVE-2012-6134/
23
+ spec.add_dependency 'omniauth-oauth2', '>= 1.1.1', '< 2.0'
24
+ spec.add_development_dependency 'rspec', '3.2.0'
25
+ spec.add_development_dependency "bundler", "~> 1.7"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ end
@@ -0,0 +1,73 @@
1
+ require 'spec_helper'
2
+
3
+ describe "OmniAuth::Strategies::Nuwe" do
4
+ subject do
5
+ OmniAuth::Strategies::Nuwe.new(nil, @options || {})
6
+ end
7
+
8
+ context 'client options' do
9
+ it 'has the correct name' do
10
+ expect(subject.options.name).to eq('nuwe')
11
+ end
12
+
13
+ it 'has correct OAuth endpoint' do
14
+ expect(subject.options.client_options.site).to eq('https://api.nuwe.co')
15
+ end
16
+
17
+ it 'has correct authorize url' do
18
+ expect(subject.options.client_options.authorize_url).to eq('https://api.nuapi.co/oauth/authorize')
19
+ end
20
+ end
21
+
22
+ context 'uid' do
23
+ before :each do
24
+ @raw_info = { 'user' => { 'id' => 123} }
25
+ allow(subject).to receive_messages(:raw_info => @raw_info)
26
+ end
27
+
28
+ it 'returns the correct id from raw_info' do
29
+ expect(subject.uid).to eq(123)
30
+ end
31
+ end
32
+
33
+ describe '#info' do
34
+ before :each do
35
+ @raw_info = { 'user' => { 'id' => 123,
36
+ 'email' => 'fred@example.com'},
37
+ 'profile' => {
38
+ 'first_name' => 'Fred',
39
+ 'last_name' => 'Smith',
40
+ 'sex' => 'F',
41
+ 'birth_date' => '1981-08-01',
42
+ 'activity' => 2 }
43
+ }
44
+ allow(subject).to receive_messages(:raw_info => @raw_info)
45
+ end
46
+
47
+ context 'when data is present in raw info' do
48
+ it 'returns the first name' do
49
+ expect(subject.info[:first_name]).to eq('Fred')
50
+ end
51
+
52
+ it 'returns the last name' do
53
+ expect(subject.info[:last_name]).to eq('Smith')
54
+ end
55
+
56
+ it 'returns the email' do
57
+ expect(subject.info[:email]).to eq('fred@example.com')
58
+ end
59
+
60
+ it 'returns the sex' do
61
+ expect(subject.info[:sex]).to eq('F')
62
+ end
63
+
64
+ it 'returns the birthdate' do
65
+ expect(subject.info[:birth_date]).to eq('1981-08-01')
66
+ end
67
+
68
+ it 'returns the activity' do
69
+ expect(subject.info[:activity]).to eq(2)
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,6 @@
1
+ require 'bundler/setup'
2
+ require 'rspec'
3
+ require 'omniauth-nuwe'
4
+
5
+ RSpec.configure do |config|
6
+ end
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-nuwe
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Stephanie Nemeth
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: omniauth-oauth2
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.1.1
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '2.0'
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 1.1.1
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '2.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - '='
52
+ - !ruby/object:Gem::Version
53
+ version: 3.2.0
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - '='
59
+ - !ruby/object:Gem::Version
60
+ version: 3.2.0
61
+ - !ruby/object:Gem::Dependency
62
+ name: bundler
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '1.7'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '1.7'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rake
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '10.0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '10.0'
89
+ description: OmniAuth strategy for Nuwe.
90
+ email:
91
+ - stephanie@spacebabies.nl
92
+ executables: []
93
+ extensions: []
94
+ extra_rdoc_files: []
95
+ files:
96
+ - ".gitignore"
97
+ - Gemfile
98
+ - LICENSE.txt
99
+ - README.md
100
+ - Rakefile
101
+ - lib/omniauth-nuwe.rb
102
+ - lib/omniauth-nuwe/version.rb
103
+ - lib/omniauth/strategies/nuwe.rb
104
+ - omniauth-nuwe.gemspec
105
+ - spec/omniauth/strategies/nuwe_spec.rb
106
+ - spec/spec_helper.rb
107
+ homepage: ''
108
+ licenses:
109
+ - MIT
110
+ metadata: {}
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 2.4.4
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: OmniAuth strategy for Nuwe.
131
+ test_files:
132
+ - spec/omniauth/strategies/nuwe_spec.rb
133
+ - spec/spec_helper.rb