omniauth-github 1.3.0 → 1.4.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: 7360551f98f08e0dc6b099cb8244f1c228be89b9
4
- data.tar.gz: aeee13d4e028e0f6d55ecc2b395bbe13d129055f
2
+ SHA256:
3
+ metadata.gz: 1f88c8d62903eb54ee19e957aea594380734acdf20943ea24817919659d1caa1
4
+ data.tar.gz: 2343a7c819ef367eebda314e3d3dfab4b0801f2c0165d72249b3a2ed0a5e5c4a
5
5
  SHA512:
6
- metadata.gz: d0dc0f3cf76e07f851edfd9689302dadc618e98a12b03420f62aa836fef5ce14a7c458bf2d0d30d6c7c66ce332ad65ac610ff636532f7821611844f2db67235f
7
- data.tar.gz: fca276a62cb23009a282ecbeb9e8b18e50a9b5048a71665742203514d55de636c6220b4aa8af8aabc76a14d3fe3c7be0dd172208d15829cc7741ba17fa52e2ee
6
+ metadata.gz: 3081908b47df5e1dbe4c1241910643d61949f9a2692cb1c9436d04a44e122d0096f01560a8666bf8c0d56e937c93a78e98be9eafb0270e0f6addb835dc99ccd0
7
+ data.tar.gz: 2162fbeb8c660834bd9cd09053ed77fa48f32f8b705a8d30d3128165c1144116731f22bdb8859ed07f2d1a520c6308e287ee76f02378876bde63450a85402863
@@ -0,0 +1,22 @@
1
+ name: Ruby
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ test:
7
+ runs-on: ubuntu-latest
8
+ strategy:
9
+ matrix:
10
+ ruby-version: ['2.4', '2.5', '2.6']
11
+
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+ - name: Set up Ruby ${{ matrix.ruby-version }}
15
+ uses: actions/setup-ruby@v1
16
+ with:
17
+ ruby-version: ${{ matrix.ruby-version }}
18
+ - name: Build and test with Rake
19
+ run: |
20
+ gem install bundler
21
+ bundle install --jobs 4 --retry 3
22
+ 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
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module GitHub
3
- VERSION = "1.3.0"
3
+ VERSION = "1.4.0"
4
4
  end
5
5
  end
@@ -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
 
@@ -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,16 @@ 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
136
152
  end
137
153
 
138
154
  context '#info.email' do
@@ -150,6 +166,12 @@ describe OmniAuth::Strategies::GitHub do
150
166
  end
151
167
  end
152
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
+
153
175
  describe '#callback_url' do
154
176
  it 'is a combination of host, script name, and callback path' do
155
177
  allow(subject).to receive(:full_host).and_return('https://example.com')
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.3.0
4
+ version: 1.4.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-05-23 00:00:00.000000000 Z
11
+ date: 2020-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth
@@ -107,6 +107,7 @@ executables: []
107
107
  extensions: []
108
108
  extra_rdoc_files: []
109
109
  files:
110
+ - ".github/workflows/ruby.yml"
110
111
  - ".gitignore"
111
112
  - ".rspec"
112
113
  - Gemfile
@@ -139,8 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
140
  - !ruby/object:Gem::Version
140
141
  version: '0'
141
142
  requirements: []
142
- rubyforge_project:
143
- rubygems_version: 2.6.11
143
+ rubygems_version: 3.0.3
144
144
  signing_key:
145
145
  specification_version: 4
146
146
  summary: Official OmniAuth strategy for GitHub.