omniauth-github-team-member 2.0.1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 218e0ef9988beea2c34414714e37f626a224d305
4
- data.tar.gz: 46178d0fad6e6566dce9973038b4f6f1ee544acd
2
+ SHA256:
3
+ metadata.gz: 2ac1491bf37b9186f206e2fe303e55090a1835f981dfe93519db775c38d21ad2
4
+ data.tar.gz: 41d42aa061dff7acee04796abf49425ad3b6dd4245e513c4a02a57b6f9b3f10a
5
5
  SHA512:
6
- metadata.gz: faf45019bf739e983db8e7a312db8541f5d2c60e4abb3adb5271fc9050c0fc2584c5ee6251b77dc1f5bf276dbc2ea506ffc1442a125b3bd618b185ef48de5f15
7
- data.tar.gz: e0aff5d84e5cde4b92895249dc1930f51d50dd2408810bf731e7df0233661f8489e3af13e0acabfeef29930a8c02ac7f35b5f0a92253780854ba3f2f046abb5f
6
+ metadata.gz: e4b226fa970d2d5a63ebf4e764021b10b049081bdcb63f2f9cea347fba279451f2236c9d472363509e41458ca06b22ec246ce56c139bffa43fc2131fd97d1474
7
+ data.tar.gz: f51c34abc78c5434471d684d67a281ca4c2513e4916af5b1b4a7e59caa6d016d60c7d5a5094e8ee0c5f23d5d9448d986b418b2dd251ef975b8fc1448f10d880c
data/README.md CHANGED
@@ -16,25 +16,27 @@ I like to store the GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET in my environment,
16
16
 
17
17
  ## Basic Usage
18
18
 
19
+ In the examples below, `42634` is the id of the team we are checking against. You can find the id of a team via the GitHub API, either by [listing all teams for the parent org](https://developer.github.com/v3/orgs/teams/#list-teams) or [finding all of the team memberships for a user who is on the team you are looking for](https://developer.github.com/v3/orgs/teams/#get-team-membership).
20
+
19
21
  Usage in Rails:
20
22
 
21
23
  ```ruby
24
+ # config/initializers/github_omniauth.rb
25
+
22
26
  Rails.application.config.middleware.use OmniAuth::Builder do
23
27
  provider :githubteammember,
24
28
  ENV['GITHUB_CLIENT_ID'],
25
29
  ENV['GITHUB_CLIENT_SECRET'],
26
- :scope => 'user',
27
- :teams => {
30
+ scope: 'read:org',
31
+ teams: {
28
32
  "mentors_team_member?" => 426344
29
33
  }
30
34
  end
31
35
  ```
32
36
 
33
- During the callback phase, you can check to see if the authed user is on the mentors team or not
34
- by checking the returned credentials object `request.env['omniauth.auth'].credentials.mentors_team_member?`.
37
+ During the callback phase, you can check to see if the authed user is on the mentors team or not by checking the returned credentials object `request.env['omniauth.auth'].credentials.mentors_team_member?`.
35
38
 
36
- An example of how to integrate this strategy with OmniAuth is below. Do note that these
37
- examples are just guidelines, you will most likely need to change each example to match your application's needs.
39
+ An example of how to integrate this strategy with OmniAuth is below. Do note that these examples are just guidelines, you will most likely need to change each example to match your application's needs.
38
40
 
39
41
  ```ruby
40
42
  class SessionsController
@@ -81,8 +83,8 @@ use OmniAuth::Builder do
81
83
  provider :githubteammember,
82
84
  ENV['GITHUB_CLIENT_ID'],
83
85
  ENV['GITHUB_CLIENT_SECRET'],
84
- :scope => 'user',
85
- :teams => {
86
+ scope: 'read:org',
87
+ teams: {
86
88
  "mentors_team_member?" => 426344
87
89
  }
88
90
  end
@@ -90,8 +92,7 @@ end
90
92
 
91
93
  ### Scopes
92
94
 
93
- You must require the user scope to be able to access the team data associated with
94
- the authenticated user.
95
+ You must require the `read:org` scope to be able to access the team data associated with the authenticated user.
95
96
 
96
97
  More info on [Scopes](http://developer.github.com/v3/oauth/#scopes).
97
98
 
@@ -108,3 +109,6 @@ More info on [Scopes](http://developer.github.com/v3/oauth/#scopes).
108
109
  * [Garrett Bjerkhoel](https://github.com/dewski)
109
110
  * [Jonathan Hoyt](https://github.com/jonmagic)
110
111
  * [Arthur Chiu](https://github.com/achiu)
112
+ * [Tim Clem](https://github.com/tclem)
113
+ * [Jessie Young](https://github.com/jessieay)
114
+ * [Paul Schreiber](https://github.com/paulschreiber)
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module GitHubTeamMember
3
- VERSION = '2.0.1'
3
+ VERSION = '2.1.0'
4
4
  end
5
5
  end
@@ -7,10 +7,18 @@ module OmniAuth
7
7
  options['teams'].inject({}) do |base, key_value_pair|
8
8
  method_name, team_id = key_value_pair
9
9
  base[booleanize_method_name(method_name)] = team_member?(team_id)
10
+ base["email"] = email_addresses
10
11
  base
11
12
  end
12
13
  end
13
14
 
15
+ def email_addresses
16
+ response = access_token.get("/user/emails")
17
+ response.status == 200 && response.parsed.map{|user| user["email"]}
18
+ rescue ::OAuth2::Error
19
+ false
20
+ end
21
+
14
22
  def team_member?(team_id)
15
23
  response = access_token.get("/teams/#{team_id}/memberships/#{raw_info['login']}")
16
24
  response.status == 200 && response.parsed["state"] == "active"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-github-team-member
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garrett Bjerkhoel
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-25 00:00:00.000000000 Z
12
+ date: 2021-02-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: omniauth-github
@@ -121,8 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  - !ruby/object:Gem::Version
122
122
  version: '0'
123
123
  requirements: []
124
- rubyforge_project:
125
- rubygems_version: 2.2.2
124
+ rubygems_version: 3.0.3
126
125
  signing_key:
127
126
  specification_version: 4
128
127
  summary: OmniAuth strategy for GitHub Team Auth.