omniauth-github 1.2.1 → 2.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 72538f29bb0f32daba3074d330d8e5524ec05d3a
4
- data.tar.gz: 4b2077a891853d05e098024fb0e7cdaab2ce1436
2
+ SHA256:
3
+ metadata.gz: 69587c7e122010a4aa5042e82d83a5783167c86b583dd5cda1d5f2a745e671f1
4
+ data.tar.gz: 01a585f28b26650b42fba83bf283760e0d26929f4b9ea0100bf7f244ed40898c
5
5
  SHA512:
6
- metadata.gz: a80670fc15ad32bb5ebd033cdf80ee1da215141180963b8df2560d9763a9f1c2bcad916312dd9f1e75bc5770ada73ca327e39fe48adbc0ffcd9b8b8431dd7171
7
- data.tar.gz: 903d08d81f70fe1ef648a19b8b468e027a8c6b41de7635486a2680f806eadc62b5135cf45a6722ccd6e23eb28b04fac3a104fb28004bc688cf1811d5e3d3f8be
6
+ metadata.gz: 23d79870e430a1331da27792d46151470a13e3bec0e98a8feff5a4d6df71605563ebc2b9206b2adfa60ab57c96f83e164f5351ee75ffe69f0803332385bc00f2
7
+ data.tar.gz: 47023e14293172e0e7ad0d24023097b8c6769435b05e8463b590bbe79a63bbad3e93dcc20c7845b7bf5981b6d86e723fd9430894a0a21561ce9ee49e3c35816b
@@ -0,0 +1,26 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ ruby-version: ['2.4', '2.5', '2.6']
15
+
16
+ steps:
17
+ - uses: actions/checkout@v2
18
+ - name: Set up Ruby ${{ matrix.ruby-version }}
19
+ uses: actions/setup-ruby@v1
20
+ with:
21
+ ruby-version: ${{ matrix.ruby-version }}
22
+ - name: Build and test with Rake
23
+ run: |
24
+ gem install bundler
25
+ bundle install --jobs 4 --retry 3
26
+ bundle exec rake
data/README.md CHANGED
@@ -1,9 +1,17 @@
1
+ ![Ruby](https://github.com/omniauth/omniauth-github/workflows/Ruby/badge.svg?branch=master)
2
+
1
3
  # OmniAuth GitHub
2
4
 
3
5
  This is the official OmniAuth strategy for authenticating to GitHub. To
4
6
  use it, you'll need to sign up for an OAuth2 Application ID and Secret
5
7
  on the [GitHub Applications Page](https://github.com/settings/applications).
6
8
 
9
+ ## Installation
10
+
11
+ ```ruby
12
+ gem 'omniauth-github', github: 'omniauth/omniauth-github', branch: 'master'
13
+ ```
14
+
7
15
  ## Basic Usage
8
16
 
9
17
  ```ruby
@@ -12,6 +20,18 @@ use OmniAuth::Builder do
12
20
  end
13
21
  ```
14
22
 
23
+
24
+ ## Basic Usage Rails
25
+
26
+ In `config/initializers/github.rb`
27
+
28
+ ```ruby
29
+ Rails.application.config.middleware.use OmniAuth::Builder do
30
+ provider :github, ENV['GITHUB_KEY'], ENV['GITHUB_SECRET']
31
+ end
32
+ ```
33
+
34
+
15
35
  ## Github Enterprise Usage
16
36
 
17
37
  ```ruby
@@ -35,7 +55,12 @@ use OmniAuth::Builder do
35
55
  end
36
56
  ```
37
57
 
38
- More info on [Scopes](http://developer.github.com/v3/oauth/#scopes).
58
+ More info on [Scopes](https://docs.github.com/en/developers/apps/scopes-for-oauth-apps).
59
+
60
+
61
+ ## Semver
62
+ This project adheres to Semantic Versioning 2.0.0. Any violations of this scheme are considered to be bugs.
63
+ All changes will be tracked [here](https://github.com/omniauth/omniauth-github/releases).
39
64
 
40
65
  ## License
41
66
 
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module GitHub
3
- VERSION = "1.2.1"
3
+ VERSION = "2.0.0"
4
4
  end
5
5
  end
@@ -28,7 +28,7 @@ module OmniAuth
28
28
  info do
29
29
  {
30
30
  'nickname' => raw_info['login'],
31
- 'email' => primary_email,
31
+ 'email' => email,
32
32
  'name' => raw_info['name'],
33
33
  'image' => raw_info['avatar_url'],
34
34
  'urls' => {
@@ -39,11 +39,11 @@ module OmniAuth
39
39
  end
40
40
 
41
41
  extra do
42
- {:raw_info => raw_info, :all_emails => emails}
42
+ {:raw_info => raw_info, :all_emails => emails, :scope => scope }
43
43
  end
44
44
 
45
45
  def raw_info
46
- access_token.options[:mode] = :query
46
+ access_token.options[:mode] = :header
47
47
  @raw_info ||= access_token.get('user').parsed
48
48
  end
49
49
 
@@ -51,6 +51,10 @@ module OmniAuth
51
51
  (email_access_allowed?) ? primary_email : raw_info['email']
52
52
  end
53
53
 
54
+ def scope
55
+ access_token['scope']
56
+ end
57
+
54
58
  def primary_email
55
59
  primary = emails.find{ |i| i['primary'] && i['verified'] }
56
60
  primary && primary['email'] || nil
@@ -59,7 +63,7 @@ module OmniAuth
59
63
  # The new /user/emails API - http://developer.github.com/v3/users/emails/#future-response
60
64
  def emails
61
65
  return [] unless email_access_allowed?
62
- access_token.options[:mode] = :query
66
+ access_token.options[:mode] = :header
63
67
  @emails ||= access_token.get('user/emails', :headers => { 'Accept' => 'application/vnd.github.v3' }).parsed
64
68
  end
65
69
 
@@ -69,6 +73,10 @@ module OmniAuth
69
73
  scopes = options['scope'].split(',')
70
74
  (scopes & email_scopes).any?
71
75
  end
76
+
77
+ def callback_url
78
+ full_host + callback_path
79
+ end
72
80
  end
73
81
  end
74
82
  end
@@ -16,8 +16,8 @@ Gem::Specification.new do |gem|
16
16
  gem.require_paths = ["lib"]
17
17
  gem.version = OmniAuth::GitHub::VERSION
18
18
 
19
- gem.add_dependency 'omniauth', '~> 1.4.0'
20
- gem.add_dependency 'omniauth-oauth2', '>= 1.4.0', '< 2.0'
19
+ gem.add_dependency 'omniauth', '~> 2.0'
20
+ gem.add_dependency 'omniauth-oauth2', '~> 1.7.1'
21
21
  gem.add_development_dependency 'rspec', '~> 3.5'
22
22
  gem.add_development_dependency 'rack-test'
23
23
  gem.add_development_dependency 'simplecov'
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe OmniAuth::Strategies::GitHub do
4
- let(:access_token) { instance_double('AccessToken', :options => {}) }
4
+ let(:access_token) { instance_double('AccessToken', :options => {}, :[] => 'user') }
5
5
  let(:parsed_response) { instance_double('ParsedResponse') }
6
6
  let(:response) { instance_double('Response', :parsed => parsed_response) }
7
7
 
@@ -122,6 +122,12 @@ describe OmniAuth::Strategies::GitHub do
122
122
  expect(access_token).to receive(:get).with('user').and_return(response)
123
123
  expect(subject.raw_info).to eq(parsed_response)
124
124
  end
125
+
126
+ it 'should use the header auth mode' do
127
+ expect(access_token).to receive(:get).with('user').and_return(response)
128
+ subject.raw_info
129
+ expect(access_token.options[:mode]).to eq(:header)
130
+ end
125
131
  end
126
132
 
127
133
  context '#emails' do
@@ -133,6 +139,24 @@ describe OmniAuth::Strategies::GitHub do
133
139
  subject.options['scope'] = 'user'
134
140
  expect(subject.emails).to eq(parsed_response)
135
141
  end
142
+
143
+ it 'should use the header auth mode' do
144
+ expect(access_token).to receive(:get).with('user/emails', :headers => {
145
+ 'Accept' => 'application/vnd.github.v3'
146
+ }).and_return(response)
147
+
148
+ subject.options['scope'] = 'user'
149
+ subject.emails
150
+ expect(access_token.options[:mode]).to eq(:header)
151
+ end
152
+ end
153
+
154
+ context '#info.email' do
155
+ it 'should use any available email' do
156
+ allow(subject).to receive(:raw_info).and_return({})
157
+ allow(subject).to receive(:email).and_return('you@example.com')
158
+ expect(subject.info['email']).to eq('you@example.com')
159
+ end
136
160
  end
137
161
 
138
162
  context '#info.urls' do
@@ -141,4 +165,19 @@ describe OmniAuth::Strategies::GitHub do
141
165
  expect(subject.info['urls']['GitHub']).to eq('http://enterprise/me')
142
166
  end
143
167
  end
168
+
169
+ context '#extra.scope' do
170
+ it 'returns the scope on the returned access_token' do
171
+ expect(subject.scope).to eq('user')
172
+ end
173
+ end
174
+
175
+ describe '#callback_url' do
176
+ it 'is a combination of host, script name, and callback path' do
177
+ allow(subject).to receive(:full_host).and_return('https://example.com')
178
+ allow(subject).to receive(:script_name).and_return('/sub_uri')
179
+
180
+ expect(subject.callback_url).to eq('https://example.com/sub_uri/auth/github/callback')
181
+ end
182
+ end
144
183
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-github
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Bleigh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-06 00:00:00.000000000 Z
11
+ date: 2021-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth
@@ -16,34 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.4.0
19
+ version: '2.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.4.0
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: omniauth-oauth2
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 1.4.0
34
- - - "<"
31
+ - - "~>"
35
32
  - !ruby/object:Gem::Version
36
- version: '2.0'
33
+ version: 1.7.1
37
34
  type: :runtime
38
35
  prerelease: false
39
36
  version_requirements: !ruby/object:Gem::Requirement
40
37
  requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: 1.4.0
44
- - - "<"
38
+ - - "~>"
45
39
  - !ruby/object:Gem::Version
46
- version: '2.0'
40
+ version: 1.7.1
47
41
  - !ruby/object:Gem::Dependency
48
42
  name: rspec
49
43
  requirement: !ruby/object:Gem::Requirement
@@ -107,6 +101,7 @@ executables: []
107
101
  extensions: []
108
102
  extra_rdoc_files: []
109
103
  files:
104
+ - ".github/workflows/ruby.yml"
110
105
  - ".gitignore"
111
106
  - ".rspec"
112
107
  - Gemfile
@@ -139,8 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
134
  - !ruby/object:Gem::Version
140
135
  version: '0'
141
136
  requirements: []
142
- rubyforge_project:
143
- rubygems_version: 2.6.4
137
+ rubygems_version: 3.0.3
144
138
  signing_key:
145
139
  specification_version: 4
146
140
  summary: Official OmniAuth strategy for GitHub.