omniauth-23andme 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c1ca1240081f37827e2024dbf9be0e3fa9e78f2f
4
+ data.tar.gz: 14ca75f09858e7b9bd6512de471f0731c5da462a
5
+ SHA512:
6
+ metadata.gz: e2fbe722f9bdb60f129f84ac90d3460de2a73348262a819f7451a4de34887c33d862c90948a71405694f5e45ca14658987cc48fb0df80c6a784c31dbf225399d
7
+ data.tar.gz: 52f8f360141a3baa9f161a268e1a01542959bd83dc5d20908ac056c0b982af97554dbf4eeefc380b97efaa8ff6299cc49d02d2b75804b3f44b26a00acc8c0b9f
@@ -0,0 +1,6 @@
1
+ .DS_Store
2
+ *.gem
3
+ .bundle
4
+ Gemfile.lock
5
+ /pkg
6
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-23andme.gemspec
4
+ gemspec
@@ -0,0 +1,43 @@
1
+ # OmniAuth 23AndMe
2
+
3
+ Unofficial OmniAuth strategy for [23andMe](https://www.23andme.com/).
4
+
5
+ ## Usage
6
+
7
+ In your initializer:
8
+
9
+ ```ruby
10
+ Rails.application.config.middleware.use OmniAuth::Builder do
11
+ provider :twenty_three_and_me, {
12
+ ENV['23ANDME_KEY'],
13
+ ENV['23ANDME_SECRET'],
14
+ scope: 'basic genomes'
15
+ }
16
+ end
17
+ ```
18
+
19
+ Or, if you're using Devise, in your `Devise.setup`:
20
+
21
+ ```ruby
22
+ config.omniauth :twenty_three_and_me, {
23
+ ENV['23ANDME_KEY'],
24
+ ENV['23ANDME_SECRET'],
25
+ scope: 'basic genomes'
26
+ }
27
+ ```
28
+
29
+ The 23andMe API requires setting scopes for accessing different sorts of data. The "basic" one doesn't get you very far, "genomes" gets you the whole thing. More on scopes [here](https://api.23andme.com/docs/authentication/#scopes).
30
+
31
+ ## Credits
32
+
33
+ Based on the exampe of [Intridea](https://github.com/intridea)'s [omniauth-github](https://github.com/intridea/omniauth-github).
34
+
35
+ ## License
36
+
37
+ Copyright (c) 2013 Daniel Luxemburg
38
+
39
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
40
+
41
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
42
+
43
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -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
6
+
7
+ desc 'Run specs'
8
+ task :default => :spec
@@ -0,0 +1,2 @@
1
+ require "omniauth-23andme/version"
2
+ require 'omniauth/strategies/23andme'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module TwentyThreeAndMe
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,43 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class TwentyThreeAndMe < OmniAuth::Strategies::OAuth2
6
+ option :name, "twenty_three_and_me"
7
+ option :client_options, {
8
+ :site => 'https://api.23andme.com',
9
+ :authorize_url => 'https://api.23andme.com/authorize',
10
+ :token_url => 'https://api.23andme.com/token'
11
+ }
12
+ option :authorize_params, {grant_type: 'authorization_code'}
13
+
14
+ def request_phase
15
+ puts authorize_params
16
+ super
17
+ end
18
+
19
+ def authorize_params
20
+ super.tap do |params|
21
+ if request.params['scope']
22
+ params[:scope] = request.params['scope']
23
+ end
24
+ end
25
+ end
26
+
27
+ uid { raw_info['id'].to_s }
28
+
29
+ info do
30
+ {id:raw_info['id']}
31
+ end
32
+
33
+ extra do
34
+ {:raw_info => raw_info}
35
+ end
36
+
37
+ def raw_info
38
+ @raw_info ||= access_token.get("/1/user").parsed
39
+ end
40
+
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/omniauth-23andme/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Daniel Luxemburg"]
6
+ gem.email = ["daniel@danielluxemburg.com"]
7
+ gem.description = %q{OmniAuth for 23andMe.}
8
+ gem.summary = %q{Unofficial OmniAuth strategy for 23andMe.}
9
+ gem.homepage = "https://github.com/dluxemburg/omniauth-23andme"
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "omniauth-23andme"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = OmniAuth::TwentyThreeAndMe::VERSION
17
+
18
+ gem.add_dependency 'omniauth', '~> 1.0'
19
+ gem.add_dependency 'omniauth-oauth2', '~> 1.1'
20
+ gem.add_development_dependency 'rspec', '~> 2.7'
21
+ gem.add_development_dependency 'rack-test'
22
+ gem.add_development_dependency 'simplecov'
23
+ gem.add_development_dependency 'webmock'
24
+ end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::TwentyThreeAndMe do
4
+ let(:access_token) { double('AccessToken', :options => {}) }
5
+ let(:parsed_response) { double('ParsedResponse') }
6
+ let(:response) { double('Response', :parsed => parsed_response) }
7
+
8
+
9
+ subject do
10
+ OmniAuth::Strategies::TwentyThreeAndMe.new({})
11
+ end
12
+
13
+ before(:each) do
14
+ subject.stub(:full_host).and_return('http://mysite.com')
15
+ subject.stub(:script_name).and_return('')
16
+ subject.stub(:access_token).and_return(access_token)
17
+ end
18
+
19
+ context "client options" do
20
+ it 'should have correct site' do
21
+ subject.options.client_options.site.should eq("https://api.23andme.com")
22
+ end
23
+
24
+ it 'should have correct authorize url' do
25
+ subject.options.client_options.authorize_url.should eq('https://api.23andme.com/authorize')
26
+ end
27
+
28
+ it 'should have correct token url' do
29
+ subject.options.client_options.token_url.should eq('https://api.23andme.com/token')
30
+ end
31
+
32
+ end
33
+
34
+ context "#callback_url" do
35
+ it 'should redirect' do
36
+ subject.callback_url.should eq('http://mysite.com/auth/twenty_three_and_me/callback')
37
+ end
38
+ end
39
+
40
+ context "#raw_info" do
41
+ it "should call to '/1/user'" do
42
+ access_token.should_receive(:get).with('/1/user').and_return(response)
43
+ subject.raw_info.should eq(parsed_response)
44
+ end
45
+ end
46
+
47
+ end
@@ -0,0 +1,14 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+ require 'rspec'
4
+ require 'rack/test'
5
+ require 'webmock/rspec'
6
+ require 'omniauth'
7
+ require 'omniauth-23andme'
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
14
+
metadata ADDED
@@ -0,0 +1,139 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-23andme
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Daniel Luxemburg
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-07-27 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'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '2.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '2.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rack-test
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: webmock
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: OmniAuth for 23andMe.
98
+ email:
99
+ - daniel@danielluxemburg.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - .gitignore
105
+ - Gemfile
106
+ - README.md
107
+ - Rakefile
108
+ - lib/omniauth-23andme.rb
109
+ - lib/omniauth-23andme/version.rb
110
+ - lib/omniauth/strategies/23andme.rb
111
+ - omniauth-23andme.gemspec
112
+ - spec/omniauth/strategies/23andme_spec.rb
113
+ - spec/spec_helper.rb
114
+ homepage: https://github.com/dluxemburg/omniauth-23andme
115
+ licenses: []
116
+ metadata: {}
117
+ post_install_message:
118
+ rdoc_options: []
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - '>='
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ requirements: []
132
+ rubyforge_project:
133
+ rubygems_version: 2.0.0
134
+ signing_key:
135
+ specification_version: 4
136
+ summary: Unofficial OmniAuth strategy for 23andMe.
137
+ test_files:
138
+ - spec/omniauth/strategies/23andme_spec.rb
139
+ - spec/spec_helper.rb